mirror of
https://github.com/strapi/strapi.git
synced 2025-07-30 12:29:30 +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 =
|
||||
document.getElementById('app') || document.createElement('div');
|
||||
|
||||
Object.keys(plugins).forEach(plugin => {
|
||||
const currentPlugin = plugins[plugin];
|
||||
Object.keys(plugins).forEach(current => {
|
||||
const registerPlugin = plugin => {
|
||||
return plugin;
|
||||
};
|
||||
const currentPluginFn = plugins[current];
|
||||
const plugin = currentPluginFn({ registerPlugin });
|
||||
|
||||
const pluginTradsPrefixed = languages.reduce((acc, lang) => {
|
||||
const currentLocale = currentPlugin.trads[lang];
|
||||
const currentLocale = plugin.trads[lang];
|
||||
|
||||
if (currentLocale) {
|
||||
const localeprefixedWithPluginId = Object.keys(currentLocale).reduce(
|
||||
(acc2, current) => {
|
||||
acc2[`${plugins[plugin].id}.${current}`] = currentLocale[current];
|
||||
acc2[`${plugin.id}.${current}`] = currentLocale[current];
|
||||
|
||||
return acc2;
|
||||
},
|
||||
@ -81,7 +85,7 @@ Object.keys(plugins).forEach(plugin => {
|
||||
|
||||
try {
|
||||
merge(translationMessages, pluginTradsPrefixed);
|
||||
dispatch(pluginLoaded(currentPlugin));
|
||||
dispatch(pluginLoaded(plugin));
|
||||
} catch (err) {
|
||||
console.log({ err });
|
||||
}
|
||||
|
@ -92,8 +92,9 @@ describe('<Admin />', () => {
|
||||
it('should render the routes', () => {
|
||||
const renderedComponent = shallow(<Admin {...props} />);
|
||||
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 pluginId from './pluginId';
|
||||
import App from './containers/Main';
|
||||
@ -7,31 +5,29 @@ import Initializer from './containers/Initializer';
|
||||
import lifecycles from './lifecycles';
|
||||
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 <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,
|
||||
return strapi.registerPlugin(plugin);
|
||||
};
|
||||
|
||||
export default plugin;
|
||||
|
@ -1,4 +1,3 @@
|
||||
import React from 'react';
|
||||
import pluginPkg from '../../package.json';
|
||||
import App from './containers/App';
|
||||
import Initializer from './containers/Initializer';
|
||||
@ -8,47 +7,45 @@ import lifecycles from './lifecycles';
|
||||
import trads from './translations';
|
||||
import pluginId from './pluginId';
|
||||
|
||||
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
||||
|
||||
function Comp(props) {
|
||||
return <App {...props} />;
|
||||
}
|
||||
|
||||
const plugin = {
|
||||
blockerComponent: null,
|
||||
blockerComponentProps: {},
|
||||
description: pluginDescription,
|
||||
icon: pluginPkg.strapi.icon,
|
||||
id: pluginId,
|
||||
initializer: Initializer,
|
||||
injectedComponents: [
|
||||
{
|
||||
plugin: 'content-manager.editView',
|
||||
area: 'right.links',
|
||||
component: Link,
|
||||
key: 'content-type-builder.link',
|
||||
props: {
|
||||
message: {
|
||||
id: 'content-manager.containers.Edit.Link.Fields',
|
||||
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: [
|
||||
{
|
||||
plugin: 'content-manager.editView',
|
||||
area: 'right.links',
|
||||
component: Link,
|
||||
key: 'content-type-builder.link',
|
||||
props: {
|
||||
message: {
|
||||
id: 'content-manager.containers.Edit.Link.Fields',
|
||||
},
|
||||
icon: 'fa-cog',
|
||||
},
|
||||
icon: 'fa-cog',
|
||||
},
|
||||
},
|
||||
{
|
||||
plugin: 'content-manager.editSettingsView',
|
||||
area: 'left.links',
|
||||
component: Button,
|
||||
key: 'content-type-builder.form',
|
||||
},
|
||||
],
|
||||
layout: null,
|
||||
lifecycles,
|
||||
leftMenuLinks: [],
|
||||
leftMenuSections: [],
|
||||
mainComponent: Comp,
|
||||
name: pluginPkg.strapi.name,
|
||||
preventComponentRendering: false,
|
||||
trads,
|
||||
};
|
||||
{
|
||||
plugin: 'content-manager.editSettingsView',
|
||||
area: 'left.links',
|
||||
component: Button,
|
||||
key: 'content-type-builder.form',
|
||||
},
|
||||
],
|
||||
layout: null,
|
||||
lifecycles,
|
||||
leftMenuLinks: [],
|
||||
leftMenuSections: [],
|
||||
mainComponent: App,
|
||||
name: pluginPkg.strapi.name,
|
||||
preventComponentRendering: false,
|
||||
trads,
|
||||
};
|
||||
|
||||
export default plugin;
|
||||
return strapi.registerPlugin(plugin);
|
||||
};
|
||||
|
@ -1,4 +1,3 @@
|
||||
import React from 'react';
|
||||
import pluginPkg from '../../package.json';
|
||||
import pluginId from './pluginId';
|
||||
import App from './containers/App';
|
||||
@ -6,29 +5,27 @@ import Initializer from './containers/Initializer';
|
||||
import lifecycles from './lifecycles';
|
||||
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 <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,
|
||||
return strapi.registerPlugin(plugin);
|
||||
};
|
||||
|
||||
export default plugin;
|
||||
|
@ -1,4 +1,3 @@
|
||||
import React from 'react';
|
||||
import pluginPkg from '../../package.json';
|
||||
import pluginId from './pluginId';
|
||||
import App from './containers/App';
|
||||
@ -6,28 +5,27 @@ import Initializer from './containers/Initializer';
|
||||
import lifecycles from './lifecycles';
|
||||
import trads from './translations';
|
||||
|
||||
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
||||
export default strapi => {
|
||||
const pluginDescription =
|
||||
pluginPkg.strapi.description || pluginPkg.description;
|
||||
|
||||
function Comp(props) {
|
||||
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: App,
|
||||
name: pluginPkg.strapi.name,
|
||||
preventComponentRendering: false,
|
||||
trads,
|
||||
};
|
||||
|
||||
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,
|
||||
return strapi.registerPlugin(plugin);
|
||||
};
|
||||
|
||||
export default plugin;
|
||||
|
@ -1,34 +1,30 @@
|
||||
import React from 'react';
|
||||
import pluginPkg from '../../package.json';
|
||||
import App from './containers/App';
|
||||
import Initializer from './containers/Initializer';
|
||||
|
||||
import lifecycles from './lifecycles';
|
||||
import trads from './translations';
|
||||
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 <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,
|
||||
return strapi.registerPlugin(plugin);
|
||||
};
|
||||
|
||||
export default plugin;
|
||||
|
@ -1,4 +1,3 @@
|
||||
import React from 'react';
|
||||
import pluginPkg from '../../package.json';
|
||||
import layout from '../../config/layout';
|
||||
import pluginId from './pluginId';
|
||||
@ -7,30 +6,29 @@ import Initializer from './containers/Initializer';
|
||||
import lifecycles from './lifecycles';
|
||||
import trads from './translations';
|
||||
|
||||
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
|
||||
export default strapi => {
|
||||
const pluginDescription =
|
||||
pluginPkg.strapi.description || pluginPkg.description;
|
||||
|
||||
function Comp(props) {
|
||||
return <App {...props} />;
|
||||
}
|
||||
const plugin = {
|
||||
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 = {
|
||||
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,
|
||||
return strapi.registerPlugin(plugin);
|
||||
};
|
||||
|
||||
export default plugin;
|
||||
|
Loading…
x
Reference in New Issue
Block a user