mirror of
https://github.com/strapi/strapi.git
synced 2025-07-31 04:45:54 +00:00
Change the way we load plugins
Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
parent
1106c07795
commit
96e092b300
@ -57,16 +57,20 @@ const { dispatch } = store;
|
|||||||
const MOUNT_NODE =
|
const MOUNT_NODE =
|
||||||
document.getElementById('app') || document.createElement('div');
|
document.getElementById('app') || document.createElement('div');
|
||||||
|
|
||||||
Object.keys(plugins).forEach(plugin => {
|
Object.keys(plugins).forEach(current => {
|
||||||
const currentPlugin = plugins[plugin];
|
const registerPlugin = plugin => {
|
||||||
|
return plugin;
|
||||||
|
};
|
||||||
|
const currentPluginFn = plugins[current];
|
||||||
|
const plugin = currentPluginFn({ registerPlugin });
|
||||||
|
|
||||||
const pluginTradsPrefixed = languages.reduce((acc, lang) => {
|
const pluginTradsPrefixed = languages.reduce((acc, lang) => {
|
||||||
const currentLocale = currentPlugin.trads[lang];
|
const currentLocale = plugin.trads[lang];
|
||||||
|
|
||||||
if (currentLocale) {
|
if (currentLocale) {
|
||||||
const localeprefixedWithPluginId = Object.keys(currentLocale).reduce(
|
const localeprefixedWithPluginId = Object.keys(currentLocale).reduce(
|
||||||
(acc2, current) => {
|
(acc2, current) => {
|
||||||
acc2[`${plugins[plugin].id}.${current}`] = currentLocale[current];
|
acc2[`${plugin.id}.${current}`] = currentLocale[current];
|
||||||
|
|
||||||
return acc2;
|
return acc2;
|
||||||
},
|
},
|
||||||
@ -81,7 +85,7 @@ Object.keys(plugins).forEach(plugin => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
merge(translationMessages, pluginTradsPrefixed);
|
merge(translationMessages, pluginTradsPrefixed);
|
||||||
dispatch(pluginLoaded(currentPlugin));
|
dispatch(pluginLoaded(plugin));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log({ err });
|
console.log({ err });
|
||||||
}
|
}
|
||||||
|
@ -92,8 +92,9 @@ describe('<Admin />', () => {
|
|||||||
it('should render the routes', () => {
|
it('should render the routes', () => {
|
||||||
const renderedComponent = shallow(<Admin {...props} />);
|
const renderedComponent = shallow(<Admin {...props} />);
|
||||||
const { renderRoute } = renderedComponent.instance();
|
const { renderRoute } = renderedComponent.instance();
|
||||||
|
const Compo = () => <div>compo</div>;
|
||||||
|
|
||||||
expect(renderRoute()).not.toBeNull();
|
expect(renderRoute({}, Compo)).not.toBeNull();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import React from 'react';
|
|
||||||
|
|
||||||
import pluginPkg from '../../package.json';
|
import pluginPkg from '../../package.json';
|
||||||
import pluginId from './pluginId';
|
import pluginId from './pluginId';
|
||||||
import App from './containers/Main';
|
import App from './containers/Main';
|
||||||
@ -7,31 +5,29 @@ import Initializer from './containers/Initializer';
|
|||||||
import lifecycles from './lifecycles';
|
import lifecycles from './lifecycles';
|
||||||
import trads from './translations';
|
import trads from './translations';
|
||||||
|
|
||||||
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
export default strapi => {
|
||||||
|
const pluginDescription =
|
||||||
|
pluginPkg.strapi.description || pluginPkg.description;
|
||||||
|
const plugin = {
|
||||||
|
blockerComponent: null,
|
||||||
|
blockerComponentProps: {},
|
||||||
|
description: pluginDescription,
|
||||||
|
icon: pluginPkg.strapi.icon,
|
||||||
|
id: pluginId,
|
||||||
|
initializer: Initializer,
|
||||||
|
injectedComponents: [],
|
||||||
|
isReady: false,
|
||||||
|
layout: null,
|
||||||
|
lifecycles,
|
||||||
|
leftMenuLinks: [],
|
||||||
|
leftMenuSections: [],
|
||||||
|
mainComponent: App,
|
||||||
|
name: pluginPkg.strapi.name,
|
||||||
|
preventComponentRendering: false,
|
||||||
|
suffixUrl: () => '/ctm-configurations/models',
|
||||||
|
suffixUrlToReplaceForLeftMenuHighlight: '/models',
|
||||||
|
trads,
|
||||||
|
};
|
||||||
|
|
||||||
function Comp(props) {
|
return strapi.registerPlugin(plugin);
|
||||||
return <App {...props} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
const plugin = {
|
|
||||||
blockerComponent: null,
|
|
||||||
blockerComponentProps: {},
|
|
||||||
description: pluginDescription,
|
|
||||||
icon: pluginPkg.strapi.icon,
|
|
||||||
id: pluginId,
|
|
||||||
initializer: Initializer,
|
|
||||||
injectedComponents: [],
|
|
||||||
isReady: false,
|
|
||||||
layout: null,
|
|
||||||
lifecycles,
|
|
||||||
leftMenuLinks: [],
|
|
||||||
leftMenuSections: [],
|
|
||||||
mainComponent: Comp,
|
|
||||||
name: pluginPkg.strapi.name,
|
|
||||||
preventComponentRendering: false,
|
|
||||||
suffixUrl: () => '/ctm-configurations/models',
|
|
||||||
suffixUrlToReplaceForLeftMenuHighlight: '/models',
|
|
||||||
trads,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default plugin;
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import React from 'react';
|
|
||||||
import pluginPkg from '../../package.json';
|
import pluginPkg from '../../package.json';
|
||||||
import App from './containers/App';
|
import App from './containers/App';
|
||||||
import Initializer from './containers/Initializer';
|
import Initializer from './containers/Initializer';
|
||||||
@ -8,47 +7,45 @@ import lifecycles from './lifecycles';
|
|||||||
import trads from './translations';
|
import trads from './translations';
|
||||||
import pluginId from './pluginId';
|
import pluginId from './pluginId';
|
||||||
|
|
||||||
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
export default strapi => {
|
||||||
|
const pluginDescription =
|
||||||
function Comp(props) {
|
pluginPkg.strapi.description || pluginPkg.description;
|
||||||
return <App {...props} />;
|
const plugin = {
|
||||||
}
|
blockerComponent: null,
|
||||||
|
blockerComponentProps: {},
|
||||||
const plugin = {
|
description: pluginDescription,
|
||||||
blockerComponent: null,
|
icon: pluginPkg.strapi.icon,
|
||||||
blockerComponentProps: {},
|
id: pluginId,
|
||||||
description: pluginDescription,
|
initializer: Initializer,
|
||||||
icon: pluginPkg.strapi.icon,
|
injectedComponents: [
|
||||||
id: pluginId,
|
{
|
||||||
initializer: Initializer,
|
plugin: 'content-manager.editView',
|
||||||
injectedComponents: [
|
area: 'right.links',
|
||||||
{
|
component: Link,
|
||||||
plugin: 'content-manager.editView',
|
key: 'content-type-builder.link',
|
||||||
area: 'right.links',
|
props: {
|
||||||
component: Link,
|
message: {
|
||||||
key: 'content-type-builder.link',
|
id: 'content-manager.containers.Edit.Link.Fields',
|
||||||
props: {
|
},
|
||||||
message: {
|
icon: 'fa-cog',
|
||||||
id: 'content-manager.containers.Edit.Link.Fields',
|
|
||||||
},
|
},
|
||||||
icon: 'fa-cog',
|
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
{
|
plugin: 'content-manager.editSettingsView',
|
||||||
plugin: 'content-manager.editSettingsView',
|
area: 'left.links',
|
||||||
area: 'left.links',
|
component: Button,
|
||||||
component: Button,
|
key: 'content-type-builder.form',
|
||||||
key: 'content-type-builder.form',
|
},
|
||||||
},
|
],
|
||||||
],
|
layout: null,
|
||||||
layout: null,
|
lifecycles,
|
||||||
lifecycles,
|
leftMenuLinks: [],
|
||||||
leftMenuLinks: [],
|
leftMenuSections: [],
|
||||||
leftMenuSections: [],
|
mainComponent: App,
|
||||||
mainComponent: Comp,
|
name: pluginPkg.strapi.name,
|
||||||
name: pluginPkg.strapi.name,
|
preventComponentRendering: false,
|
||||||
preventComponentRendering: false,
|
trads,
|
||||||
trads,
|
};
|
||||||
};
|
|
||||||
|
|
||||||
export default plugin;
|
return strapi.registerPlugin(plugin);
|
||||||
|
};
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import React from 'react';
|
|
||||||
import pluginPkg from '../../package.json';
|
import pluginPkg from '../../package.json';
|
||||||
import pluginId from './pluginId';
|
import pluginId from './pluginId';
|
||||||
import App from './containers/App';
|
import App from './containers/App';
|
||||||
@ -6,29 +5,27 @@ import Initializer from './containers/Initializer';
|
|||||||
import lifecycles from './lifecycles';
|
import lifecycles from './lifecycles';
|
||||||
import trads from './translations';
|
import trads from './translations';
|
||||||
|
|
||||||
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
export default strapi => {
|
||||||
|
const pluginDescription =
|
||||||
|
pluginPkg.strapi.description || pluginPkg.description;
|
||||||
|
const plugin = {
|
||||||
|
blockerComponent: null,
|
||||||
|
blockerComponentProps: {},
|
||||||
|
description: pluginDescription,
|
||||||
|
icon: pluginPkg.strapi.icon,
|
||||||
|
id: pluginId,
|
||||||
|
initializer: Initializer,
|
||||||
|
injectedComponents: [],
|
||||||
|
isReady: false,
|
||||||
|
layout: null,
|
||||||
|
lifecycles,
|
||||||
|
leftMenuLinks: [],
|
||||||
|
leftMenuSections: [],
|
||||||
|
mainComponent: App,
|
||||||
|
name: pluginPkg.strapi.name,
|
||||||
|
preventComponentRendering: false,
|
||||||
|
trads,
|
||||||
|
};
|
||||||
|
|
||||||
function Comp(props) {
|
return strapi.registerPlugin(plugin);
|
||||||
return <App {...props} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
const plugin = {
|
|
||||||
blockerComponent: null,
|
|
||||||
blockerComponentProps: {},
|
|
||||||
description: pluginDescription,
|
|
||||||
icon: pluginPkg.strapi.icon,
|
|
||||||
id: pluginId,
|
|
||||||
initializer: Initializer,
|
|
||||||
injectedComponents: [],
|
|
||||||
isReady: false,
|
|
||||||
layout: null,
|
|
||||||
lifecycles,
|
|
||||||
leftMenuLinks: [],
|
|
||||||
leftMenuSections: [],
|
|
||||||
mainComponent: Comp,
|
|
||||||
name: pluginPkg.strapi.name,
|
|
||||||
preventComponentRendering: false,
|
|
||||||
trads,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default plugin;
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import React from 'react';
|
|
||||||
import pluginPkg from '../../package.json';
|
import pluginPkg from '../../package.json';
|
||||||
import pluginId from './pluginId';
|
import pluginId from './pluginId';
|
||||||
import App from './containers/App';
|
import App from './containers/App';
|
||||||
@ -6,28 +5,27 @@ import Initializer from './containers/Initializer';
|
|||||||
import lifecycles from './lifecycles';
|
import lifecycles from './lifecycles';
|
||||||
import trads from './translations';
|
import trads from './translations';
|
||||||
|
|
||||||
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
export default strapi => {
|
||||||
|
const pluginDescription =
|
||||||
|
pluginPkg.strapi.description || pluginPkg.description;
|
||||||
|
|
||||||
function Comp(props) {
|
const plugin = {
|
||||||
return <App {...props} />;
|
blockerComponent: null,
|
||||||
}
|
blockerComponentProps: {},
|
||||||
|
description: pluginDescription,
|
||||||
|
icon: pluginPkg.strapi.icon,
|
||||||
|
id: pluginId,
|
||||||
|
initializer: Initializer,
|
||||||
|
injectedComponents: [],
|
||||||
|
layout: null,
|
||||||
|
lifecycles,
|
||||||
|
leftMenuLinks: [],
|
||||||
|
leftMenuSections: [],
|
||||||
|
mainComponent: App,
|
||||||
|
name: pluginPkg.strapi.name,
|
||||||
|
preventComponentRendering: false,
|
||||||
|
trads,
|
||||||
|
};
|
||||||
|
|
||||||
const plugin = {
|
return strapi.registerPlugin(plugin);
|
||||||
blockerComponent: null,
|
|
||||||
blockerComponentProps: {},
|
|
||||||
description: pluginDescription,
|
|
||||||
icon: pluginPkg.strapi.icon,
|
|
||||||
id: pluginId,
|
|
||||||
initializer: Initializer,
|
|
||||||
injectedComponents: [],
|
|
||||||
layout: null,
|
|
||||||
lifecycles,
|
|
||||||
leftMenuLinks: [],
|
|
||||||
leftMenuSections: [],
|
|
||||||
mainComponent: Comp,
|
|
||||||
name: pluginPkg.strapi.name,
|
|
||||||
preventComponentRendering: false,
|
|
||||||
trads,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default plugin;
|
|
||||||
|
@ -1,34 +1,30 @@
|
|||||||
import React from 'react';
|
|
||||||
import pluginPkg from '../../package.json';
|
import pluginPkg from '../../package.json';
|
||||||
import App from './containers/App';
|
import App from './containers/App';
|
||||||
import Initializer from './containers/Initializer';
|
import Initializer from './containers/Initializer';
|
||||||
|
|
||||||
import lifecycles from './lifecycles';
|
import lifecycles from './lifecycles';
|
||||||
import trads from './translations';
|
import trads from './translations';
|
||||||
import pluginId from './pluginId';
|
import pluginId from './pluginId';
|
||||||
|
|
||||||
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
export default strapi => {
|
||||||
|
const pluginDescription =
|
||||||
|
pluginPkg.strapi.description || pluginPkg.description;
|
||||||
|
const plugin = {
|
||||||
|
blockerComponent: null,
|
||||||
|
blockerComponentProps: {},
|
||||||
|
description: pluginDescription,
|
||||||
|
icon: pluginPkg.strapi.icon,
|
||||||
|
id: pluginId,
|
||||||
|
initializer: Initializer,
|
||||||
|
injectedComponents: [],
|
||||||
|
layout: null,
|
||||||
|
lifecycles,
|
||||||
|
leftMenuLinks: [],
|
||||||
|
leftMenuSections: [],
|
||||||
|
mainComponent: App,
|
||||||
|
name: pluginPkg.strapi.name,
|
||||||
|
preventComponentRendering: false,
|
||||||
|
trads,
|
||||||
|
};
|
||||||
|
|
||||||
function Comp(props) {
|
return strapi.registerPlugin(plugin);
|
||||||
return <App {...props} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
const plugin = {
|
|
||||||
blockerComponent: null,
|
|
||||||
blockerComponentProps: {},
|
|
||||||
description: pluginDescription,
|
|
||||||
icon: pluginPkg.strapi.icon,
|
|
||||||
id: pluginId,
|
|
||||||
initializer: Initializer,
|
|
||||||
injectedComponents: [],
|
|
||||||
layout: null,
|
|
||||||
lifecycles,
|
|
||||||
leftMenuLinks: [],
|
|
||||||
leftMenuSections: [],
|
|
||||||
mainComponent: Comp,
|
|
||||||
name: pluginPkg.strapi.name,
|
|
||||||
preventComponentRendering: false,
|
|
||||||
trads,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default plugin;
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import React from 'react';
|
|
||||||
import pluginPkg from '../../package.json';
|
import pluginPkg from '../../package.json';
|
||||||
import layout from '../../config/layout';
|
import layout from '../../config/layout';
|
||||||
import pluginId from './pluginId';
|
import pluginId from './pluginId';
|
||||||
@ -7,30 +6,29 @@ import Initializer from './containers/Initializer';
|
|||||||
import lifecycles from './lifecycles';
|
import lifecycles from './lifecycles';
|
||||||
import trads from './translations';
|
import trads from './translations';
|
||||||
|
|
||||||
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
export default strapi => {
|
||||||
|
const pluginDescription =
|
||||||
|
pluginPkg.strapi.description || pluginPkg.description;
|
||||||
|
|
||||||
function Comp(props) {
|
const plugin = {
|
||||||
return <App {...props} />;
|
blockerComponent: null,
|
||||||
}
|
blockerComponentProps: {},
|
||||||
|
description: pluginDescription,
|
||||||
|
icon: pluginPkg.strapi.icon,
|
||||||
|
id: pluginId,
|
||||||
|
initializer: Initializer,
|
||||||
|
injectedComponents: [],
|
||||||
|
layout,
|
||||||
|
lifecycles,
|
||||||
|
leftMenuLinks: [],
|
||||||
|
leftMenuSections: [],
|
||||||
|
mainComponent: App,
|
||||||
|
name: pluginPkg.strapi.name,
|
||||||
|
preventComponentRendering: false,
|
||||||
|
suffixUrl: () => '/roles',
|
||||||
|
suffixUrlToReplaceForLeftMenuHighlight: '/roles',
|
||||||
|
trads,
|
||||||
|
};
|
||||||
|
|
||||||
const plugin = {
|
return strapi.registerPlugin(plugin);
|
||||||
blockerComponent: null,
|
|
||||||
blockerComponentProps: {},
|
|
||||||
description: pluginDescription,
|
|
||||||
icon: pluginPkg.strapi.icon,
|
|
||||||
id: pluginId,
|
|
||||||
initializer: Initializer,
|
|
||||||
injectedComponents: [],
|
|
||||||
layout,
|
|
||||||
lifecycles,
|
|
||||||
leftMenuLinks: [],
|
|
||||||
leftMenuSections: [],
|
|
||||||
mainComponent: Comp,
|
|
||||||
name: pluginPkg.strapi.name,
|
|
||||||
preventComponentRendering: false,
|
|
||||||
suffixUrl: () => '/roles',
|
|
||||||
suffixUrlToReplaceForLeftMenuHighlight: '/roles',
|
|
||||||
trads,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default plugin;
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user