mirror of
https://github.com/strapi/strapi.git
synced 2025-11-10 15:19:00 +00:00
Init dynamic load of plugins
Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
parent
c2ae41acb0
commit
6e4604d662
@ -45,7 +45,7 @@ function SettingsPage() {
|
|||||||
);
|
);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const pluginsRoutes = useMemo(() => createSectionsRoutes(settings), [settings]);
|
const pluginsRoutes = createSectionsRoutes(settings);
|
||||||
|
|
||||||
// Only display accessible sections
|
// Only display accessible sections
|
||||||
const filteredMenu = useMemo(() => getSectionsToDisplay(menu), [menu]);
|
const filteredMenu = useMemo(() => getSectionsToDisplay(menu), [menu]);
|
||||||
|
|||||||
@ -1,55 +1,99 @@
|
|||||||
import RolesCreatePage from 'ee_else_ce/pages/Roles/CreatePage';
|
import RolesCreatePage from 'ee_else_ce/pages/Roles/CreatePage';
|
||||||
import ProtectedRolesListPage from 'ee_else_ce/pages/Roles/ProtectedListPage';
|
import ProtectedRolesListPage from 'ee_else_ce/pages/Roles/ProtectedListPage';
|
||||||
import UsersEditPage from '../../Users/ProtectedEditPage';
|
|
||||||
import UsersListPage from '../../Users/ProtectedListPage';
|
|
||||||
import RolesEditPage from '../../Roles/ProtectedEditPage';
|
|
||||||
import WebhooksCreateView from '../../Webhooks/ProtectedCreateView';
|
|
||||||
import WebhooksEditView from '../../Webhooks/ProtectedEditView';
|
|
||||||
import WebhooksListView from '../../Webhooks/ProtectedListView';
|
|
||||||
|
|
||||||
const defaultRoutes = [
|
const defaultRoutes = [
|
||||||
{
|
{
|
||||||
Component: ProtectedRolesListPage,
|
Component: () => {
|
||||||
|
return { default: ProtectedRolesListPage };
|
||||||
|
},
|
||||||
|
|
||||||
to: '/settings/roles',
|
to: '/settings/roles',
|
||||||
exact: true,
|
exact: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Component: RolesCreatePage,
|
Component: () => {
|
||||||
|
return { default: RolesCreatePage };
|
||||||
|
},
|
||||||
to: '/settings/roles/duplicate/:id',
|
to: '/settings/roles/duplicate/:id',
|
||||||
exact: true,
|
exact: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Component: RolesCreatePage,
|
// Component: RolesCreatePage,
|
||||||
|
Component: () => {
|
||||||
|
return { default: RolesCreatePage };
|
||||||
|
},
|
||||||
to: '/settings/roles/new',
|
to: '/settings/roles/new',
|
||||||
exact: true,
|
exact: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Component: RolesEditPage,
|
// Component: RolesEditPage,
|
||||||
|
Component: async () => {
|
||||||
|
const component = await import(
|
||||||
|
/* webpackChunkName: "admin-edit-roles-page" */ '../../Roles/ProtectedEditPage'
|
||||||
|
);
|
||||||
|
|
||||||
|
return component;
|
||||||
|
},
|
||||||
to: '/settings/roles/:id',
|
to: '/settings/roles/:id',
|
||||||
exact: true,
|
exact: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Component: UsersListPage,
|
// Component: UsersListPage,
|
||||||
|
Component: async () => {
|
||||||
|
const component = await import(
|
||||||
|
/* webpackChunkName: "admin-users" */ '../../Users/ProtectedListPage'
|
||||||
|
);
|
||||||
|
|
||||||
|
return component;
|
||||||
|
},
|
||||||
to: '/settings/users',
|
to: '/settings/users',
|
||||||
exact: true,
|
exact: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Component: UsersEditPage,
|
// Component: UsersEditPage,
|
||||||
|
Component: async () => {
|
||||||
|
const component = await import(
|
||||||
|
/* webpackChunkName: "admin-edit-users" */ '../../Users/ProtectedEditPage'
|
||||||
|
);
|
||||||
|
|
||||||
|
return component;
|
||||||
|
},
|
||||||
to: '/settings/users/:id',
|
to: '/settings/users/:id',
|
||||||
exact: true,
|
exact: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Component: WebhooksCreateView,
|
// Component: WebhooksCreateView,
|
||||||
|
Component: async () => {
|
||||||
|
const component = await import(
|
||||||
|
/* webpackChunkName: "webhook-edit-page" */ '../../Webhooks/ProtectedCreateView'
|
||||||
|
);
|
||||||
|
|
||||||
|
return component;
|
||||||
|
},
|
||||||
to: '/settings/webhooks/create',
|
to: '/settings/webhooks/create',
|
||||||
exact: true,
|
exact: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Component: WebhooksEditView,
|
// Component: WebhooksEditView,
|
||||||
|
Component: async () => {
|
||||||
|
const component = await import(
|
||||||
|
/* webpackChunkName: "webhook-edit-page" */ '../../Webhooks/ProtectedEditView'
|
||||||
|
);
|
||||||
|
|
||||||
|
return component;
|
||||||
|
},
|
||||||
to: '/settings/webhooks/:id',
|
to: '/settings/webhooks/:id',
|
||||||
exact: true,
|
exact: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Component: WebhooksListView,
|
// Component: WebhooksListView,
|
||||||
|
Component: async () => {
|
||||||
|
const component = await import(
|
||||||
|
/* webpackChunkName: "webhook-list-page" */ '../../Webhooks/ProtectedListView'
|
||||||
|
);
|
||||||
|
|
||||||
|
return component;
|
||||||
|
},
|
||||||
to: '/settings/webhooks',
|
to: '/settings/webhooks',
|
||||||
exact: true,
|
exact: true,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,8 +1,46 @@
|
|||||||
import React from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
import { Route } from 'react-router-dom';
|
import { Route } from 'react-router-dom';
|
||||||
|
import { LoadingIndicatorPage } from '@strapi/helper-plugin';
|
||||||
|
|
||||||
|
const LazyCompo = ({ loadComponent }) => {
|
||||||
|
const [C, setCompo] = useState(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const loadCompo = async () => {
|
||||||
|
try {
|
||||||
|
const loadedCompo = await loadComponent();
|
||||||
|
|
||||||
|
setCompo(() => loadedCompo.default);
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
loadCompo();
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
if (C) {
|
||||||
|
return <C />;
|
||||||
|
}
|
||||||
|
|
||||||
|
return <LoadingIndicatorPage />;
|
||||||
|
};
|
||||||
|
|
||||||
const createRoute = (Component, to, exact) => {
|
const createRoute = (Component, to, exact) => {
|
||||||
return <Route component={Component} key={to} path={to} exact={exact || false} />;
|
return (
|
||||||
|
<Route
|
||||||
|
render={() => <LazyCompo loadComponent={Component} />}
|
||||||
|
key={to}
|
||||||
|
path={to}
|
||||||
|
exact={exact || false}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
LazyCompo.propTypes = {
|
||||||
|
loadComponent: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default createRoute;
|
export default createRoute;
|
||||||
|
|||||||
@ -1,9 +1,12 @@
|
|||||||
import SingleSignOn from '../SingleSignOn';
|
|
||||||
|
|
||||||
const ssoRoutes = strapi.features.isEnabled(strapi.features.SSO)
|
const ssoRoutes = strapi.features.isEnabled(strapi.features.SSO)
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
Component: SingleSignOn,
|
// Component: SingleSignOn,
|
||||||
|
Component: async () => {
|
||||||
|
const component = await import(/* webpackChunkName: "sso" */ '../SingleSignOn');
|
||||||
|
|
||||||
|
return component;
|
||||||
|
},
|
||||||
to: '/settings/single-sign-on',
|
to: '/settings/single-sign-on',
|
||||||
exact: true,
|
exact: true,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -5,14 +5,12 @@
|
|||||||
// Also the strapi-generate-plugins/files/admin/src/index.js needs to be updated
|
// Also the strapi-generate-plugins/files/admin/src/index.js needs to be updated
|
||||||
// IF THE DOC IS NOT UPDATED THE PULL REQUEST WILL NOT BE MERGED
|
// IF THE DOC IS NOT UPDATED THE PULL REQUEST WILL NOT BE MERGED
|
||||||
|
|
||||||
import React from 'react';
|
import { prefixPluginTranslations } from '@strapi/helper-plugin';
|
||||||
import { CheckPagePermissions, prefixPluginTranslations } from '@strapi/helper-plugin';
|
|
||||||
import pluginPkg from '../../package.json';
|
import pluginPkg from '../../package.json';
|
||||||
import pluginId from './pluginId';
|
import pluginId from './pluginId';
|
||||||
import pluginLogo from './assets/images/logo.svg';
|
import pluginLogo from './assets/images/logo.svg';
|
||||||
import pluginPermissions from './permissions';
|
import pluginPermissions from './permissions';
|
||||||
import getTrad from './utils/getTrad';
|
import getTrad from './utils/getTrad';
|
||||||
import SettingsPage from './pages/Settings';
|
|
||||||
|
|
||||||
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
||||||
const icon = pluginPkg.strapi.icon;
|
const icon = pluginPkg.strapi.icon;
|
||||||
@ -34,11 +32,18 @@ export default {
|
|||||||
},
|
},
|
||||||
id: 'settings',
|
id: 'settings',
|
||||||
to: `/settings/${pluginId}`,
|
to: `/settings/${pluginId}`,
|
||||||
Component: () => (
|
Component: async () => {
|
||||||
<CheckPagePermissions permissions={pluginPermissions.settings}>
|
const component = await import(
|
||||||
<SettingsPage />
|
/* webpackChunkName: "email-settings" */ './pages/Settings'
|
||||||
</CheckPagePermissions>
|
);
|
||||||
),
|
|
||||||
|
return component;
|
||||||
|
},
|
||||||
|
// Component: () => (
|
||||||
|
// <CheckPagePermissions permissions={pluginPermissions.settings}>
|
||||||
|
// <SettingsPage />
|
||||||
|
// </CheckPagePermissions>
|
||||||
|
// ),
|
||||||
|
|
||||||
permissions: pluginPermissions.settings,
|
permissions: pluginPermissions.settings,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -20,6 +20,12 @@ import { AlignedButton, Text } from './components';
|
|||||||
import schema from '../../utils/schema';
|
import schema from '../../utils/schema';
|
||||||
import pluginPermissions from '../../permissions';
|
import pluginPermissions from '../../permissions';
|
||||||
|
|
||||||
|
const ProtectedSettingsPage = () => (
|
||||||
|
<CheckPagePermissions permissions={pluginPermissions.settings}>
|
||||||
|
<SettingsPage />
|
||||||
|
</CheckPagePermissions>
|
||||||
|
);
|
||||||
|
|
||||||
const SettingsPage = () => {
|
const SettingsPage = () => {
|
||||||
const toggleNotification = useNotification();
|
const toggleNotification = useNotification();
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
@ -205,4 +211,4 @@ const SettingsPage = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SettingsPage;
|
export default ProtectedSettingsPage;
|
||||||
|
|||||||
@ -4,15 +4,13 @@
|
|||||||
// Here's the file: strapi/docs/3.0.0-beta.x/guides/registering-a-field-in-admin.md
|
// Here's the file: strapi/docs/3.0.0-beta.x/guides/registering-a-field-in-admin.md
|
||||||
// Also the strapi-generate-plugins/files/admin/src/index.js needs to be updated
|
// Also the strapi-generate-plugins/files/admin/src/index.js needs to be updated
|
||||||
// IF THE DOC IS NOT UPDATED THE PULL REQUEST WILL NOT BE MERGED
|
// IF THE DOC IS NOT UPDATED THE PULL REQUEST WILL NOT BE MERGED
|
||||||
import React from 'react';
|
import { prefixPluginTranslations } from '@strapi/helper-plugin';
|
||||||
import { CheckPagePermissions, prefixPluginTranslations } from '@strapi/helper-plugin';
|
|
||||||
import pluginPkg from '../../package.json';
|
import pluginPkg from '../../package.json';
|
||||||
import pluginLogo from './assets/images/logo.svg';
|
import pluginLogo from './assets/images/logo.svg';
|
||||||
import pluginPermissions from './permissions';
|
import pluginPermissions from './permissions';
|
||||||
import Initializer from './components/Initializer';
|
import Initializer from './components/Initializer';
|
||||||
import InputMedia from './components/InputMedia';
|
import InputMedia from './components/InputMedia';
|
||||||
import InputModalStepper from './components/InputModalStepper';
|
import InputModalStepper from './components/InputModalStepper';
|
||||||
import SettingsPage from './pages/SettingsPage';
|
|
||||||
import reducers from './reducers';
|
import reducers from './reducers';
|
||||||
import pluginId from './pluginId';
|
import pluginId from './pluginId';
|
||||||
import { getTrad } from './utils';
|
import { getTrad } from './utils';
|
||||||
@ -61,11 +59,13 @@ export default {
|
|||||||
defaultMessage: 'Media Library',
|
defaultMessage: 'Media Library',
|
||||||
},
|
},
|
||||||
to: '/settings/media-library',
|
to: '/settings/media-library',
|
||||||
Component: () => (
|
Component: async () => {
|
||||||
<CheckPagePermissions permissions={pluginPermissions.settings}>
|
const component = await import(
|
||||||
<SettingsPage />
|
/* webpackChunkName: "upload-settings" */ './pages/SettingsPage'
|
||||||
</CheckPagePermissions>
|
);
|
||||||
),
|
|
||||||
|
return component;
|
||||||
|
},
|
||||||
permissions: pluginPermissions.settings,
|
permissions: pluginPermissions.settings,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@ -4,13 +4,24 @@ import { Helmet } from 'react-helmet';
|
|||||||
import { Text } from '@buffetjs/core';
|
import { Text } from '@buffetjs/core';
|
||||||
import { isEqual } from 'lodash';
|
import { isEqual } from 'lodash';
|
||||||
import { useIntl } from 'react-intl';
|
import { useIntl } from 'react-intl';
|
||||||
import { LoadingIndicatorPage, useNotification, request } from '@strapi/helper-plugin';
|
import {
|
||||||
|
CheckPagePermissions,
|
||||||
|
LoadingIndicatorPage,
|
||||||
|
useNotification,
|
||||||
|
request,
|
||||||
|
} from '@strapi/helper-plugin';
|
||||||
import { getRequestUrl, getTrad } from '../../utils';
|
import { getRequestUrl, getTrad } from '../../utils';
|
||||||
import SectionTitleWrapper from './SectionTitleWrapper';
|
import SectionTitleWrapper from './SectionTitleWrapper';
|
||||||
import Wrapper from './Wrapper';
|
import Wrapper from './Wrapper';
|
||||||
import init from './init';
|
import init from './init';
|
||||||
import reducer, { initialState } from './reducer';
|
import reducer, { initialState } from './reducer';
|
||||||
|
import pluginPermissions from '../../permissions';
|
||||||
|
|
||||||
|
const ProtectedSettingsPage = () => (
|
||||||
|
<CheckPagePermissions permissions={pluginPermissions.settings}>
|
||||||
|
<SettingsPage />
|
||||||
|
</CheckPagePermissions>
|
||||||
|
);
|
||||||
|
|
||||||
const SettingsPage = () => {
|
const SettingsPage = () => {
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
@ -202,4 +213,4 @@ const SettingsPage = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SettingsPage;
|
export default ProtectedSettingsPage;
|
||||||
|
|||||||
@ -9,7 +9,6 @@ import pluginPkg from '../../package.json';
|
|||||||
import pluginPermissions from './permissions';
|
import pluginPermissions from './permissions';
|
||||||
import pluginId from './pluginId';
|
import pluginId from './pluginId';
|
||||||
import pluginLogo from './assets/images/logo.svg';
|
import pluginLogo from './assets/images/logo.svg';
|
||||||
import App from './pages/App';
|
|
||||||
|
|
||||||
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
||||||
const icon = pluginPkg.strapi.icon;
|
const icon = pluginPkg.strapi.icon;
|
||||||
@ -25,7 +24,11 @@ export default {
|
|||||||
defaultMessage: 'Documentation',
|
defaultMessage: 'Documentation',
|
||||||
},
|
},
|
||||||
permissions: pluginPermissions.main,
|
permissions: pluginPermissions.main,
|
||||||
Component: App,
|
Component: async () => {
|
||||||
|
const component = await import(/* webpackChunkName: "documentation" */ './pages/App');
|
||||||
|
|
||||||
|
return component;
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
app.registerPlugin({
|
app.registerPlugin({
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import pluginLogo from './assets/images/logo.svg';
|
|||||||
import CheckboxConfirmation from './components/CheckboxConfirmation';
|
import CheckboxConfirmation from './components/CheckboxConfirmation';
|
||||||
import CMEditViewInjectedComponents from './components/CMEditViewInjectedComponents';
|
import CMEditViewInjectedComponents from './components/CMEditViewInjectedComponents';
|
||||||
import Initializer from './components/Initializer';
|
import Initializer from './components/Initializer';
|
||||||
import SettingsPage from './pages/SettingsPage';
|
|
||||||
import LocalePicker from './components/LocalePicker';
|
import LocalePicker from './components/LocalePicker';
|
||||||
import middlewares from './middlewares';
|
import middlewares from './middlewares';
|
||||||
import pluginPermissions from './permissions';
|
import pluginPermissions from './permissions';
|
||||||
@ -64,7 +63,14 @@ export default {
|
|||||||
},
|
},
|
||||||
id: 'internationalization',
|
id: 'internationalization',
|
||||||
to: '/settings/internationalization',
|
to: '/settings/internationalization',
|
||||||
Component: SettingsPage,
|
|
||||||
|
Component: async () => {
|
||||||
|
const component = await import(
|
||||||
|
/* webpackChunkName: "i18n-settings" */ './pages/SettingsPage'
|
||||||
|
);
|
||||||
|
|
||||||
|
return component;
|
||||||
|
},
|
||||||
permissions: pluginPermissions.accessMain,
|
permissions: pluginPermissions.accessMain,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -4,16 +4,11 @@
|
|||||||
// Here's the file: strapi/docs/3.0.0-beta.x/guides/registering-a-field-in-admin.md
|
// Here's the file: strapi/docs/3.0.0-beta.x/guides/registering-a-field-in-admin.md
|
||||||
// Also the strapi-generate-plugins/files/admin/src/index.js needs to be updated
|
// Also the strapi-generate-plugins/files/admin/src/index.js needs to be updated
|
||||||
// IF THE DOC IS NOT UPDATED THE PULL REQUEST WILL NOT BE MERGED
|
// IF THE DOC IS NOT UPDATED THE PULL REQUEST WILL NOT BE MERGED
|
||||||
import React from 'react';
|
import { prefixPluginTranslations } from '@strapi/helper-plugin';
|
||||||
import { CheckPagePermissions, prefixPluginTranslations } from '@strapi/helper-plugin';
|
|
||||||
import pluginPkg from '../../package.json';
|
import pluginPkg from '../../package.json';
|
||||||
import pluginLogo from './assets/images/logo.svg';
|
import pluginLogo from './assets/images/logo.svg';
|
||||||
import pluginPermissions from './permissions';
|
import pluginPermissions from './permissions';
|
||||||
import pluginId from './pluginId';
|
import pluginId from './pluginId';
|
||||||
import RolesPage from './pages/Roles';
|
|
||||||
import ProvidersPage from './pages/Providers';
|
|
||||||
import EmailTemplatesPage from './pages/EmailTemplates';
|
|
||||||
import AdvancedSettingsPage from './pages/AdvancedSettings';
|
|
||||||
import getTrad from './utils/getTrad';
|
import getTrad from './utils/getTrad';
|
||||||
|
|
||||||
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
||||||
@ -39,11 +34,11 @@ export default {
|
|||||||
},
|
},
|
||||||
id: 'roles',
|
id: 'roles',
|
||||||
to: `/settings/${pluginId}/roles`,
|
to: `/settings/${pluginId}/roles`,
|
||||||
Component: () => (
|
Component: async () => {
|
||||||
<CheckPagePermissions permissions={pluginPermissions.accessRoles}>
|
const component = await import(/* webpackChunkName: "users-roles" */ './pages/Roles');
|
||||||
<RolesPage />
|
|
||||||
</CheckPagePermissions>
|
return component;
|
||||||
),
|
},
|
||||||
permissions: pluginPermissions.accessRoles,
|
permissions: pluginPermissions.accessRoles,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -53,11 +48,13 @@ export default {
|
|||||||
},
|
},
|
||||||
id: 'providers',
|
id: 'providers',
|
||||||
to: `/settings/${pluginId}/providers`,
|
to: `/settings/${pluginId}/providers`,
|
||||||
Component: () => (
|
Component: async () => {
|
||||||
<CheckPagePermissions permissions={pluginPermissions.readProviders}>
|
const component = await import(
|
||||||
<ProvidersPage />
|
/* webpackChunkName: "users-providers" */ './pages/Providers'
|
||||||
</CheckPagePermissions>
|
);
|
||||||
),
|
|
||||||
|
return component;
|
||||||
|
},
|
||||||
permissions: pluginPermissions.readProviders,
|
permissions: pluginPermissions.readProviders,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -67,11 +64,13 @@ export default {
|
|||||||
},
|
},
|
||||||
id: 'email-templates',
|
id: 'email-templates',
|
||||||
to: `/settings/${pluginId}/email-templates`,
|
to: `/settings/${pluginId}/email-templates`,
|
||||||
Component: () => (
|
Component: async () => {
|
||||||
<CheckPagePermissions permissions={pluginPermissions.readEmailTemplates}>
|
const component = await import(
|
||||||
<EmailTemplatesPage />
|
/* webpackChunkName: "users-email" */ './pages/EmailTemplates'
|
||||||
</CheckPagePermissions>
|
);
|
||||||
),
|
|
||||||
|
return component;
|
||||||
|
},
|
||||||
permissions: pluginPermissions.readEmailTemplates,
|
permissions: pluginPermissions.readEmailTemplates,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -81,11 +80,13 @@ export default {
|
|||||||
},
|
},
|
||||||
id: 'advanced-settings',
|
id: 'advanced-settings',
|
||||||
to: `/settings/${pluginId}/advanced-settings`,
|
to: `/settings/${pluginId}/advanced-settings`,
|
||||||
Component: () => (
|
Component: async () => {
|
||||||
<CheckPagePermissions permissions={pluginPermissions.readAdvancedSettings}>
|
const component = await import(
|
||||||
<AdvancedSettingsPage />
|
/* webpackChunkName: "users-advanced-settings" */ './pages/AdvancedSettings'
|
||||||
</CheckPagePermissions>
|
);
|
||||||
),
|
|
||||||
|
return component;
|
||||||
|
},
|
||||||
permissions: pluginPermissions.readAdvancedSettings,
|
permissions: pluginPermissions.readAdvancedSettings,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import {
|
|||||||
request,
|
request,
|
||||||
useNotification,
|
useNotification,
|
||||||
useOverlayBlocker,
|
useOverlayBlocker,
|
||||||
|
CheckPagePermissions,
|
||||||
} from '@strapi/helper-plugin';
|
} from '@strapi/helper-plugin';
|
||||||
import pluginPermissions from '../../permissions';
|
import pluginPermissions from '../../permissions';
|
||||||
import { getTrad, getRequestURL } from '../../utils';
|
import { getTrad, getRequestURL } from '../../utils';
|
||||||
@ -18,6 +19,12 @@ import ListBaselineAlignment from '../../components/ListBaselineAlignment';
|
|||||||
import form from './utils/form';
|
import form from './utils/form';
|
||||||
import reducer, { initialState } from './reducer';
|
import reducer, { initialState } from './reducer';
|
||||||
|
|
||||||
|
const Protected = () => (
|
||||||
|
<CheckPagePermissions permissions={pluginPermissions.readAdvancedSettings}>
|
||||||
|
<AdvancedSettingsPage />
|
||||||
|
</CheckPagePermissions>
|
||||||
|
);
|
||||||
|
|
||||||
const AdvancedSettingsPage = () => {
|
const AdvancedSettingsPage = () => {
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
const toggleNotification = useNotification();
|
const toggleNotification = useNotification();
|
||||||
@ -212,4 +219,4 @@ const AdvancedSettingsPage = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default AdvancedSettingsPage;
|
export default Protected;
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import {
|
|||||||
getYupInnerErrors,
|
getYupInnerErrors,
|
||||||
useNotification,
|
useNotification,
|
||||||
useOverlayBlocker,
|
useOverlayBlocker,
|
||||||
|
CheckPagePermissions,
|
||||||
} from '@strapi/helper-plugin';
|
} from '@strapi/helper-plugin';
|
||||||
import { Row } from 'reactstrap';
|
import { Row } from 'reactstrap';
|
||||||
import pluginPermissions from '../../permissions';
|
import pluginPermissions from '../../permissions';
|
||||||
@ -22,6 +23,12 @@ import { getRequestURL, getTrad } from '../../utils';
|
|||||||
import forms from './utils/forms';
|
import forms from './utils/forms';
|
||||||
import schema from './utils/schema';
|
import schema from './utils/schema';
|
||||||
|
|
||||||
|
const Protected = () => (
|
||||||
|
<CheckPagePermissions permissions={pluginPermissions.readEmailTemplates}>
|
||||||
|
<EmailTemplatesPage />
|
||||||
|
</CheckPagePermissions>
|
||||||
|
);
|
||||||
|
|
||||||
const EmailTemplatesPage = () => {
|
const EmailTemplatesPage = () => {
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
const { trackUsage } = useTracking();
|
const { trackUsage } = useTracking();
|
||||||
@ -232,4 +239,4 @@ const EmailTemplatesPage = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default EmailTemplatesPage;
|
export default Protected;
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import {
|
|||||||
request,
|
request,
|
||||||
useNotification,
|
useNotification,
|
||||||
useOverlayBlocker,
|
useOverlayBlocker,
|
||||||
|
CheckPagePermissions,
|
||||||
} from '@strapi/helper-plugin';
|
} from '@strapi/helper-plugin';
|
||||||
import { get, upperFirst, has } from 'lodash';
|
import { get, upperFirst, has } from 'lodash';
|
||||||
import { Row } from 'reactstrap';
|
import { Row } from 'reactstrap';
|
||||||
@ -23,6 +24,12 @@ import ModalForm from '../../components/ModalForm';
|
|||||||
import createProvidersArray from './utils/createProvidersArray';
|
import createProvidersArray from './utils/createProvidersArray';
|
||||||
import forms from './utils/forms';
|
import forms from './utils/forms';
|
||||||
|
|
||||||
|
const ProtectedProvidersPage = () => (
|
||||||
|
<CheckPagePermissions permissions={pluginPermissions.readProviders}>
|
||||||
|
<ProvidersPage />
|
||||||
|
</CheckPagePermissions>
|
||||||
|
);
|
||||||
|
|
||||||
const ProvidersPage = () => {
|
const ProvidersPage = () => {
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
const { trackUsage } = useTracking();
|
const { trackUsage } = useTracking();
|
||||||
@ -279,4 +286,4 @@ const ProvidersPage = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ProvidersPage;
|
export default ProtectedProvidersPage;
|
||||||
|
|||||||
@ -1,20 +1,26 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Switch, Route } from 'react-router-dom';
|
import { Switch, Route } from 'react-router-dom';
|
||||||
import { NotFound } from '@strapi/helper-plugin';
|
import { CheckPagePermissions, NotFound } from '@strapi/helper-plugin';
|
||||||
import pluginId from '../../pluginId';
|
import pluginId from '../../pluginId';
|
||||||
|
import pluginPermissions from '../../permissions';
|
||||||
import ProtectedRolesListPage from './ProtectedListPage';
|
import ProtectedRolesListPage from './ProtectedListPage';
|
||||||
import ProtectedRolesEditPage from './ProtectedEditPage';
|
import ProtectedRolesEditPage from './ProtectedEditPage';
|
||||||
import ProtectedRolesCreatePage from './ProtectedCreatePage';
|
import ProtectedRolesCreatePage from './ProtectedCreatePage';
|
||||||
|
|
||||||
const Roles = () => {
|
const Roles = () => {
|
||||||
return (
|
return (
|
||||||
<Switch>
|
<CheckPagePermissions permissions={pluginPermissions.accessRoles}>
|
||||||
<Route path={`/settings/${pluginId}/roles/new`} component={ProtectedRolesCreatePage} exact />
|
<Switch>
|
||||||
<Route path={`/settings/${pluginId}/roles/:id`} component={ProtectedRolesEditPage} exact />
|
<Route
|
||||||
<Route path={`/settings/${pluginId}/roles`} component={ProtectedRolesListPage} exact />
|
path={`/settings/${pluginId}/roles/new`}
|
||||||
<Route path="" component={NotFound} />
|
component={ProtectedRolesCreatePage}
|
||||||
</Switch>
|
exact
|
||||||
|
/>
|
||||||
|
<Route path={`/settings/${pluginId}/roles/:id`} component={ProtectedRolesEditPage} exact />
|
||||||
|
<Route path={`/settings/${pluginId}/roles`} component={ProtectedRolesListPage} exact />
|
||||||
|
<Route path="" component={NotFound} />
|
||||||
|
</Switch>
|
||||||
|
</CheckPagePermissions>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user