Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POC: Add option to disable Classic UI. #3922

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions Products/CMFPlone/_disable_classic_ui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
"""Hang on, this is funny.

The summary is: if you want to (partially) disable Classic UI,
you can set an environment variable DISABLE_CLASSIC_UI=true.
This is a temporary measure for Plone 6.1+.
In Plone 7, Classic UI would be disabled by default,
unless the plone.classicui package is available.

How does this work?

In meta.zcml, we check if this module can be imported.
If the import works, we register a zcml feature "disable-classic-ui".
If the import doesn't work, we do nothing, and all is normal.

In this module, we check for an environment variable DISABLE_CLASSIC_UI.
We check if this has been set, and has a "truthy" value.

If it is truthy, we do nothing.
Result: this module can be imported.

If it is not set, or not truthy, we raise an ImportError.
Result: this module can't be imported.
This is actually the expected default case in Plone 6.

Now we can use zcml:condition="not-have disable-classic-ui"
around zcml parts that load zcml that is only of interest for Classic UI.

Some potential targets:

* portlets
* viewlets
* plonetheme.barceloneta
* plone.staticresources

In the first tests with portlets, we can see that it can be tricky to get this right.

* We can avoid loading the zcml of plone.portlets, plone.app.portlets,
and plone.portlet.static/collection in CMFPlone, but plone.portlet.static
has autoinclude of its zcml turned on setup.py, and loading it fails.
This is something to fix in plone.portlet.static.
* plone.app.event defines two own portlets, so it needs to use the same
conditional loading of this part of its zcml.
* The rolemap.xml of CMFPlone wants to set roles for a permission
"Portlets: Manage portlets" and this fails unless we load the
permissions.zcml from plone.app.portlets anyway.
* In metadata.xml of the CMFPlone dependencies profile, we want to install
the default profiles of plone.portlet.collection/static, which fails.
A solution would be to integrate the portlets.xml from these two packages in our own.
* Note that it is fine that CMFPlone has a portlets.xml: if the plone.app.portlets
zcml is not loaded, no import handler is defined that reads this.
* plone.app.contentmenu defines a Portlets menu, which leads to non-existing urls.
The contentmenu is specific for Classic UI though, so we might want to avoid
loading this as well.
* Obviously lots of tests will fail.
Nicest would be to have an extra job on Jenkins or GitHub Actions that installs
only Products.CMFPlone and its test dependencies, and disable Classic UI there,
and run the tests.
* It might be easier to first "unify" the portlets:
* Move the portlets from plone.portlet.collection/static and plone.app.event
to plone.app.portlets.
* Keep BBB imports in place, to avoid breaking existing portlets.
* Be careful to not introduce circular imports.
* Move portlets.xml from CMFPlone to plone.app.portlets in a new profile.
* Move the portlet part of rolemap.xml to plone.app.portlets.
* Make sure to install the new profile by default: we only want to change
this in Plone 7.
* Perhaps disabling plone.app.layout.viewlets is an easier first target
for disabling a part of Classic UI. :-)

"""
import os


if os.getenv("DISABLE_CLASSIC_UI", "").lower() not in ("true", "yes", "on", "1"):
raise ImportError("Explicitly raised ImportError to disable Classic UI.")
15 changes: 11 additions & 4 deletions Products/CMFPlone/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<include package="plone.locking" />
<include package="plone.memoize" />
<include package="plone.outputfilters" />
<include package="plone.portlets" />
<include package="plone.protect" />
<include package="plone.registry" />
<include package="plone.resource" />
Expand All @@ -50,7 +49,6 @@
<include package="plone.app.linkintegrity" />
<include package="plone.app.locales" />
<include zcml:condition="installed plone.app.multilingual" package="plone.app.multilingual" />
<include package="plone.app.portlets" />
<include package="plone.app.redirector" />
<include package="plone.app.registry" />
<include package="plone.app.theming" />
Expand All @@ -61,8 +59,17 @@
<include package="plone.app.workflow" />

<!-- plone extra -->
<include package="plone.portlet.static" />
<include package="plone.portlet.collection" />
<configure zcml:condition="not-have disable-classic-ui">
<include zcml:condition="installed plone.portlets" package="plone.portlets" />
<include zcml:condition="installed plone.app.portlets" package="plone.app.portlets" />
<include zcml:condition="installed plone.portlet.static" package="plone.portlet.static" />
<include zcml:condition="installed plone.portlet.collection" package="plone.portlet.collection" />
</configure>
<configure zcml:condition="have disable-classic-ui">
<!-- We must include this, otherwise the CMFPlone rolemap.xml cannot be imported. -->
<include package="plone.app.portlets" file="permissions.zcml" />
</configure>

<include package="plonetheme.barceloneta" />

<!-- conditional -->
Expand Down
19 changes: 15 additions & 4 deletions Products/CMFPlone/meta.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
<meta:provides feature="plone-52" />
<meta:provides feature="plone-60" />
<meta:provides feature="plone-61" />
<!-- XXX plone.portlet.static has autoinclude, which does not help here.
So temporarily switch this off.
See remarks in _disable_classic_ui.py -->
<meta:provides feature="disable-autoinclude" />

<configure zcml:condition="installed Products.CMFPlone._disable_classic_ui">
<meta:provides feature="disable-classic-ui" />
</configure>

<include
package="Products.CMFCore"
Expand All @@ -43,10 +51,13 @@
package="plone.app.dexterity"
file="meta.zcml"
/>
<include
package="plone.app.portlets"
file="meta.zcml"
/>
<configure zcml:condition="not-have disable-classic-ui">
<include
package="plone.app.portlets"
file="meta.zcml"
zcml:condition="installed plone.app.portlets"
/>
</configure>
<include
package="plone.contentrules"
file="meta.zcml"
Expand Down
14 changes: 9 additions & 5 deletions Products/CMFPlone/overrides.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@
package="plone.i18n"
file="overrides.zcml"
/>
<configure zcml:condition="not-have disable-classic-ui">
<include package="disable.override" />
<include
package="plone.app.portlets"
file="overrides.zcml"
zcml:condition="installed plone.app.portlets"
/>
</configure>
<include
package="plone.app.portlets"
file="overrides.zcml"
/>
<include
zcml:condition="installed plone.app.multilingual"
zcml:condition="installed plone.app.multilingual"
package="plone.app.multilingual"
file="overrides.zcml"
/>
Expand Down
5 changes: 3 additions & 2 deletions Products/CMFPlone/profiles/dependencies/metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
<dependency>profile-plone.app.theming:default</dependency>
<dependency>profile-plone.app.users:default</dependency>
<dependency>profile-plone.outputfilters:default</dependency>
<dependency>profile-plone.portlet.collection:default</dependency>
<dependency>profile-plone.portlet.static:default</dependency>
<!-- TODO Integrate the portlets.xml from these two packages in our own. -->
<!-- <dependency>profile-plone.portlet.collection:default</dependency> -->
<!-- <dependency>profile-plone.portlet.static:default</dependency> -->
<dependency>profile-plone.protect:default</dependency>
<dependency>profile-plone.staticresources:default</dependency>
</dependencies>
Expand Down