volto
volto copied to clipboard
Use only App.jsx asyncConnect for getNavigation dispatching
This fixes the issue of having to reload the page when logging in, to be able to see private top level folders, see https://github.com/plone/volto/issues/2721
Also fixes the issue when deleting a top-level page in Contents (but you have to step out of contents view, as Contents is also asyncConnected. The __SERVER__
condition should be removed from there, as well.
Looking for feedback on this... should we pursue this path?
The tests would have to be updated... the @navigation
endpoint is no longer (re)loaded on everything. I'd call that a desirable optimization.
I'm ok with this, taking into account that asyncConnect might go in the foreseeable future.
Also, I'm +1 on pursue the assimilation not only of the navigation query, but the breadcrumbs as well. Removing the query action from the components, making them "structural" as the content one.
However, I'd also investigate if we could spare both, using only the expanders, or selectively using them when required. Also, if the expander is present, always use the expander.
Let's talk about it.
As a workaround, in case this PR doesn't get through, here's how I did it in my project:
config.settings.asyncPropsExtenders = [
...(config.settings.asyncPropsExtenders || []),
{
key: 'navigation',
extend: (dispatchActions) => {
const action = {
key: 'navigation',
promise: ({ location, store: { dispatch } }) => {
// Customized, we don't want SERVER as a condition
return dispatch(
getNavigation(
getBaseUrl(location.pathname),
config.settings.navDepth,
),
);
},
};
return [
...dispatchActions.filter(({ key }) => key !== 'navigation'),
action,
];
},
},
];