mirror of
https://github.com/strapi/strapi.git
synced 2025-09-26 00:39:49 +00:00
Merge pull request #10661 from strapi/improve-bundle
Proposal load plugins when needed
This commit is contained in:
commit
87c93b19d6
@ -1,9 +1,6 @@
|
|||||||
import { prefixPluginTranslations } from '@strapi/helper-plugin';
|
import { prefixPluginTranslations } from '@strapi/helper-plugin';
|
||||||
import pluginPkg from '../../package.json';
|
import pluginPkg from '../../package.json';
|
||||||
import pluginId from './pluginId';
|
import pluginId from './pluginId';
|
||||||
|
|
||||||
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;
|
||||||
const name = pluginPkg.strapi.name;
|
const name = pluginPkg.strapi.name;
|
||||||
@ -17,7 +14,11 @@ export default {
|
|||||||
id: `${pluginId}.plugin.name`,
|
id: `${pluginId}.plugin.name`,
|
||||||
defaultMessage: 'My plugin',
|
defaultMessage: 'My plugin',
|
||||||
},
|
},
|
||||||
Component: App,
|
Component: async () => {
|
||||||
|
const component = await import(/* webpackChunkName: "my-plugin" */ './pages/App');
|
||||||
|
|
||||||
|
return component;
|
||||||
|
},
|
||||||
permissions: [],
|
permissions: [],
|
||||||
});
|
});
|
||||||
app.registerPlugin({
|
app.registerPlugin({
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
import 'sanitize.css/sanitize.css';
|
|
||||||
import 'bootstrap/dist/css/bootstrap.css';
|
|
||||||
import 'font-awesome/css/font-awesome.min.css';
|
|
||||||
import '@fortawesome/fontawesome-free/css/all.css';
|
|
||||||
// eslint-disable-next-line import/extensions
|
|
||||||
import '@fortawesome/fontawesome-free/js/all.min.js';
|
|
||||||
import { createGlobalStyle } from 'styled-components';
|
import { createGlobalStyle } from 'styled-components';
|
||||||
|
|
||||||
|
const loadCss = async () => {
|
||||||
|
await import(/* webpackChunkName: "sanitize-css" */ 'sanitize.css/sanitize.css');
|
||||||
|
await import(/* webpackChunkName: "fontawesome-css" */ 'font-awesome/css/font-awesome.min.css');
|
||||||
|
await import(
|
||||||
|
/* webpackChunkName: "fontawesome-css-all" */ '@fortawesome/fontawesome-free/css/all.css'
|
||||||
|
);
|
||||||
|
await import(/* webpackChunkName: "fontawesome-js" */ '@fortawesome/fontawesome-free/js/all.min');
|
||||||
|
await import(/* webpackChunkName: "bootstrap" */ 'bootstrap/dist/css/bootstrap.css');
|
||||||
|
};
|
||||||
|
|
||||||
|
loadCss();
|
||||||
|
|
||||||
const GlobalStyle = createGlobalStyle`
|
const GlobalStyle = createGlobalStyle`
|
||||||
html {
|
html {
|
||||||
font-size: 62.5%;
|
font-size: 62.5%;
|
||||||
|
@ -7,13 +7,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import cm from 'codemirror';
|
import cm from 'codemirror';
|
||||||
import 'codemirror/mode/javascript/javascript';
|
|
||||||
import 'codemirror/addon/lint/lint';
|
|
||||||
import 'codemirror/addon/lint/javascript-lint';
|
|
||||||
import 'codemirror/addon/edit/closebrackets';
|
|
||||||
import 'codemirror/addon/selection/mark-selection';
|
|
||||||
import 'codemirror/lib/codemirror.css';
|
|
||||||
import 'codemirror/theme/solarized.css';
|
|
||||||
|
|
||||||
import { trimStart } from 'lodash';
|
import { trimStart } from 'lodash';
|
||||||
import jsonlint from './jsonlint';
|
import jsonlint from './jsonlint';
|
||||||
@ -23,6 +16,26 @@ const WAIT = 600;
|
|||||||
const stringify = JSON.stringify;
|
const stringify = JSON.stringify;
|
||||||
const DEFAULT_THEME = 'solarized dark';
|
const DEFAULT_THEME = 'solarized dark';
|
||||||
|
|
||||||
|
const loadCss = async () => {
|
||||||
|
await import(
|
||||||
|
/* webpackChunkName: "codemirror-javacript" */ 'codemirror/mode/javascript/javascript'
|
||||||
|
);
|
||||||
|
await import(/* webpackChunkName: "codemirror-addon-lint" */ 'codemirror/addon/lint/lint');
|
||||||
|
await import(
|
||||||
|
/* webpackChunkName: "codemirror-addon-lint-js" */ 'codemirror/addon/lint/javascript-lint'
|
||||||
|
);
|
||||||
|
await import(
|
||||||
|
/* webpackChunkName: "codemirror-addon-closebrackets" */ 'codemirror/addon/edit/closebrackets'
|
||||||
|
);
|
||||||
|
await import(
|
||||||
|
/* webpackChunkName: "codemirror-addon-mark-selection" */ 'codemirror/addon/selection/mark-selection'
|
||||||
|
);
|
||||||
|
await import(/* webpackChunkName: "codemirror-css" */ 'codemirror/lib/codemirror.css');
|
||||||
|
await import(/* webpackChunkName: "codemirror-theme" */ 'codemirror/theme/solarized.css');
|
||||||
|
};
|
||||||
|
|
||||||
|
loadCss();
|
||||||
|
|
||||||
class InputJSON extends React.Component {
|
class InputJSON extends React.Component {
|
||||||
timer = null;
|
timer = null;
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
/* eslint-disable prefer-template */
|
/* eslint-disable prefer-template */
|
||||||
import Markdown from 'markdown-it';
|
import Markdown from 'markdown-it';
|
||||||
import 'highlight.js/styles/solarized-dark.css';
|
|
||||||
import { getLanguage, highlightAuto, highlight } from 'highlight.js';
|
import { getLanguage, highlightAuto, highlight } from 'highlight.js';
|
||||||
import abbr from 'markdown-it-abbr';
|
import abbr from 'markdown-it-abbr';
|
||||||
import container from 'markdown-it-container';
|
import container from 'markdown-it-container';
|
||||||
@ -12,6 +11,12 @@ import mark from 'markdown-it-mark';
|
|||||||
import sub from 'markdown-it-sub';
|
import sub from 'markdown-it-sub';
|
||||||
import sup from 'markdown-it-sup';
|
import sup from 'markdown-it-sup';
|
||||||
|
|
||||||
|
const loadCss = async () => {
|
||||||
|
await import(/* webpackChunkName: "highlight.js" */ 'highlight.js/styles/solarized-dark.css');
|
||||||
|
};
|
||||||
|
|
||||||
|
loadCss();
|
||||||
|
|
||||||
const md = new Markdown({
|
const md = new Markdown({
|
||||||
html: true, // Enable HTML tags in source
|
html: true, // Enable HTML tags in source
|
||||||
xhtmlOut: false,
|
xhtmlOut: false,
|
||||||
|
@ -59,7 +59,7 @@ describe('<Admin />', () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
to: '/plugins/documentation',
|
to: '/plugins/documentation',
|
||||||
Component: () => <div>DOCUMENTATION PLUGIN</div>,
|
Component: () => ({ default: () => <div>DOCUMENTATION PLUGIN</div> }),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}));
|
}));
|
||||||
|
@ -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]);
|
||||||
|
@ -2,7 +2,7 @@ import React from 'react';
|
|||||||
import { Router, Route } from 'react-router-dom';
|
import { Router, Route } from 'react-router-dom';
|
||||||
import { ThemeProvider } from 'styled-components';
|
import { ThemeProvider } from 'styled-components';
|
||||||
import { StrapiAppProvider, AppInfosContext } from '@strapi/helper-plugin';
|
import { StrapiAppProvider, AppInfosContext } from '@strapi/helper-plugin';
|
||||||
import { render, screen } from '@testing-library/react';
|
import { render, screen, waitFor } from '@testing-library/react';
|
||||||
import userEvent from '@testing-library/user-event';
|
import userEvent from '@testing-library/user-event';
|
||||||
import { createMemoryHistory } from 'history';
|
import { createMemoryHistory } from 'history';
|
||||||
import { SettingsPage } from '..';
|
import { SettingsPage } from '..';
|
||||||
@ -248,7 +248,7 @@ describe('ADMIN | pages | SettingsPage', () => {
|
|||||||
expect(screen.getByText(/App infos/)).toBeInTheDocument();
|
expect(screen.getByText(/App infos/)).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create the plugins routes correctly', () => {
|
it('should create the plugins routes correctly', async () => {
|
||||||
useSettingsMenu.mockImplementation(() => ({
|
useSettingsMenu.mockImplementation(() => ({
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
menu: [
|
menu: [
|
||||||
@ -265,7 +265,7 @@ describe('ADMIN | pages | SettingsPage', () => {
|
|||||||
isDisplayed: true,
|
isDisplayed: true,
|
||||||
permissions: [],
|
permissions: [],
|
||||||
to: '/settings/internationalization',
|
to: '/settings/internationalization',
|
||||||
Component: () => <div>i18n settings</div>,
|
Component: () => ({ default: () => <div>i18n settings</div> }),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@ -279,7 +279,7 @@ describe('ADMIN | pages | SettingsPage', () => {
|
|||||||
isDisplayed: true,
|
isDisplayed: true,
|
||||||
permissions: [],
|
permissions: [],
|
||||||
to: '/settings/email-settings',
|
to: '/settings/email-settings',
|
||||||
Component: () => <div>email settings</div>,
|
Component: () => ({ default: () => <div>email settings</div> }),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@ -301,7 +301,7 @@ describe('ADMIN | pages | SettingsPage', () => {
|
|||||||
isDisplayed: true,
|
isDisplayed: true,
|
||||||
permissions: [],
|
permissions: [],
|
||||||
to: '/settings/internationalization',
|
to: '/settings/internationalization',
|
||||||
Component: () => <div>i18n settings</div>,
|
Component: () => ({ default: () => <div>i18n settings</div> }),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@ -315,7 +315,7 @@ describe('ADMIN | pages | SettingsPage', () => {
|
|||||||
isDisplayed: true,
|
isDisplayed: true,
|
||||||
permissions: [],
|
permissions: [],
|
||||||
to: '/settings/email-settings',
|
to: '/settings/email-settings',
|
||||||
Component: () => <div>email settings</div>,
|
Component: () => ({ default: () => <div>email settings</div> }),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@ -329,10 +329,14 @@ describe('ADMIN | pages | SettingsPage', () => {
|
|||||||
|
|
||||||
userEvent.click(screen.getByText('i18n.plugin.name'));
|
userEvent.click(screen.getByText('i18n.plugin.name'));
|
||||||
|
|
||||||
expect(screen.getByText(/i18n settings/)).toBeInTheDocument();
|
await waitFor(() => {
|
||||||
|
expect(screen.getByText(/i18n settings/)).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
userEvent.click(screen.getByText('email'));
|
userEvent.click(screen.getByText('email'));
|
||||||
|
|
||||||
expect(screen.getByText(/email settings/)).toBeInTheDocument();
|
await waitFor(() => {
|
||||||
|
expect(screen.getByText(/email settings/)).toBeInTheDocument();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,55 +1,92 @@
|
|||||||
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: () => {
|
||||||
|
return { default: RolesCreatePage };
|
||||||
|
},
|
||||||
to: '/settings/roles/new',
|
to: '/settings/roles/new',
|
||||||
exact: true,
|
exact: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
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: 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: 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: 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: 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: 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,45 @@
|
|||||||
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 [Compo, setCompo] = useState(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const loadCompo = async () => {
|
||||||
|
try {
|
||||||
|
const loadedCompo = await loadComponent();
|
||||||
|
|
||||||
|
setCompo(() => loadedCompo.default);
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
loadCompo();
|
||||||
|
}, [loadComponent]);
|
||||||
|
|
||||||
|
if (Compo) {
|
||||||
|
return <Compo />;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
@ -5,12 +5,11 @@ describe('ADMIN | CONTAINER | SettingsPage | utils | createRoute', () => {
|
|||||||
const compo = () => 'test';
|
const compo = () => 'test';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
props: { component, path, exact },
|
props: { path, exact },
|
||||||
key,
|
key,
|
||||||
} = createRoute(compo, '/test', true);
|
} = createRoute(compo, '/test', true);
|
||||||
|
|
||||||
expect(key).toEqual('/test');
|
expect(key).toEqual('/test');
|
||||||
expect(component()).toEqual('test');
|
|
||||||
expect(exact).toBeTruthy();
|
expect(exact).toBeTruthy();
|
||||||
expect(path).toEqual('/test');
|
expect(path).toEqual('/test');
|
||||||
});
|
});
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
import SingleSignOn from '../SingleSignOn';
|
|
||||||
|
|
||||||
const ssoRoutes = strapi.features.isEnabled(strapi.features.SSO)
|
const ssoRoutes = strapi.features.isEnabled(strapi.features.SSO)
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
Component: SingleSignOn,
|
Component: async () => {
|
||||||
|
const component = await import(
|
||||||
|
/* webpackChunkName: "sso-settings-page" */ '../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,12 +32,13 @@ 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-page" */ './pages/Settings'
|
||||||
</CheckPagePermissions>
|
);
|
||||||
),
|
|
||||||
|
|
||||||
|
return component;
|
||||||
|
},
|
||||||
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;
|
||||||
|
@ -86,8 +86,6 @@ const createCoreStore = ({ environment: defaultEnv, db }) => {
|
|||||||
type: (typeof value).toString(),
|
type: (typeof value).toString(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
await db.query('strapi::core-store').update({ where: { id: data.id }, data });
|
await db.query('strapi::core-store').update({ where: { id: data.id }, data });
|
||||||
} else {
|
} else {
|
||||||
const data = Object.assign({}, where, {
|
const data = Object.assign({}, where, {
|
||||||
|
@ -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;
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
import { prefixPluginTranslations } from '@strapi/helper-plugin';
|
import { prefixPluginTranslations } from '@strapi/helper-plugin';
|
||||||
import pluginPkg from '../../package.json';
|
import pluginPkg from '../../package.json';
|
||||||
import pluginId from './pluginId';
|
import pluginId from './pluginId';
|
||||||
import App from './containers/App';
|
import Initializer from './components/Initializer';
|
||||||
import Initializer from './containers/Initializer';
|
|
||||||
|
|
||||||
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
||||||
const icon = pluginPkg.strapi.icon;
|
const icon = pluginPkg.strapi.icon;
|
||||||
const name = pluginPkg.strapi.name;
|
const name = pluginPkg.strapi.name;
|
||||||
@ -17,7 +15,11 @@ export default {
|
|||||||
id: `${pluginId}.plugin.name`,
|
id: `${pluginId}.plugin.name`,
|
||||||
defaultMessage: name,
|
defaultMessage: name,
|
||||||
},
|
},
|
||||||
Component: App,
|
Component: async () => {
|
||||||
|
const component = await import(/* webpackChunkName: "[request]" */ './pages/App');
|
||||||
|
|
||||||
|
return component;
|
||||||
|
},
|
||||||
permissions: [
|
permissions: [
|
||||||
// Uncomment to set the permissions of the plugin here
|
// Uncomment to set the permissions of the plugin here
|
||||||
// {
|
// {
|
||||||
|
@ -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-page" */ './pages/App');
|
||||||
|
|
||||||
|
return component;
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
app.registerPlugin({
|
app.registerPlugin({
|
||||||
|
@ -90,10 +90,17 @@ const HomePage = () => {
|
|||||||
setVersionToDelete(null);
|
setVersionToDelete(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return <LoadingIndicatorPage />;
|
return <LoadingIndicatorPage />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME
|
||||||
|
if (!data) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ContainerFluid className="container-fluid">
|
<ContainerFluid className="container-fluid">
|
||||||
<PopUpWarning
|
<PopUpWarning
|
||||||
|
@ -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-page" */ './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,13 @@ 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(
|
||||||
<RolesPage />
|
/* webpackChunkName: "users-roles-settings-page" */ './pages/Roles'
|
||||||
</CheckPagePermissions>
|
);
|
||||||
),
|
|
||||||
|
return component;
|
||||||
|
},
|
||||||
permissions: pluginPermissions.accessRoles,
|
permissions: pluginPermissions.accessRoles,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -53,11 +50,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-settings-page" */ './pages/Providers'
|
||||||
</CheckPagePermissions>
|
);
|
||||||
),
|
|
||||||
|
return component;
|
||||||
|
},
|
||||||
permissions: pluginPermissions.readProviders,
|
permissions: pluginPermissions.readProviders,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -67,11 +66,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-settings-page" */ './pages/EmailTemplates'
|
||||||
</CheckPagePermissions>
|
);
|
||||||
),
|
|
||||||
|
return component;
|
||||||
|
},
|
||||||
permissions: pluginPermissions.readEmailTemplates,
|
permissions: pluginPermissions.readEmailTemplates,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -81,11 +82,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-page" */ './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 ProtectedAdvancedSettingsPage = () => (
|
||||||
|
<CheckPagePermissions permissions={pluginPermissions.readAdvancedSettings}>
|
||||||
|
<AdvancedSettingsPage />
|
||||||
|
</CheckPagePermissions>
|
||||||
|
);
|
||||||
|
|
||||||
const AdvancedSettingsPage = () => {
|
const AdvancedSettingsPage = () => {
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
const toggleNotification = useNotification();
|
const toggleNotification = useNotification();
|
||||||
@ -217,4 +224,4 @@ const AdvancedSettingsPage = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default AdvancedSettingsPage;
|
export default ProtectedAdvancedSettingsPage;
|
||||||
|
@ -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 ProtectedEmailTemplatesPage = () => (
|
||||||
|
<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 ProtectedEmailTemplatesPage;
|
||||||
|
@ -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