mirror of
https://github.com/strapi/strapi.git
synced 2025-11-01 18:33:55 +00:00
Update reducer injector in all plugins
Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
parent
76e63b8dd1
commit
13d4c58bbe
@ -104,7 +104,7 @@
|
||||
"app.components.listPlugins.title.singular": "{number} Plugin ist installiert",
|
||||
"app.components.listPluginsPage.deletePlugin.error": "Bei der Entfernung des Plugins ist ein Fehler aufgetreten",
|
||||
"app.utils.SelectOption.defaultMessage": " ",
|
||||
"app.utils.defaultMessage": "",
|
||||
"app.utils.defaultMessage": " ",
|
||||
"app.utils.placeholder.defaultMessage": " ",
|
||||
"components.AutoReloadBlocker.description": "Führen Sie Strapi mit einem der folgenden Befehle aus:",
|
||||
"components.AutoReloadBlocker.header": "Dieses Plugin benötigt das Neuladen-Feature.",
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import { injectIntl } from 'react-intl';
|
||||
import { CopyToClipboard } from 'react-copy-to-clipboard';
|
||||
import { bindActionCreators, compose } from 'redux';
|
||||
import { get, isEmpty } from 'lodash';
|
||||
@ -39,7 +38,6 @@ import {
|
||||
} from './actions';
|
||||
// Selectors
|
||||
import selectHomePage from './selectors';
|
||||
import reducer from './reducer';
|
||||
import saga from './saga';
|
||||
|
||||
export class HomePage extends React.Component {
|
||||
@ -188,9 +186,7 @@ export class HomePage extends React.Component {
|
||||
onChange={() => {}}
|
||||
label={{ id: getTrad('containers.HomePage.form.jwtToken') }}
|
||||
inputDescription={{
|
||||
id: getTrad(
|
||||
'containers.HomePage.form.jwtToken.description'
|
||||
),
|
||||
id: getTrad('containers.HomePage.form.jwtToken.description'),
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
@ -257,19 +253,7 @@ function mapDispatchToProps(dispatch) {
|
||||
|
||||
const mapStateToProps = selectHomePage();
|
||||
|
||||
const withConnect = connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
);
|
||||
const withReducer = strapi.injectReducer({
|
||||
key: 'homePage',
|
||||
reducer,
|
||||
pluginId,
|
||||
});
|
||||
const withConnect = connect(mapStateToProps, mapDispatchToProps);
|
||||
const withSaga = strapi.injectSaga({ key: 'homePage', saga, pluginId });
|
||||
|
||||
export default compose(
|
||||
withReducer,
|
||||
withSaga,
|
||||
withConnect
|
||||
)(injectIntl(HomePage));
|
||||
export default compose(withSaga, withConnect)(HomePage);
|
||||
|
||||
@ -11,6 +11,7 @@ import pluginLogo from './assets/images/logo.svg';
|
||||
import App from './containers/App';
|
||||
import Initializer from './containers/Initializer';
|
||||
import lifecycles from './lifecycles';
|
||||
import reducers from './reducers';
|
||||
import trads from './translations';
|
||||
|
||||
export default strapi => {
|
||||
@ -33,6 +34,7 @@ export default strapi => {
|
||||
name: pluginPkg.strapi.name,
|
||||
pluginLogo,
|
||||
preventComponentRendering: false,
|
||||
reducers,
|
||||
trads,
|
||||
};
|
||||
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
import homePageReducer from './containers/HomePage/reducer';
|
||||
import pluginId from './pluginId';
|
||||
|
||||
const reducers = {
|
||||
[`${pluginId}_homePage`]: homePageReducer,
|
||||
};
|
||||
|
||||
export default reducers;
|
||||
@ -10,20 +10,14 @@ import { connect } from 'react-redux';
|
||||
import { bindActionCreators, compose } from 'redux';
|
||||
import { findIndex, get, isEmpty } from 'lodash';
|
||||
import { Header } from '@buffetjs/custom';
|
||||
|
||||
// You can find these components in either
|
||||
// ./node_modules/strapi-helper-plugin/lib/src
|
||||
// or strapi/packages/strapi-helper-plugin/lib/src
|
||||
import { ContainerFluid, HeaderNav, GlobalContext } from 'strapi-helper-plugin';
|
||||
|
||||
import pluginId from '../../pluginId';
|
||||
|
||||
// Plugin's components
|
||||
import EditForm from '../../components/EditForm';
|
||||
|
||||
import { getSettings, onCancel, onChange, setErrors, submit } from './actions';
|
||||
|
||||
import reducer from './reducer';
|
||||
import saga from './saga';
|
||||
import selectConfigPage from './selectors';
|
||||
|
||||
@ -57,9 +51,7 @@ class ConfigPage extends React.Component {
|
||||
|
||||
// Redirect the user to the email list after modifying is provider
|
||||
if (prevProps.submitSuccess !== this.props.submitSuccess) {
|
||||
this.props.history.push(
|
||||
`/plugins/email/configurations/${this.props.match.params.env}`
|
||||
);
|
||||
this.props.history.push(`/plugins/email/configurations/${this.props.match.params.env}`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,11 +93,7 @@ class ConfigPage extends React.Component {
|
||||
handleSubmit = e => {
|
||||
e.preventDefault();
|
||||
const formErrors = Object.keys(
|
||||
get(
|
||||
this.props.settings,
|
||||
['providers', this.getSelectedProviderIndex(), 'auth'],
|
||||
{}
|
||||
)
|
||||
get(this.props.settings, ['providers', this.getSelectedProviderIndex(), 'auth'], {})
|
||||
).reduce((acc, current) => {
|
||||
if (isEmpty(get(this.props.modifiedData, current, ''))) {
|
||||
acc.push({
|
||||
@ -140,10 +128,7 @@ class ConfigPage extends React.Component {
|
||||
})}
|
||||
title={{ label: formatMessage({ id: 'email.ConfigPage.title' }) }}
|
||||
/>
|
||||
<HeaderNav
|
||||
links={this.generateLinks()}
|
||||
style={{ marginTop: '4.6rem' }}
|
||||
/>
|
||||
<HeaderNav links={this.generateLinks()} style={{ marginTop: '4.6rem' }} />
|
||||
<EditForm
|
||||
didCheckErrors={this.props.didCheckErrors}
|
||||
formErrors={this.props.formErrors}
|
||||
@ -198,20 +183,8 @@ function mapDispatchToProps(dispatch) {
|
||||
|
||||
const mapStateToProps = selectConfigPage();
|
||||
|
||||
const withConnect = connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
);
|
||||
const withConnect = connect(mapStateToProps, mapDispatchToProps);
|
||||
|
||||
const withReducer = strapi.injectReducer({
|
||||
key: 'configPage',
|
||||
reducer,
|
||||
pluginId,
|
||||
});
|
||||
const withSaga = strapi.injectSaga({ key: 'configPage', saga, pluginId });
|
||||
|
||||
export default compose(
|
||||
withReducer,
|
||||
withSaga,
|
||||
withConnect
|
||||
)(ConfigPage);
|
||||
export default compose(withSaga, withConnect)(ConfigPage);
|
||||
|
||||
@ -11,6 +11,7 @@ import pluginLogo from './assets/images/logo.svg';
|
||||
import App from './containers/App';
|
||||
import Initializer from './containers/Initializer';
|
||||
import lifecycles from './lifecycles';
|
||||
import reducers from './reducers';
|
||||
import trads from './translations';
|
||||
|
||||
export default strapi => {
|
||||
@ -33,6 +34,7 @@ export default strapi => {
|
||||
name: pluginPkg.strapi.name,
|
||||
pluginLogo,
|
||||
preventComponentRendering: false,
|
||||
reducers,
|
||||
trads,
|
||||
};
|
||||
|
||||
|
||||
8
packages/strapi-plugin-email/admin/src/reducers.js
Normal file
8
packages/strapi-plugin-email/admin/src/reducers.js
Normal file
@ -0,0 +1,8 @@
|
||||
import configPageReducer from './containers/ConfigPage/reducer';
|
||||
import pluginId from './pluginId';
|
||||
|
||||
const reducers = {
|
||||
[`${pluginId}_configPage`]: configPageReducer,
|
||||
};
|
||||
|
||||
export default reducers;
|
||||
@ -51,8 +51,6 @@ import {
|
||||
|
||||
// Selectors
|
||||
import makeSelectEditPage from './selectors';
|
||||
|
||||
import reducer from './reducer';
|
||||
import saga from './saga';
|
||||
|
||||
import { Loader, Title, Separator, Wrapper } from './Components';
|
||||
@ -221,10 +219,7 @@ export class EditPage extends React.Component {
|
||||
label: formatMessage({ id: getTrad('EditPage.submit') }),
|
||||
onClick: this.handleSubmit,
|
||||
type: 'submit',
|
||||
disabled: isEqual(
|
||||
this.props.editPage.modifiedData,
|
||||
this.props.editPage.initialData
|
||||
),
|
||||
disabled: isEqual(this.props.editPage.modifiedData, this.props.editPage.initialData),
|
||||
key: 'button-submit',
|
||||
},
|
||||
];
|
||||
@ -240,9 +235,7 @@ export class EditPage extends React.Component {
|
||||
selectAllActions={this.props.selectAllActions}
|
||||
setInputPoliciesPath={this.props.setInputPoliciesPath}
|
||||
setShouldDisplayPolicieshint={this.props.setShouldDisplayPolicieshint}
|
||||
resetShouldDisplayPoliciesHint={
|
||||
this.props.resetShouldDisplayPoliciesHint
|
||||
}
|
||||
resetShouldDisplayPoliciesHint={this.props.resetShouldDisplayPoliciesHint}
|
||||
>
|
||||
<Wrapper>
|
||||
<BackHeader onClick={() => this.props.history.goBack()} />
|
||||
@ -256,11 +249,7 @@ export class EditPage extends React.Component {
|
||||
<FormattedMessage
|
||||
id={pluginHeaderDescription}
|
||||
values={{
|
||||
description: get(
|
||||
this.props.editPage.initialData,
|
||||
'description',
|
||||
''
|
||||
),
|
||||
description: get(this.props.editPage.initialData, 'description', ''),
|
||||
}}
|
||||
>
|
||||
{description => {
|
||||
@ -302,16 +291,11 @@ export class EditPage extends React.Component {
|
||||
)}
|
||||
{!this.showLoaderPermissions() && (
|
||||
<Plugins
|
||||
plugins={get(this.props.editPage, [
|
||||
'modifiedData',
|
||||
'permissions',
|
||||
])}
|
||||
plugins={get(this.props.editPage, ['modifiedData', 'permissions'])}
|
||||
/>
|
||||
)}
|
||||
<Policies
|
||||
shouldDisplayPoliciesHint={
|
||||
this.props.editPage.shouldDisplayPoliciesHint
|
||||
}
|
||||
shouldDisplayPoliciesHint={this.props.editPage.shouldDisplayPoliciesHint}
|
||||
inputSelectName={this.props.editPage.inputPoliciesPath}
|
||||
routes={this.props.editPage.routes}
|
||||
selectOptions={this.props.editPage.policies}
|
||||
@ -394,11 +378,7 @@ function mapDispatchToProps(dispatch) {
|
||||
}
|
||||
|
||||
const withConnect = connect(mapStateToProps, mapDispatchToProps);
|
||||
const withReducer = strapi.injectReducer({
|
||||
key: 'editPage',
|
||||
reducer,
|
||||
pluginId,
|
||||
});
|
||||
|
||||
const withSaga = strapi.injectSaga({ key: 'editPage', saga, pluginId });
|
||||
|
||||
export default compose(withReducer, withSaga, withConnect)(EditPage);
|
||||
export default compose(withSaga, withConnect)(EditPage);
|
||||
|
||||
@ -31,7 +31,6 @@ import {
|
||||
submit,
|
||||
unsetDataToEdit,
|
||||
} from './actions';
|
||||
import reducer from './reducer';
|
||||
import saga from './saga';
|
||||
import checkFormValidity from './checkFormValidity';
|
||||
|
||||
@ -99,8 +98,7 @@ export class HomePage extends React.Component {
|
||||
UNSAFE_componentWillUpdate(nextProps) {
|
||||
const allowedPaths = ['roles', 'providers', 'email-templates', 'advanced'];
|
||||
const shouldRedirect =
|
||||
allowedPaths.filter(el => el === nextProps.match.params.settingType)
|
||||
.length === 0;
|
||||
allowedPaths.filter(el => el === nextProps.match.params.settingType).length === 0;
|
||||
|
||||
if (shouldRedirect) {
|
||||
this.props.history.push('/404');
|
||||
@ -112,9 +110,7 @@ export class HomePage extends React.Component {
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
if (
|
||||
prevProps.match.params.settingType !== this.props.match.params.settingType
|
||||
) {
|
||||
if (prevProps.match.params.settingType !== this.props.match.params.settingType) {
|
||||
this.props.fetchData(this.props.match.params.settingType);
|
||||
}
|
||||
}
|
||||
@ -159,10 +155,7 @@ export class HomePage extends React.Component {
|
||||
this.getEndPoint(),
|
||||
this.props.dataToEdit,
|
||||
]);
|
||||
const initObject = get(this.props.initialData, [
|
||||
this.getEndPoint(),
|
||||
this.props.dataToEdit,
|
||||
]);
|
||||
const initObject = get(this.props.initialData, [this.getEndPoint(), this.props.dataToEdit]);
|
||||
const formErrors = checkFormValidity(
|
||||
this.props.match.params.settingType,
|
||||
modifiedObject,
|
||||
@ -189,12 +182,8 @@ export class HomePage extends React.Component {
|
||||
const { data, isLoading, modifiedData } = this.props;
|
||||
|
||||
return (
|
||||
(isLoading &&
|
||||
get(data, this.getEndPoint()) === undefined &&
|
||||
!this.isAdvanded()) ||
|
||||
(isLoading &&
|
||||
this.isAdvanded() &&
|
||||
get(modifiedData, this.getEndPoint()) === undefined)
|
||||
(isLoading && get(data, this.getEndPoint()) === undefined && !this.isAdvanded()) ||
|
||||
(isLoading && this.isAdvanded() && get(modifiedData, this.getEndPoint()) === undefined)
|
||||
);
|
||||
};
|
||||
|
||||
@ -212,13 +201,11 @@ export class HomePage extends React.Component {
|
||||
} = this.props;
|
||||
const { formatMessage } = this.context;
|
||||
const headerActions =
|
||||
match.params.settingType === 'advanced' &&
|
||||
!isEqual(modifiedData, initialData)
|
||||
match.params.settingType === 'advanced' && !isEqual(modifiedData, initialData)
|
||||
? this.pluginHeaderActions
|
||||
: [];
|
||||
const noButtonList =
|
||||
match.params.settingType === 'email-templates' ||
|
||||
match.params.settingType === 'providers';
|
||||
match.params.settingType === 'email-templates' || match.params.settingType === 'providers';
|
||||
const values = get(modifiedData, this.getEndPoint(), {});
|
||||
|
||||
return (
|
||||
@ -242,10 +229,7 @@ export class HomePage extends React.Component {
|
||||
})}
|
||||
actions={headerActions}
|
||||
/>
|
||||
<HeaderNav
|
||||
links={this.headerNavLinks}
|
||||
style={{ marginTop: '4.6rem' }}
|
||||
/>
|
||||
<HeaderNav links={this.headerNavLinks} style={{ marginTop: '4.6rem' }} />
|
||||
{!this.isAdvanded() ? (
|
||||
<List
|
||||
data={get(data, this.getEndPoint(), [])}
|
||||
@ -324,19 +308,8 @@ function mapDispatchToProps(dispatch) {
|
||||
|
||||
const mapStateToProps = selectHomePage();
|
||||
|
||||
const withConnect = connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
);
|
||||
const withReducer = strapi.injectReducer({
|
||||
key: 'homePage',
|
||||
reducer,
|
||||
pluginId,
|
||||
});
|
||||
const withConnect = connect(mapStateToProps, mapDispatchToProps);
|
||||
|
||||
const withSaga = strapi.injectSaga({ key: 'homePage', saga, pluginId });
|
||||
|
||||
export default compose(
|
||||
withReducer,
|
||||
withSaga,
|
||||
withConnect
|
||||
)(injectIntl(HomePage));
|
||||
export default compose(withSaga, withConnect)(injectIntl(HomePage));
|
||||
|
||||
@ -12,6 +12,7 @@ import pluginId from './pluginId';
|
||||
import App from './containers/App';
|
||||
import Initializer from './containers/Initializer';
|
||||
import lifecycles from './lifecycles';
|
||||
import reducers from './reducers';
|
||||
import trads from './translations';
|
||||
|
||||
export default strapi => {
|
||||
@ -34,6 +35,7 @@ export default strapi => {
|
||||
name: pluginPkg.strapi.name,
|
||||
pluginLogo,
|
||||
preventComponentRendering: false,
|
||||
reducers,
|
||||
settings: {},
|
||||
suffixUrl: () => '/roles',
|
||||
suffixUrlToReplaceForLeftMenuHighlight: '/roles',
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
import editPageReducer from './containers/EditPage/reducer';
|
||||
import homePageReducer from './containers/HomePage/reducer';
|
||||
import pluginId from './pluginId';
|
||||
|
||||
const reducers = {
|
||||
[`${pluginId}_editPage`]: editPageReducer,
|
||||
[`${pluginId}_homePage`]: homePageReducer,
|
||||
};
|
||||
|
||||
export default reducers;
|
||||
Loading…
x
Reference in New Issue
Block a user