mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 08:19:07 +00:00
Fix conflict
This commit is contained in:
commit
fab65fdd0b
@ -36,6 +36,7 @@ import LanguageProvider from 'containers/LanguageProvider';
|
||||
import App from 'containers/App';
|
||||
import { showNotification } from 'containers/NotificationProvider/actions';
|
||||
import { pluginLoaded, updatePlugin } from 'containers/App/actions';
|
||||
import auth from 'utils/auth';
|
||||
|
||||
import configureStore from './store';
|
||||
import { translationMessages, languages } from './i18n';
|
||||
@ -120,6 +121,9 @@ if (window.location.port !== '4000') {
|
||||
});
|
||||
}
|
||||
|
||||
// const isPluginAllowedToRegister = (plugin) => true;
|
||||
const isPluginAllowedToRegister = (plugin) => plugin.id === 'users-permissions' || plugin.id === 'email' || auth.getToken();
|
||||
|
||||
/**
|
||||
* Public Strapi object exposed to the `window` object
|
||||
*/
|
||||
@ -134,10 +138,11 @@ const registerPlugin = (plugin) => {
|
||||
merge(translationMessages, plugin.translationMessages);
|
||||
|
||||
plugin.leftMenuSections = plugin.leftMenuSections || [];
|
||||
const shouldAllowRegister = isPluginAllowedToRegister(plugin);
|
||||
|
||||
switch (true) {
|
||||
// Execute bootstrap function and check if plugin can be rendered
|
||||
case isFunction(plugin.bootstrap) && isFunction(plugin.pluginRequirements):
|
||||
case isFunction(plugin.bootstrap) && isFunction(plugin.pluginRequirements) && shouldAllowRegister:
|
||||
plugin.pluginRequirements(plugin)
|
||||
.then(plugin => {
|
||||
return plugin.bootstrap(plugin);
|
||||
@ -153,7 +158,7 @@ const registerPlugin = (plugin) => {
|
||||
});
|
||||
break;
|
||||
// Execute bootstrap function
|
||||
case isFunction(plugin.bootstrap):
|
||||
case isFunction(plugin.bootstrap) && shouldAllowRegister:
|
||||
plugin.bootstrap(plugin).then(plugin => {
|
||||
store.dispatch(pluginLoaded(plugin));
|
||||
});
|
||||
|
@ -14,9 +14,9 @@ import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import { createStructuredSelector } from 'reselect';
|
||||
import { Switch, Route } from 'react-router-dom';
|
||||
import { get, includes, isUndefined } from 'lodash';
|
||||
import { get, includes, isFunction, isUndefined, map, omit } from 'lodash';
|
||||
|
||||
import { updatePlugin } from 'containers/App/actions';
|
||||
import { pluginLoaded, updatePlugin } from 'containers/App/actions';
|
||||
import { selectPlugins } from 'containers/App/selectors';
|
||||
import { hideNotification } from 'containers/NotificationProvider/actions';
|
||||
|
||||
@ -36,6 +36,8 @@ import auth from 'utils/auth';
|
||||
import styles from './styles.scss';
|
||||
|
||||
export class AdminPage extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
||||
state = { hasAlreadyRegistereOtherPlugins: false };
|
||||
|
||||
getChildContext = () => (
|
||||
{
|
||||
plugins: this.props.plugins,
|
||||
@ -66,6 +68,20 @@ export class AdminPage extends React.Component { // eslint-disable-line react/pr
|
||||
if (!this.isUrlProtected(props) && includes(props.location.pathname, 'register') && this.hasAdminUser()) {
|
||||
this.props.history.push('/plugins/users-permissions/auth/login');
|
||||
}
|
||||
|
||||
if (!this.hasUsersPlugin() || auth.getToken() && !this.state.hasAlreadyRegistereOtherPlugins) {
|
||||
map(omit(this.props.plugins.toJS(), ['users-permissions', 'email']), plugin => {
|
||||
if (isFunction(plugin.bootstrap)) {
|
||||
plugin.bootstrap(plugin)
|
||||
.then(updatedPlugin => this.props.pluginLoaded(updatedPlugin))
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
this.setState({ hasAlreadyRegistereOtherPlugins: true });
|
||||
}
|
||||
}
|
||||
|
||||
hasUsersPlugin = () => !isUndefined(get(this.props.plugins.toJS(), 'users-permissions'));
|
||||
@ -118,6 +134,7 @@ AdminPage.contextTypes = {
|
||||
AdminPage.propTypes = {
|
||||
history: PropTypes.object.isRequired,
|
||||
location: PropTypes.object.isRequired,
|
||||
pluginLoaded: PropTypes.func.isRequired,
|
||||
plugins: PropTypes.object.isRequired,
|
||||
updatePlugin: PropTypes.func.isRequired,
|
||||
};
|
||||
@ -130,6 +147,7 @@ function mapDispatchToProps(dispatch) {
|
||||
return {
|
||||
onHideNotification: (id) => { dispatch(hideNotification(id)); },
|
||||
updatePlugin: (pluginId, updatedKey, updatedValue) => { dispatch(updatePlugin(pluginId, updatedKey, updatedValue)); },
|
||||
pluginLoaded: (plugin) => { dispatch(pluginLoaded(plugin)); },
|
||||
dispatch,
|
||||
};
|
||||
}
|
||||
|
@ -83,20 +83,20 @@ if (module.hot) {
|
||||
|
||||
// Register the plugin.
|
||||
strapi.registerPlugin({
|
||||
name: pluginPkg.strapi.name,
|
||||
icon: pluginPkg.strapi.icon,
|
||||
blockerComponent: null,
|
||||
blockerComponentProps: {},
|
||||
bootstrap,
|
||||
description: pluginDescription,
|
||||
icon: pluginPkg.strapi.icon,
|
||||
id: pluginId,
|
||||
injectedComponents,
|
||||
layout,
|
||||
leftMenuLinks: [],
|
||||
mainComponent: Comp,
|
||||
translationMessages,
|
||||
bootstrap,
|
||||
name: pluginPkg.strapi.name,
|
||||
pluginRequirements,
|
||||
layout,
|
||||
preventComponentRendering: false,
|
||||
blockerComponent: null,
|
||||
injectedComponents,
|
||||
blockerComponentProps: {},
|
||||
translationMessages,
|
||||
});
|
||||
|
||||
// Export store
|
||||
|
3
packages/strapi-plugin-content-type-builder/admin/src/bootstrap.js
vendored
Normal file
3
packages/strapi-plugin-content-type-builder/admin/src/bootstrap.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
const bootstrap = (plugin) => Promise.resolve(plugin);
|
||||
|
||||
export default bootstrap;
|
3
packages/strapi-plugin-settings-manager/admin/src/bootstrap.js
vendored
Normal file
3
packages/strapi-plugin-settings-manager/admin/src/bootstrap.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
const bootstrap = (plugin) => Promise.resolve(plugin);
|
||||
|
||||
export default bootstrap;
|
@ -113,7 +113,7 @@ export function getUser(user) {
|
||||
export function getUserSucceeded(users) {
|
||||
return {
|
||||
type: GET_USER_SUCCEEDED,
|
||||
users,
|
||||
users: users.filter(o => o.role.toString() !== '0'),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -268,7 +268,7 @@
|
||||
"controllers": {
|
||||
"contentmanager": {
|
||||
"models": {
|
||||
"enabled": true,
|
||||
"enabled": false,
|
||||
"policy": ""
|
||||
},
|
||||
"find": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user