Init loader plugin users

This commit is contained in:
soupette 2018-06-13 22:12:11 +02:00
parent d9be6cb831
commit f52880e810
5 changed files with 20 additions and 16 deletions

View File

@ -29,8 +29,8 @@ function Sub({ bordered, content, link, name, style, title, underline }) {
<a className={cn(styles.subWrapper, bordered && styles.subBordered, styles.link)} href={`https://blog.strapi.io/${link}`} target="_blank">
<span>{title}</span>
{title === '' && <LoadingBar />}
{content === '' && <LoadingBar style={{ width: '40%' }} />}
<p style={style}>
{content === '' && <LoadingBar style={{ width: '40%' }} />}
{isFunction(content) ? content() : content}
</p>
</a>

View File

@ -1,4 +1,3 @@
<<<<<<< HEAD
{
"product": {
"attributes": {
@ -8,6 +7,3 @@
}
}
}
=======
{}
>>>>>>> ee56c16e3310bd254514b0f90df6aeb82c6940b3

View File

@ -96,6 +96,8 @@ export class HomePage extends React.Component {
this.props.resetProps();
}
getEndPoint = () => this.props.match.params.settingType;
handleKeyBoardShortCut = (e) => {
if (includes(keyBoardShortCuts, e.keyCode)) {
const mapKey = clone(this.state.mapKey);
@ -154,14 +156,14 @@ export class HomePage extends React.Component {
];
render() {
const { didCheckErrors, formErrors, modifiedData, initialData, match, dataToEdit } = this.props;
const { data, didCheckErrors, formErrors, modifiedData, initialData, match, dataToEdit } = this.props;
const headerActions = match.params.settingType === 'advanced' && !isEqual(modifiedData, initialData) ?
this.pluginHeaderActions : [];
const noButtonList = match.params.settingType === 'email-templates' || match.params.settingType === 'providers';
const component = match.params.settingType === 'advanced' ?
<EditForm onChange={this.props.onChange} values={modifiedData} /> : (
<List
data={this.props.data}
data={get(data, this.getEndPoint(), [])}
deleteData={this.props.deleteData}
noButton={noButtonList}
onButtonClick={this.handleButtonClick}
@ -169,7 +171,10 @@ export class HomePage extends React.Component {
values={modifiedData}
/>
);
console.log(this.props.match);
console.log(modifiedData)
console.log(this.props.endPoint);
return (
<div>
<form onSubmit={(e) => e.preventDefault()}>
@ -208,7 +213,7 @@ HomePage.defaultProps = {};
HomePage.propTypes = {
cancelChanges: PropTypes.func.isRequired,
data: PropTypes.array.isRequired,
data: PropTypes.object.isRequired,
dataToEdit: PropTypes.string.isRequired,
deleteData: PropTypes.func.isRequired,
didCheckErrors: PropTypes.bool.isRequired,

View File

@ -10,6 +10,7 @@ import {
CANCEL_CHANGES,
DELETE_DATA,
DELETE_DATA_SUCCEEDED,
FETCH_DATA,
FETCH_DATA_SUCCEEDED,
ON_CHANGE,
RESET_PROPS,
@ -21,16 +22,18 @@ import {
} from './constants';
const initialState = fromJS({
data: List([]),
data: fromJS({}),
dataToDelete: Map({}),
dataToEdit: '',
deleteEndPoint: '',
didCheckErrors: false,
formErrors: List([]),
initialData: Map({}),
isLoading: true,
modifiedData: Map({}),
showButtons: false,
didDeleteData: false,
endPoint: 'roles',
});
function homePageReducer(state = initialState, action) {
@ -49,11 +52,14 @@ function homePageReducer(state = initialState, action) {
.set('deleteEndPoint', '')
.set('dataToDelete', Map({}))
.update('didDeleteData', (v) => !v);
case FETCH_DATA:
return state
.update('endPoint', () => action.endPoint);
case FETCH_DATA_SUCCEEDED:
return state
.set('data', List(action.data))
.set('initialData', action.modifiedData)
.set('modifiedData', action.modifiedData);
.updateIn(['data', state.get('endPoint')], () => List(action.data))
.updateIn(['initialData', state.get('endPoint')], () => action.modifiedData)
.updateIn(['modifiedData', state.get('endPoint')], () => action.modifiedData);
case ON_CHANGE:
return state
.updateIn(action.keys, () => action.value);

View File

@ -17,9 +17,6 @@ import {
SUBMIT,
} from './constants';
// TODO uncomment to test design providers and so on...
// import data from './data.json';
import {
makeSelectAllData,
makeSelectDataToDelete,