Update plugin generators

This commit is contained in:
soupette 2019-02-11 18:35:46 +01:00
parent d81fba0488
commit 85774b2f51
10 changed files with 31 additions and 20 deletions

View File

@ -13,7 +13,7 @@ import { Switch, Route } from 'react-router-dom';
import { bindActionCreators, compose } from 'redux';
// Utils
import { pluginId } from 'app';
import pluginId from 'pluginId';
// Containers
import HomePage from 'containers/HomePage';
@ -21,6 +21,7 @@ import NotFoundPage from 'containers/NotFoundPage';
// When you're done studying the ExamplePage container, remove the following line and delete the ExamplePage container
import ExamplePage from 'containers/ExamplePage';
import reducer from './reducer';
class App extends React.Component {
// When you're done studying the ExamplePage container, remove the following lines and delete the ExamplePage container
@ -44,7 +45,6 @@ class App extends React.Component {
App.contextTypes = {
plugins: PropTypes.object,
router: PropTypes.object.isRequired,
updatePlugin: PropTypes.func,
};
@ -63,7 +63,9 @@ const mapStateToProps = createStructuredSelector({});
// Wrap the component to inject dispatch and state into it
const withConnect = connect(mapStateToProps, mapDispatchToProps);
const withReducer = strapi.injectReducer({ key: 'global', reducer, pluginId });
export default compose(
withReducer,
withConnect,
)(App);

View File

@ -1,9 +1,10 @@
// import { createSelector } from 'reselect';
// import pluginId from 'pluginId';
/**
* Direct selector to the list state domain
*/
// const selectGlobalDomain = () => state => state.get('global');
// const selectGlobalDomain = () => state => state.get(`${pluginId}-global`);
export {};

View File

@ -4,5 +4,7 @@
*
*/
export const LOAD_DATA = 'ExamplePage/LOAD_DATA';
export const LOADED_DATA = 'ExamplePage/LOADED_DATA';
import pluginId from 'pluginId';
export const LOAD_DATA = `${pluginId}/ExamplePage/LOAD_DATA`;
export const LOADED_DATA = `${pluginId}/ExamplePage/LOADED_DATA`;

View File

@ -10,9 +10,7 @@ import { connect } from 'react-redux';
import { createStructuredSelector } from 'reselect';
import { injectIntl } from 'react-intl';
import { bindActionCreators, compose } from 'redux';
import injectReducer from 'utils/injectReducer';
import injectSaga from 'utils/injectSaga';
import pluginId from 'pluginId';
import Button from 'components/Button';
@ -90,8 +88,8 @@ const mapStateToProps = createStructuredSelector({
const withConnect = connect(mapStateToProps, mapDispatchToProps);
const withReducer = injectReducer({ key: 'examplePage', reducer });
const withSaga = injectSaga({ key: 'examplePage', saga });
const withReducer = strapi.injectReducer({ key: 'examplePage', reducer, pluginId });
const withSaga = strapi.injectSaga({ key: 'examplePage', saga, pluginId });
export default compose(
withReducer,

View File

@ -1,9 +1,10 @@
import { createSelector } from 'reselect';
import pluginId from 'pluginId';
/**
* Direct selector to the examplePage state domain
*/
const selectExamplePageDomain = () => state => state.get('examplePage');
const selectExamplePageDomain = () => state => state.get(`${pluginId}-examplePage`);
/**
* Default selector used by HomePage

View File

@ -4,4 +4,6 @@
*
*/
export const DEFAULT_ACTION = 'HomePage/DEFAULT_ACTION';
import pluginId from 'pluginId';
export const DEFAULT_ACTION = `${pluginId}/HomePage/DEFAULT_ACTION`;

View File

@ -10,9 +10,7 @@ import { connect } from 'react-redux';
import { createStructuredSelector } from 'reselect';
import { injectIntl } from 'react-intl';
import { bindActionCreators, compose } from 'redux';
import injectReducer from 'utils/injectReducer';
import injectSaga from 'utils/injectSaga';
import pluginId from 'pluginId';
// Selectors
import selectHomePage from './selectors';
@ -55,8 +53,8 @@ const mapStateToProps = createStructuredSelector({
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 });
const withSaga = strapi.injectSaga({ key: 'homePage', saga, pluginId });
export default compose(
withReducer,

View File

@ -1,9 +1,9 @@
import { createSelector } from 'reselect';
import pluginId from 'pluginId';
/**
* Direct selector to the homePage state domain
*/
const selectHomePageDomain = () => state => state.get('homePage');
const selectHomePageDomain = () => state => state.get(`${pluginId}-homePage`);
/**
* Default selector used by HomePage

View File

@ -0,0 +1,7 @@
const pluginPkg = require('../../package.json');
const pluginId = pluginPkg.name.replace(
/^strapi-plugin-/i,
''
);
module.exports = pluginId;

View File

@ -47,7 +47,7 @@ function* submit() {
}, init);
};
const body = createBody(cloneDeep(form));
console.log({ form, body });
if (body.restrictedAccess && body.password === '') {
return yield put(
setFormErrors({ password: [{ id: 'components.Input.error.validation.required' }] }),