diff --git a/client/coral-admin/src/routes/Configure/components/Configure.js b/client/coral-admin/src/routes/Configure/components/Configure.js index f61089080..b0bf5e064 100644 --- a/client/coral-admin/src/routes/Configure/components/Configure.js +++ b/client/coral-admin/src/routes/Configure/components/Configure.js @@ -19,33 +19,21 @@ export default class Configure extends Component { this.setState({activeSection}); } - getSection (section) { - let SectionComponent; + getSectionComponent(section) { switch(section){ case 'stream': - SectionComponent = StreamSettings; - break; + return StreamSettings; case 'moderation': - SectionComponent = ModerationSettings; - break; + return ModerationSettings; case 'tech': - SectionComponent = TechSettings; + return TechSettings; } - - return ( -
- -
- ); + throw new Error(`Unknown section ${section}`); } render () { const {activeSection} = this.state; - const section = this.getSection(activeSection); + const SectionComponent = this.getSectionComponent(activeSection); const {auth: {user}, canSave, savePending} = this.props; if (!can(user, 'UPDATE_CONFIG')) { @@ -92,7 +80,13 @@ export default class Configure extends Component {
- {section} +
+ +
); @@ -101,9 +95,6 @@ export default class Configure extends Component { Configure.propTypes = { notify: PropTypes.func.isRequired, - updateWordlist: PropTypes.func.isRequired, - updateSettings: PropTypes.func.isRequired, - errors: PropTypes.object.isRequired, savePending: PropTypes.func.isRequired, auth: PropTypes.object.isRequired, data: PropTypes.object.isRequired, diff --git a/client/coral-admin/src/routes/Configure/containers/Configure.js b/client/coral-admin/src/routes/Configure/containers/Configure.js index b0c276b5e..44c8d1c66 100644 --- a/client/coral-admin/src/routes/Configure/containers/Configure.js +++ b/client/coral-admin/src/routes/Configure/containers/Configure.js @@ -12,34 +12,12 @@ import {getErrorMessages, getDefinitionName} from 'coral-framework/utils'; import StreamSettings from './StreamSettings'; import TechSettings from './TechSettings'; import ModerationSettings from './ModerationSettings'; -import { - updatePending, - clearPending, -} from '../../../actions/configure'; +import {clearPending} from '../../../actions/configure'; import Configure from '../components/Configure'; class ConfigureContainer extends Component { - updateWordlist = (listName, list) => { - this.props.updatePending({updater: { - wordlist: {$apply: (wordlist) => { - const changeSet = {[listName]: list}; - if (!wordlist) { - return changeSet; - } - return { - ...wordlist, - ...changeSet, - }; - }}, - }}); - }; - - updateSettings = (settings, {setError = {}} = {}) => { - this.props.updatePending({updater: {$merge: settings}, errorUpdater: {$merge: setError}}); - }; - savePending = async () => { try { await this.props.updateSettings(this.props.pending); @@ -59,9 +37,6 @@ class ConfigureContainer extends Component { return ({ auth: state.auth, pending: state.configure.pending, canSave: state.configure.canSave, - errors: state.configure.errors, }); const mapDispatchToProps = (dispatch) => bindActionCreators({ notify, - updatePending, clearPending, }, dispatch); @@ -139,14 +89,12 @@ export default compose( )(ConfigureContainer); ConfigureContainer.propTypes = { - updatePending: PropTypes.func.isRequired, updateSettings: PropTypes.func.isRequired, clearPending: PropTypes.func.isRequired, notify: PropTypes.func.isRequired, auth: PropTypes.object.isRequired, data: PropTypes.object.isRequired, root: PropTypes.object.isRequired, - errors: PropTypes.object.isRequired, canSave: PropTypes.bool.isRequired, pending: PropTypes.object.isRequired, };