2017-11-07 14:32:31 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* EditPage
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
import React from 'react';
|
2017-11-07 16:33:15 +01:00
|
|
|
import PropTypes from 'prop-types';
|
2017-11-07 14:32:31 +01:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { createStructuredSelector } from 'reselect';
|
|
|
|
import { bindActionCreators, compose } from 'redux';
|
2017-11-07 16:33:15 +01:00
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
import { get } from 'lodash';
|
|
|
|
import cn from 'classnames';
|
|
|
|
|
|
|
|
// Design
|
|
|
|
import BackHeader from 'components/BackHeader';
|
|
|
|
import Input from 'components/Input';
|
|
|
|
import InputSearch from 'components/InputSearch';
|
|
|
|
import PluginHeader from 'components/PluginHeader';
|
2017-11-07 14:32:31 +01:00
|
|
|
|
|
|
|
import injectSaga from 'utils/injectSaga';
|
|
|
|
import injectReducer from 'utils/injectReducer';
|
2017-11-07 16:33:15 +01:00
|
|
|
|
|
|
|
// Actions
|
|
|
|
import {
|
|
|
|
onCancel,
|
|
|
|
onChangeInput,
|
|
|
|
} from './actions';
|
|
|
|
|
|
|
|
// Selectors
|
2017-11-07 14:32:31 +01:00
|
|
|
import makeSelectEditPage from './selectors';
|
2017-11-07 16:33:15 +01:00
|
|
|
|
2017-11-07 14:32:31 +01:00
|
|
|
import reducer from './reducer';
|
|
|
|
import saga from './saga';
|
|
|
|
|
2017-11-07 16:33:15 +01:00
|
|
|
import styles from './styles.scss';
|
|
|
|
|
2017-11-07 14:32:31 +01:00
|
|
|
export class EditPage extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
2017-11-07 16:33:15 +01:00
|
|
|
pluginHeaderActions = [
|
|
|
|
{
|
|
|
|
label: 'users-permissions.EditPage.cancel',
|
|
|
|
kind: 'secondary',
|
|
|
|
onClick: this.props.onCancel,
|
|
|
|
type: 'button',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
kind: 'primary',
|
|
|
|
label: 'users-permissions.EditPage.submit',
|
|
|
|
onClick: () => console.log('submit'),
|
|
|
|
type: 'submit',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2017-11-07 14:32:31 +01:00
|
|
|
render() {
|
2017-11-07 16:33:15 +01:00
|
|
|
const pluginHeaderTitle = this.props.match.params.id === 'create' ?
|
|
|
|
'users-permissions.EditPage.header.title.create'
|
|
|
|
: 'users-permissions.EditPage.header.title';
|
|
|
|
const pluginHeaderDescription = this.props.match.params.id === 'create' ?
|
|
|
|
'users-permissions.EditPage.header.description.create'
|
|
|
|
: 'users-permissions.EditPage.header.description';
|
|
|
|
|
|
|
|
const pluginHeaderActions = this.props.editPage.showButtons ? this.pluginHeaderActions : [];
|
2017-11-07 14:32:31 +01:00
|
|
|
return (
|
|
|
|
<div>
|
2017-11-07 16:33:15 +01:00
|
|
|
<BackHeader onClick={() => this.props.history.goBack()} />
|
|
|
|
<div className={cn('container-fluid', styles.containerFluid)}>
|
|
|
|
<PluginHeader
|
|
|
|
title={{
|
|
|
|
id: pluginHeaderTitle,
|
|
|
|
values: {
|
|
|
|
name: '',
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
description={{
|
|
|
|
id: pluginHeaderDescription,
|
|
|
|
values: {
|
|
|
|
description: '',
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
actions={pluginHeaderActions}
|
|
|
|
/>
|
|
|
|
<div className="row">
|
|
|
|
<div className="col-md-12">
|
|
|
|
<div className={styles.main_wrapper}>
|
|
|
|
<div className={styles.titleContainer}>
|
|
|
|
<FormattedMessage id="users-permissions.EditPage.form.roles" />
|
|
|
|
</div>
|
|
|
|
<form className={styles.form}>
|
|
|
|
<div className="row">
|
|
|
|
<div className="col-md-6">
|
|
|
|
<div className="row">
|
|
|
|
<Input
|
|
|
|
customBootstrapClass="col-md-12"
|
|
|
|
label="users-permissions.EditPage.form.roles.label.name"
|
|
|
|
name="name"
|
|
|
|
onChange={this.props.onChangeInput}
|
|
|
|
type="text"
|
|
|
|
validations={{ required: true }}
|
|
|
|
value={get(this.props.editPage, ['modifiedData', 'name'])}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="row">
|
|
|
|
<Input
|
|
|
|
customBootstrapClass="col-md-12"
|
|
|
|
label="users-permissions.EditPage.form.roles.label.description"
|
|
|
|
name="description"
|
|
|
|
onChange={this.props.onChangeInput}
|
|
|
|
type="textarea"
|
|
|
|
validations={{ required: true }}
|
|
|
|
value={get(this.props.editPage, ['modifiedData', 'description'])}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<InputSearch
|
|
|
|
label="users-permissions.EditPage.form.roles.label.users"
|
|
|
|
labelValues={{ number: 0 }}
|
|
|
|
onChange={() => console.log('change')}
|
|
|
|
type="text"
|
|
|
|
validations={{ required: true }}
|
|
|
|
value=""
|
|
|
|
name="users"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2017-11-07 14:32:31 +01:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EditPage.propTypes = {
|
2017-11-07 16:33:15 +01:00
|
|
|
history: PropTypes.object.isRequired,
|
|
|
|
onCancel: PropTypes.func.isRequired,
|
|
|
|
onChangeInput: PropTypes.func.isRequired,
|
2017-11-07 14:32:31 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
const mapStateToProps = createStructuredSelector({
|
2017-11-07 16:33:15 +01:00
|
|
|
editPage: makeSelectEditPage(),
|
2017-11-07 14:32:31 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
function mapDispatchToProps(dispatch) {
|
|
|
|
return bindActionCreators(
|
2017-11-07 16:33:15 +01:00
|
|
|
{
|
|
|
|
onCancel,
|
|
|
|
onChangeInput,
|
|
|
|
},
|
|
|
|
dispatch,
|
2017-11-07 14:32:31 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
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 });
|
|
|
|
|
|
|
|
export default compose(
|
|
|
|
withReducer,
|
|
|
|
withSaga,
|
|
|
|
withConnect,
|
|
|
|
)(EditPage);
|