mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 15:13:21 +00:00
Make plugin injection more dynamic
This commit is contained in:
parent
a1c344ab15
commit
3d370d2a82
@ -14,19 +14,27 @@ export class Content extends React.Component { // eslint-disable-line react/pref
|
||||
render() {
|
||||
let plugin;
|
||||
|
||||
// Detect plugin according to params
|
||||
this.props.plugins.map(p => {
|
||||
plugin = p;
|
||||
return p;
|
||||
if (this.props.params.plugin === p.id) {
|
||||
plugin = p;
|
||||
}
|
||||
});
|
||||
|
||||
const Elem = plugin.mainComponent;
|
||||
let content;
|
||||
if (!plugin) {
|
||||
content = <p>Unknown plugin.</p>
|
||||
} else {
|
||||
const Elem = plugin.mainComponent;
|
||||
content = <Elem plugin={plugin}></Elem>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={styles.content}>
|
||||
<div className="alert alert-success" role="alert">
|
||||
<strong>Welcome!</strong> You successfully loaded the admin panel.
|
||||
</div>
|
||||
<Elem></Elem>
|
||||
{content}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ export class HomePage extends React.Component { // eslint-disable-line react/pre
|
||||
<LeftMenu {...this.props}></LeftMenu>
|
||||
<div className={styles.homePageRightWrapper}>
|
||||
<Header></Header>
|
||||
<Content></Content>
|
||||
<Content {...this.props}></Content>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@ -55,7 +55,7 @@ export default function createRoutes(store) {
|
||||
},
|
||||
}, {
|
||||
path: '*',
|
||||
name: 'notfound',
|
||||
name: '404',
|
||||
getComponent(nextState, cb) {
|
||||
System.import('containers/NotFoundPage')
|
||||
.then(loadModule(cb))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user