volto icon indicating copy to clipboard operation
volto copied to clipboard

Use only App.jsx asyncConnect for getNavigation dispatching

Open tiberiuichim opened this issue 2 years ago • 3 comments

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?

tiberiuichim avatar Oct 17 '21 07:10 tiberiuichim

The tests would have to be updated... the @navigation endpoint is no longer (re)loaded on everything. I'd call that a desirable optimization.

tiberiuichim avatar Oct 17 '21 08:10 tiberiuichim

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.

sneridagh avatar Jul 14 '22 08:07 sneridagh

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,
        ];
      },
    },
];

tiberiuichim avatar Sep 10 '22 17:09 tiberiuichim