Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions packages/volto/news/8258.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix(Subpath): dispatch async actions for controlpanels on /controlpanels @nileshgulia1
Comment thread
nileshgulia1 marked this conversation as resolved.
Outdated
12 changes: 10 additions & 2 deletions packages/volto/src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ import { installDefaultWidgets } from './Widgets';
import { installDefaultViews } from './Views';
import { installDefaultBlocks } from './Blocks';

import { getSiteAsyncPropExtender } from '@plone/volto/helpers/Site';
import {
getSiteAsyncPropExtender,
SystemInfoAsyncPropExtender,
getControlpanelAsyncPropExtender,
} from '@plone/volto/helpers/Site';
import { registerValidators } from './validation';

import languages from '@plone/volto/constants/Languages.cjs';
Expand Down Expand Up @@ -124,7 +128,11 @@ let config = {
useEmailAsLogin: false,
persistentReducers: ['blocksClipboard.cut', 'blocksClipboard.copy'],
initialReducersBlacklist: [], // reducers in this list won't be hydrated in windows.__data
asyncPropsExtenders: [getSiteAsyncPropExtender], // per route asyncConnect customizers
asyncPropsExtenders: [
getSiteAsyncPropExtender,
SystemInfoAsyncPropExtender,
getControlpanelAsyncPropExtender,
], // per route asyncConnect customizers
contentIcons: contentIcons,
loadables,
lazyBundles: {
Expand Down
49 changes: 48 additions & 1 deletion packages/volto/src/helpers/Site/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { GET_SITE } from '@plone/volto/constants/ActionTypes';
import { getSite } from '@plone/volto/actions/site/site';
import {
listControlpanels,
getSystemInformation,
} from '@plone/volto/actions/controlpanels/controlpanels';
import config from '@plone/volto/registry';

const prefixPath = config.settings.subpathPrefix || '';

const getSiteAsyncPropExtender = {
path: '/',
Expand All @@ -18,4 +25,44 @@ const getSiteAsyncPropExtender = {
},
};

export { getSiteAsyncPropExtender };
const getControlpanelAsyncPropExtender = {
path: `${prefixPath}/controlpanel`,
extend: (dispatchActions) => {
if (
dispatchActions.filter(
(asyncAction) => asyncAction.key === 'controlpanels',
).length === 0
) {
dispatchActions.push({
key: 'controlpanels',
promise: ({ location, store: { dispatch } }) =>
__SERVER__ && dispatch(listControlpanels()),
});
}
return dispatchActions;
},
};

const SystemInfoAsyncPropExtender = {
Comment thread
nileshgulia1 marked this conversation as resolved.
Outdated
path: `${prefixPath}/controlpanel`,
extend: (dispatchActions) => {
if (
dispatchActions.filter(
(asyncAction) => asyncAction.key === 'systemInformation',
).length === 0
) {
dispatchActions.push({
key: 'systemInformation',
promise: ({ location, store: { dispatch } }) =>
__SERVER__ && dispatch(getSystemInformation()),
});
}
return dispatchActions;
},
};

export {
getSiteAsyncPropExtender,
SystemInfoAsyncPropExtender,
getControlpanelAsyncPropExtender,
};
Loading