Change users-permissions hp reducer

This commit is contained in:
soupette 2018-06-14 11:35:40 +02:00
parent f52880e810
commit dee1ecd23f
7 changed files with 19 additions and 15 deletions

View File

@ -185,6 +185,10 @@ export class AdminPage extends React.Component {
const header = this.showLeftMenu() ? <Header /> : '';
const style = this.showLeftMenu() ? {} : { width: '100%' };
if (adminPage.isLoading) {
return <div />;
}
return (
<div className={styles.adminPage}>
{this.showLeftMenu() && (

View File

@ -16,6 +16,7 @@ import {
const initialState = fromJS({
allowGa: true,
currentEnvironment: 'development',
isLoading: true,
layout: Map({}),
strapiVersion: '3',
});
@ -23,7 +24,9 @@ const initialState = fromJS({
function adminPageReducer(state = initialState, action) {
switch (action.type) {
case GET_CURR_ENV_SUCCEEDED:
return state.update('currentEnvironment', () => action.currentEnvironment);
return state
.update('isLoading', () => false)
.update('currentEnvironment', () => action.currentEnvironment);
case GET_GA_STATUS_SUCCEEDED:
return state.update('allowGa', () => action.allowGa);
case GET_LAYOUT_SUCCEEDED:

View File

@ -5,7 +5,7 @@ export default function checkAttributeValidations(errors) {
const attributeIndex = split(this.props.hash, '::')[3];
const sameAttributes = filter(this.props.contentTypeData.attributes, (attr) => attr.name === this.props.modifiedDataAttribute.name);
const sameParamsKey = filter(this.props.contentTypeData.attributes, (attr) =>
attr.params.key === this.props.modifiedDataAttribute.params.key && attr.params.target === this.props.modifiedDataAttribute.params.target);
attr.params.key !== '-' && attr.params.key === this.props.modifiedDataAttribute.params.key && attr.params.target === this.props.modifiedDataAttribute.params.target);
const sameParamsKeyAndName = filter(this.props.contentTypeData.attributes, (attr) => attr.name === this.props.modifiedDataAttribute.params.key);
const formErrors = concat(errors, hasNestedValue(this.props.modifiedDataAttribute));
const isEditingParamsKey = this.props.modifiedDataAttribute.params.key !== get(this.props.contentTypeData.attributes, [attributeIndex, 'params', 'key']);

View File

@ -104,7 +104,7 @@ class PopUpForm extends React.Component { // eslint-disable-line react/prefer-st
<Input
inputDescription={{ id: 'users-permissions.PopUpForm.Providers.enabled.description' }}
label={{ id: 'users-permissions.PopUpForm.Providers.enabled.label' }}
name={`${dataToEdit}.enabled`}
name={`${settingType}.${dataToEdit}.enabled`}
onChange={this.handleChange}
type="toggle"
validations={{}}
@ -121,7 +121,7 @@ class PopUpForm extends React.Component { // eslint-disable-line react/prefer-st
errors={get(this.props.formErrors, [findIndex(this.props.formErrors, ['name', value]), 'errors'], [])}
key={value}
label={{ id: `users-permissions.PopUpForm.Providers.${ includes(value, 'callback') || includes(value, 'redirect_uri') ? 'redirectURL.front-end' : value}.label` }}
name={`${dataToEdit}.${value}`}
name={`${settingType}.${dataToEdit}.${value}`}
onFocus={includes(value, 'callback') || includes(value, 'redirect_uri') ? this.handleFocus : () => {}}
onBlur={includes(value, 'callback') || includes(value, 'redirect_uri') ? this.handleBlur : false}
onChange={this.props.onChange}
@ -163,7 +163,7 @@ class PopUpForm extends React.Component { // eslint-disable-line react/prefer-st
didCheckErrors={this.props.didCheckErrors}
errors={get(this.props.formErrors, [findIndex(this.props.formErrors, ['name', value]), 'errors'], [])}
label={{ id: `users-permissions.PopUpForm.Email.${value}.label` }}
name={`${dataToEdit}.${value}`}
name={`${settingType}.${dataToEdit}.${value}`}
onChange={this.props.onChange}
placeholder={`users-permissions.PopUpForm.Email.${value}.placeholder`}
type={includes(value, 'email') ? 'email' : 'text'}
@ -179,7 +179,7 @@ class PopUpForm extends React.Component { // eslint-disable-line react/prefer-st
didCheckErrors={this.props.didCheckErrors}
errors={get(this.props.formErrors, [findIndex(this.props.formErrors, ['name', value]), 'errors'], [])}
label={{ id: `users-permissions.PopUpForm.Email.${value}.label` }}
name={`${dataToEdit}.${value}`}
name={`${settingType}.${dataToEdit}.${value}`}
inputDescription={{
id: includes(value, 'object') ? 'users-permissions.PopUpForm.Email.email_templates.inputDescription' : '',
params,

View File

@ -124,8 +124,8 @@ export class HomePage extends React.Component {
handleSubmit = (e) => {
e.preventDefault();
const modifiedObject = get(this.props.modifiedData, this.props.dataToEdit);
const initObject = get(this.props.initialData, this.props.dataToEdit);
const modifiedObject = get(this.props.modifiedData, [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, this.props.dataToEdit);
if (isEqual(initObject, modifiedObject)) {
@ -168,13 +168,10 @@ export class HomePage extends React.Component {
noButton={noButtonList}
onButtonClick={this.handleButtonClick}
settingType={match.params.settingType}
values={modifiedData}
values={get(modifiedData, this.getEndPoint(), {})}
/>
);
console.log(this.props.match);
console.log(modifiedData)
console.log(this.props.endPoint);
return (
<div>
<form onSubmit={(e) => e.preventDefault()}>
@ -196,7 +193,7 @@ export class HomePage extends React.Component {
onChange={this.props.onChange}
onSubmit={this.handleSubmit}
settingType={match.params.settingType}
values={modifiedData[dataToEdit] || {}}
values={get(modifiedData,[this.getEndPoint(), dataToEdit], {})}
/>
</form>
</div>

View File

@ -48,7 +48,7 @@ function homePageReducer(state = initialState, action) {
.set('deleteEndPoint', action.deleteEndPoint);
case DELETE_DATA_SUCCEEDED:
return state
.update('data', list => list.splice(action.indexDataToDelete, 1))
.updateIn(['data', state.get('endPoint')], list => list.splice(action.indexDataToDelete, 1))
.set('deleteEndPoint', '')
.set('dataToDelete', Map({}))
.update('didDeleteData', (v) => !v);

View File

@ -28,8 +28,8 @@ export function* dataDelete() {
try {
const allData = yield select(makeSelectAllData());
const dataToDelete = yield select(makeSelectDataToDelete());
const indexDataToDelete = findIndex(allData, ['name', dataToDelete.name]);
const endPointAPI = yield select(makeSelectDeleteEndPoint());
const indexDataToDelete = findIndex(allData[endPointAPI], ['name', dataToDelete.name]);
if (indexDataToDelete !== -1) {
const id = dataToDelete.id;