diff --git a/docs/HISTORY.txt b/docs/HISTORY.txt index fbc6861..c6a10ed 100644 --- a/docs/HISTORY.txt +++ b/docs/HISTORY.txt @@ -1,6 +1,15 @@ Changelog ========= +6.1 - (2024-12-10) +--------------------------- +* Fix: large query on context navigation when on layout or add new item. + We return no results when we have the `Additional files` variation set + since it has potential to have a very large number of items. + [ichim-david - refs #280463] +* Feature: Add `Language` querystring field in order to be able to filter by language in Search block + [avoinea - refs #281503] + 6.0 - (2024-12-05) --------------------------- * Change: Fix plone.app.vocabularies.Users to work with Creators and Contributors Field diff --git a/eea/volto/policy/profiles.zcml b/eea/volto/policy/profiles.zcml index 66ddd3f..853580d 100644 --- a/eea/volto/policy/profiles.zcml +++ b/eea/volto/policy/profiles.zcml @@ -16,6 +16,15 @@ post_handler=".setuphandlers.post_install" /> + + - 5.4 + 6.1 profile-plone.volto:default diff --git a/eea/volto/policy/profiles/multilingual/registry/plone.app.querystring.field.Language.xml b/eea/volto/policy/profiles/multilingual/registry/plone.app.querystring.field.Language.xml new file mode 100644 index 0000000..9c500bd --- /dev/null +++ b/eea/volto/policy/profiles/multilingual/registry/plone.app.querystring.field.Language.xml @@ -0,0 +1,16 @@ + + + + Language + The language of the content. + True + False + + plone.app.querystring.operation.selection.any + + plone.app.vocabularies.SupportedContentLanguages + Text + + diff --git a/eea/volto/policy/restapi/services/contextnavigation/get.py b/eea/volto/policy/restapi/services/contextnavigation/get.py index 6e28335..2facbd3 100644 --- a/eea/volto/policy/restapi/services/contextnavigation/get.py +++ b/eea/volto/policy/restapi/services/contextnavigation/get.py @@ -1,11 +1,15 @@ """EEA Context Navigation""" +from Acquisition import aq_inner from zope.component import getUtility from zope.component import adapter +from zope.globalrequest import getRequest from zope.schema.interfaces import IFromUnicode from zope.interface import implementer from zope.interface import Interface +from Products.CMFCore.interfaces import ISiteRoot from Products.CMFPlone.utils import normalizeString +from plone.app.layout.navigation.navtree import buildFolderTree from plone.app.layout.navigation.root import getNavigationRoot from plone.app.dexterity import _ from plone.restapi.services.contextnavigation import get as original_get @@ -15,6 +19,7 @@ from plone.restapi.bbb import safe_hasattr from plone import schema from plone import api +from plone.memoize.instance import memoize class IEEANavigationPortlet(original_get.INavigationPortlet): @@ -87,11 +92,25 @@ def __init__(self, context, data): if depth == 0: depth = 999 + currentFolderOnly = data.currentFolderOnly + root = original_get.get_root(context, data.root_path) if root is not None: rootPath = "/".join(root.getPhysicalPath()) else: - rootPath = getNavigationRoot(context) + rootPath = getNavigationRoot(context) if not currentFolderOnly \ + else "/".join(context.getPhysicalPath()) + + # avoid large queries on layout pages where context is site + if currentFolderOnly: + request = getRequest() + # don't query when we add a new page and we use report_navigation + is_site = ISiteRoot.providedBy(context) + if is_site or 'add?type' in request.get('HTTP_REFERER', '') and \ + request.form.get('expand.contextnavigation.variation', '')\ + == 'report_navigation': + self.query = {} + return # EEA modification to always use the rootPath for query self.query["path"] = {"query": rootPath, "depth": depth, @@ -106,7 +125,15 @@ def __init__(self, context, data): self.query["path"]["navtree_start"] = depth -original_get.QueryBuilder = EEAContextNavigationQueryBuilder +class EEANavtreeStrategy(original_get.NavtreeStrategy): + """Custom NavtreeStrategy for context navigation""" + + def decoratorFactory(self, node): + """Decorate the navigation tree""" + new_node = super().decoratorFactory(node) + if getattr(new_node["item"], "side_nav_title", False): + new_node["side_nav_title"] = new_node["item"].side_nav_title + return new_node class EEANavigationPortletRenderer(original_get.NavigationPortletRenderer): @@ -180,6 +207,24 @@ def title(self): # handle bug where empty title is set to undefined from Volto return name if name != "undefined" else self.data.title + @memoize + def getNavTree(self, _marker=None): + """ Get the navigation tree """ + + if _marker is None: + _marker = [] + context = aq_inner(self.context) + queryBuilder = EEAContextNavigationQueryBuilder(context, self.data) + query_result = queryBuilder() + if not query_result: + return {"children": []} + strategy = EEANavtreeStrategy(context, self.data) + + tree = buildFolderTree( + context, obj=context, query=query_result, strategy=strategy + ) + return tree + def recurse(self, children, level, bottomLevel): """Recurse through the navigation tree""" res = [] @@ -289,18 +334,3 @@ def reply(self): return navigation(expand=True, prefix="expand.contextnavigation.")[ "contextnavigation" ] - - -class EEANavtreeStrategy(original_get.NavtreeStrategy): - """Custom NavtreeStrategy for context navigation""" - - def decoratorFactory(self, node): - """Decorate the navigation tree""" - new_node = super().decoratorFactory(node) - if getattr(new_node["item"], "side_nav_title", False): - new_node["side_nav_title"] = new_node["item"].side_nav_title - return new_node - - -# Monkey patch the original NavtreeStrategy -original_get.NavtreeStrategy = EEANavtreeStrategy diff --git a/eea/volto/policy/setuphandlers.py b/eea/volto/policy/setuphandlers.py index d211252..b4c0fb9 100644 --- a/eea/volto/policy/setuphandlers.py +++ b/eea/volto/policy/setuphandlers.py @@ -19,6 +19,7 @@ def getNonInstallableProfiles(self): """ Hide uninstall profile from site-creation and quickinstaller. """ return [ + 'eea.volto.policy:multilingual', 'eea.volto.policy:uninstall', ] diff --git a/eea/volto/policy/upgrades/configure.zcml b/eea/volto/policy/upgrades/configure.zcml index bda67d6..4cc1cf4 100644 --- a/eea/volto/policy/upgrades/configure.zcml +++ b/eea/volto/policy/upgrades/configure.zcml @@ -74,4 +74,16 @@ + + + + + + diff --git a/eea/volto/policy/version.txt b/eea/volto/policy/version.txt index e0ea36f..a435f5a 100644 --- a/eea/volto/policy/version.txt +++ b/eea/volto/policy/version.txt @@ -1 +1 @@ -6.0 +6.1