diff --git a/packages/strapi-admin/admin/src/strapi.js b/packages/strapi-admin/admin/src/strapi.js
index 107b073647..fb2263fa14 100644
--- a/packages/strapi-admin/admin/src/strapi.js
+++ b/packages/strapi-admin/admin/src/strapi.js
@@ -10,6 +10,8 @@ import {
updatePlugin,
} from 'containers/App/actions';
import { showNotification } from 'containers/NotificationProvider/actions';
+import injectReducer from './utils/injectReducer';
+import injectSaga from './utils/injectSaga';
import { history, store } from './createStore';
import { translationMessages, languages } from './i18n';
import './public-path';
@@ -94,4 +96,7 @@ window.strapi = Object.assign(window.strapi || {}, {
currentLanguage: window.localStorage.getItem('strapi-admin-language') || window.navigator.language || window.navigator.userLanguage || 'en',
lockApp,
unlockApp,
-});
\ No newline at end of file
+ injectReducer,
+ injectSaga,
+ store,
+});
diff --git a/packages/strapi-admin/admin/src/utils/injectReducer.js b/packages/strapi-admin/admin/src/utils/injectReducer.js
index 4af84187f3..60818e074b 100644
--- a/packages/strapi-admin/admin/src/utils/injectReducer.js
+++ b/packages/strapi-admin/admin/src/utils/injectReducer.js
@@ -11,7 +11,7 @@ import getInjectors from './reducerInjectors';
* @param {function} reducer A reducer that will be injected
*
*/
-export default ({ key, reducer }) => (WrappedComponent) => {
+export default ({ key, reducer, pluginId }) => (WrappedComponent) => {
class ReducerInjector extends React.Component {
static WrappedComponent = WrappedComponent;
static displayName = `withReducer(${(WrappedComponent.displayName || WrappedComponent.name || 'Component')})`;
@@ -21,8 +21,13 @@ export default ({ key, reducer }) => (WrappedComponent) => {
componentWillMount() {
const { injectReducer } = this.injectors;
+ let reducerName = key;
- injectReducer(key, reducer);
+ if (pluginId) {
+ reducerName = `${pluginId}-${key}`;
+ }
+
+ injectReducer(reducerName, reducer);
}
injectors = getInjectors(this.context.store);
diff --git a/packages/strapi-admin/admin/src/utils/injectSaga.js b/packages/strapi-admin/admin/src/utils/injectSaga.js
index 158b0e1732..3bd84a4938 100644
--- a/packages/strapi-admin/admin/src/utils/injectSaga.js
+++ b/packages/strapi-admin/admin/src/utils/injectSaga.js
@@ -15,7 +15,7 @@ import getInjectors from './sagaInjectors';
* - constants.ONCE_TILL_UNMOUNT—behaves like 'RESTART_ON_REMOUNT' but never runs it again.
*
*/
-export default ({ key, saga, mode }) => (WrappedComponent) => {
+export default ({ key, saga, mode, pluginId }) => (WrappedComponent) => {
class InjectSaga extends React.Component {
static WrappedComponent = WrappedComponent;
static displayName = `withSaga(${(WrappedComponent.displayName || WrappedComponent.name || 'Component')})`;
@@ -25,8 +25,13 @@ export default ({ key, saga, mode }) => (WrappedComponent) => {
componentWillMount() {
const { injectSaga } = this.injectors;
+ let sagaName = key;
- injectSaga(key, { saga, mode }, this.props);
+ if (pluginId) {
+ sagaName = `${pluginId}-${key}`;
+ }
+
+ injectSaga(sagaName, { saga, mode }, this.props);
}
componentWillUnmount() {
diff --git a/packages/strapi-helper-plugin/lib/src/app.js b/packages/strapi-helper-plugin/lib/src/app.js
index 24f2074753..25d8ca9437 100644
--- a/packages/strapi-helper-plugin/lib/src/app.js
+++ b/packages/strapi-helper-plugin/lib/src/app.js
@@ -11,9 +11,9 @@ import './public-path.js'; // eslint-disable-line import/extensions
import React from 'react';
import Loadable from 'react-loadable';
-import { Provider } from 'react-redux';
+// import { Provider } from 'react-redux';
import LoadingIndicatorPage from 'components/LoadingIndicatorPage';
-import configureStore from './store';
+// import configureStore from './store';
import { translationMessages } from './i18n';
@@ -61,22 +61,23 @@ const apiUrl = `${strapi.backendURL}/${pluginId}`;
const router = strapi.router;
// Create redux store with Strapi admin history
-const store = configureStore({}, strapi.router, pluginName);
+// const store = configureStore({}, strapi.router, pluginName);
+const store = strapi.store;
// Define the plugin root component
function Comp(props) {
return (
-
-
-
+ //
+
+ //
);
}
-if (window.Cypress) {
- window.__store__ = Object.assign(window.__store__ || {}, {
- [pluginId]: store,
- });
-}
+// if (window.Cypress) {
+// window.__store__ = Object.assign(window.__store__ || {}, {
+// [pluginId]: store,
+// });
+// }
// Hot reloadable translation json files
if (module.hot) {
diff --git a/packages/strapi-helper-plugin/lib/src/reducers.js b/packages/strapi-helper-plugin/lib/src/reducers.js
index 675e54a67a..e1c64df53a 100644
--- a/packages/strapi-helper-plugin/lib/src/reducers.js
+++ b/packages/strapi-helper-plugin/lib/src/reducers.js
@@ -8,7 +8,6 @@ import { fromJS } from 'immutable';
import { LOCATION_CHANGE } from 'react-router-redux';
import globalReducer from 'containers/App/reducer'; // eslint-disable-line
-
/*
* routeReducer
*
diff --git a/packages/strapi-plugin-users-permissions/admin/src/containers/App/actions.js b/packages/strapi-plugin-users-permissions/admin/src/containers/App/actions.js
deleted file mode 100644
index a5002ad023..0000000000
--- a/packages/strapi-plugin-users-permissions/admin/src/containers/App/actions.js
+++ /dev/null
@@ -1,5 +0,0 @@
-/*
- *
- * App actions
- *
- */
diff --git a/packages/strapi-plugin-users-permissions/admin/src/containers/App/constants.js b/packages/strapi-plugin-users-permissions/admin/src/containers/App/constants.js
deleted file mode 100644
index f62c609507..0000000000
--- a/packages/strapi-plugin-users-permissions/admin/src/containers/App/constants.js
+++ /dev/null
@@ -1,5 +0,0 @@
-/*
- *
- * App constants
- *
- */
diff --git a/packages/strapi-plugin-users-permissions/admin/src/containers/App/index.js b/packages/strapi-plugin-users-permissions/admin/src/containers/App/index.js
index 16efbef769..6b44dea864 100644
--- a/packages/strapi-plugin-users-permissions/admin/src/containers/App/index.js
+++ b/packages/strapi-plugin-users-permissions/admin/src/containers/App/index.js
@@ -7,10 +7,9 @@
import React from 'react';
import PropTypes from 'prop-types';
-import { connect } from 'react-redux';
-import { createStructuredSelector } from 'reselect';
+// import { connect } from 'react-redux';
import { Switch, Route } from 'react-router-dom';
-import { bindActionCreators, compose } from 'redux';
+// import { bindActionCreators, compose } from 'redux';
// Utils
import { pluginId } from 'app';
@@ -59,18 +58,17 @@ App.propTypes = {
location: PropTypes.object.isRequired,
};
-export function mapDispatchToProps(dispatch) {
- return bindActionCreators(
- {},
- dispatch,
- );
-}
-
-const mapStateToProps = createStructuredSelector({});
+// export function mapDispatchToProps(dispatch) {
+// return bindActionCreators(
+// {},
+// dispatch,
+// );
+// }
// Wrap the component to inject dispatch and state into it
-const withConnect = connect(mapStateToProps, mapDispatchToProps);
+// const withConnect = connect(null, mapDispatchToProps);
+export default App;
-export default compose(
- withConnect,
-)(App);
+// export default compose(
+// withConnect,
+// )(App);
diff --git a/packages/strapi-plugin-users-permissions/admin/src/containers/App/reducer.js b/packages/strapi-plugin-users-permissions/admin/src/containers/App/reducer.js
deleted file mode 100644
index 38026c39cd..0000000000
--- a/packages/strapi-plugin-users-permissions/admin/src/containers/App/reducer.js
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- *
- * App reducer
- *
- */
-
-import { fromJS } from 'immutable';
-
-const initialState = fromJS({});
-
-function appReducer(state = initialState, action) {
- switch (action.type) {
- default:
- return state;
- }
-}
-
-export default appReducer;
diff --git a/packages/strapi-plugin-users-permissions/admin/src/containers/App/selectors.js b/packages/strapi-plugin-users-permissions/admin/src/containers/App/selectors.js
deleted file mode 100644
index 59c3cfbba0..0000000000
--- a/packages/strapi-plugin-users-permissions/admin/src/containers/App/selectors.js
+++ /dev/null
@@ -1,7 +0,0 @@
-// import { createSelector } from 'reselect';
-
-/**
- * Direct selector to the list state domain
- */
-
-// const selectGlobalDomain = () => state => state.get('global');
diff --git a/packages/strapi-plugin-users-permissions/admin/src/containers/AuthPage/index.js b/packages/strapi-plugin-users-permissions/admin/src/containers/AuthPage/index.js
index 757283664a..d67fee74c7 100644
--- a/packages/strapi-plugin-users-permissions/admin/src/containers/AuthPage/index.js
+++ b/packages/strapi-plugin-users-permissions/admin/src/containers/AuthPage/index.js
@@ -22,8 +22,6 @@ import Input from 'components/InputsIndex';
// Utils
import auth from 'utils/auth';
-import injectSaga from 'utils/injectSaga';
-import injectReducer from 'utils/injectReducer';
import {
hideLoginErrorsInput,
@@ -328,16 +326,8 @@ function mapDispatchToProps(dispatch) {
}
const withConnect = connect(mapStateToProps, mapDispatchToProps);
-
-/* Remove this line if the container doesn't have a route and
-* check the documentation to see how to create the container's store
-*/
-const withReducer = injectReducer({ key: 'authPage', reducer });
-
-/* Remove the line below the container doesn't have a route and
-* check the documentation to see how to create the container's store
-*/
-const withSaga = injectSaga({ key: 'authPage', saga });
+const withReducer = strapi.injectReducer({ key: 'authPage', reducer, pluginId: 'users-permissions' });
+const withSaga = strapi.injectSaga({ key: 'authPage', saga, pluginId: 'users-permissions' });
export default compose(
withReducer,
diff --git a/packages/strapi-plugin-users-permissions/admin/src/containers/AuthPage/selectors.js b/packages/strapi-plugin-users-permissions/admin/src/containers/AuthPage/selectors.js
index 4029f19277..6f9e7af843 100644
--- a/packages/strapi-plugin-users-permissions/admin/src/containers/AuthPage/selectors.js
+++ b/packages/strapi-plugin-users-permissions/admin/src/containers/AuthPage/selectors.js
@@ -3,7 +3,7 @@ import { createSelector } from 'reselect';
/**
* Direct selector to the authPage state domain
*/
-const selectAuthPageDomain = () => (state) => state.get('authPage');
+const selectAuthPageDomain = () => (state) => state.get('users-permissions-authPage');
/**
* Default selector used by AuthPage
diff --git a/packages/strapi-plugin-users-permissions/admin/src/containers/EditPage/index.js b/packages/strapi-plugin-users-permissions/admin/src/containers/EditPage/index.js
index 894027dc90..27ff04c536 100644
--- a/packages/strapi-plugin-users-permissions/admin/src/containers/EditPage/index.js
+++ b/packages/strapi-plugin-users-permissions/admin/src/containers/EditPage/index.js
@@ -23,9 +23,6 @@ import PluginHeader from 'components/PluginHeader';
import Plugins from 'components/Plugins';
import Policies from 'components/Policies';
-import injectSaga from 'utils/injectSaga';
-import injectReducer from 'utils/injectReducer';
-
// Actions
import {
addUser,
@@ -326,16 +323,8 @@ function mapDispatchToProps(dispatch) {
}
const withConnect = connect(mapStateToProps, mapDispatchToProps);
-
-/* Remove this line if the container doesn't have a route and
-* check the documentation to see how to create the container's store
-*/
-const withReducer = injectReducer({ key: 'editPage', reducer });
-
-/* Remove the line below the container doesn't have a route and
-* check the documentation to see how to create the container's store
-*/
-const withSaga = injectSaga({ key: 'editPage', saga });
+const withReducer = strapi.injectReducer({ key: 'editPage', reducer, pluginId: 'users-permissions'});
+const withSaga = strapi.injectSaga({ key: 'editPage', saga, pluginId: 'users-permissions' });
export default compose(
withReducer,
diff --git a/packages/strapi-plugin-users-permissions/admin/src/containers/EditPage/selectors.js b/packages/strapi-plugin-users-permissions/admin/src/containers/EditPage/selectors.js
index ae0bb87c3a..159023fb5e 100644
--- a/packages/strapi-plugin-users-permissions/admin/src/containers/EditPage/selectors.js
+++ b/packages/strapi-plugin-users-permissions/admin/src/containers/EditPage/selectors.js
@@ -3,7 +3,7 @@ import { createSelector } from 'reselect';
/**
* Direct selector to the editPage state domain
*/
-const selectEditPageDomain = () => (state) => state.get('editPage');
+const selectEditPageDomain = () => (state) => state.get('users-permissions-editPage');
/**
* Default selector used by EditPage
diff --git a/packages/strapi-plugin-users-permissions/admin/src/containers/HomePage/index.js b/packages/strapi-plugin-users-permissions/admin/src/containers/HomePage/index.js
index 8778e163b5..08df1f03b2 100644
--- a/packages/strapi-plugin-users-permissions/admin/src/containers/HomePage/index.js
+++ b/packages/strapi-plugin-users-permissions/admin/src/containers/HomePage/index.js
@@ -19,10 +19,6 @@ import List from 'components/List';
import PluginHeader from 'components/PluginHeader';
import PopUpForm from 'components/PopUpForm';
-// Utils
-import injectReducer from 'utils/injectReducer';
-import injectSaga from 'utils/injectSaga';
-
// Selectors
import selectHomePage from './selectors';
@@ -280,8 +276,8 @@ const mapStateToProps = selectHomePage();
const withConnect = connect(mapStateToProps, mapDispatchToProps);
-const withReducer = injectReducer({ key: 'homePage', reducer });
-const withSaga = injectSaga({ key: 'homePage', saga });
+const withReducer = strapi.injectReducer({ key: 'homePage', reducer, pluginId: 'users-permissions' });
+const withSaga = strapi.injectSaga({ key: 'homePage', saga, pluginId: 'users-permissions' });
export default compose(
withReducer,
diff --git a/packages/strapi-plugin-users-permissions/admin/src/containers/HomePage/saga.js b/packages/strapi-plugin-users-permissions/admin/src/containers/HomePage/saga.js
index c5ff308f0e..63f7ead670 100644
--- a/packages/strapi-plugin-users-permissions/admin/src/containers/HomePage/saga.js
+++ b/packages/strapi-plugin-users-permissions/admin/src/containers/HomePage/saga.js
@@ -1,6 +1,14 @@
-import { LOCATION_CHANGE } from 'react-router-redux';
+// import { LOCATION_CHANGE } from 'react-router-redux';
import { findIndex, get } from 'lodash';
-import { takeLatest, put, fork, take, cancel, select, call } from 'redux-saga/effects';
+import {
+ takeLatest,
+ put,
+ fork,
+ // take,
+ // cancel,
+ select,
+ call,
+} from 'redux-saga/effects';
import request from 'utils/request';
@@ -75,13 +83,14 @@ export function* submitData(action) {
}
// Individual exports for testing
export function* defaultSaga() {
- const loadDataWatcher = yield fork(takeLatest, FETCH_DATA, dataFetch);
+ // const loadDataWatcher = yield fork(takeLatest, FETCH_DATA, dataFetch);
+ yield fork(takeLatest, FETCH_DATA, dataFetch);
yield fork(takeLatest, DELETE_DATA, dataDelete);
yield fork(takeLatest, SUBMIT, submitData);
- yield take(LOCATION_CHANGE);
- yield cancel(loadDataWatcher);
+ // yield take(LOCATION_CHANGE);
+ // yield cancel(loadDataWatcher);
}
// All sagas to be loaded
diff --git a/packages/strapi-plugin-users-permissions/admin/src/containers/HomePage/selectors.js b/packages/strapi-plugin-users-permissions/admin/src/containers/HomePage/selectors.js
index 34abcc4fcf..4c9fc780e0 100644
--- a/packages/strapi-plugin-users-permissions/admin/src/containers/HomePage/selectors.js
+++ b/packages/strapi-plugin-users-permissions/admin/src/containers/HomePage/selectors.js
@@ -3,7 +3,7 @@ import { createSelector } from 'reselect';
/**
* Direct selector to the homePage state domain
*/
-const selectHomePageDomain = () => state => state.get('homePage');
+const selectHomePageDomain = () => state => state.get('users-permissions-homePage');
/**
* Default selector used by HomePage