From 957837169fb93ae9336b97653ecf166207fa36f4 Mon Sep 17 00:00:00 2001 From: David Jay Date: Thu, 1 Dec 2016 19:35:35 -0500 Subject: [PATCH] Moving configuration sections to seperate files. --- .../containers/Configure/CommentSettings.js | 65 +++++++++ .../src/containers/Configure/Configure.js | 124 ++++-------------- .../src/containers/Configure/EmbedLink.js | 49 +++++++ .../src/containers/Configure/Wordlist.js | 17 +++ client/coral-admin/src/translations.json | 1 + 5 files changed, 158 insertions(+), 98 deletions(-) create mode 100644 client/coral-admin/src/containers/Configure/CommentSettings.js create mode 100644 client/coral-admin/src/containers/Configure/EmbedLink.js create mode 100644 client/coral-admin/src/containers/Configure/Wordlist.js diff --git a/client/coral-admin/src/containers/Configure/CommentSettings.js b/client/coral-admin/src/containers/Configure/CommentSettings.js new file mode 100644 index 000000000..c6a53adbe --- /dev/null +++ b/client/coral-admin/src/containers/Configure/CommentSettings.js @@ -0,0 +1,65 @@ +import React from 'react'; +import I18n from 'coral-framework/modules/i18n/i18n'; +import translations from '../../translations.json'; +import styles from './Configure.css'; +import { + List, + ListItem, + ListItemContent, + ListItemAction, + Textfield, + Checkbox +} from 'react-mdl'; +import {updateSettings} from '../../actions/settings'; + +const updateModeration = (props) => () => { + const moderation = props.settings.moderation === 'pre' ? 'post' : 'pre'; + props.dispatch(updateSettings({moderation})); +}; + +const updateInfoBoxEnable = (props) => () => { + const infoBoxEnable = !props.settings.infoBoxEnable; + props.dispatch(updateSettings({infoBoxEnable})); +}; + +const updateInfoBoxContent = (props) => (event) => { + const infoBoxContent = event.target.value; + props.dispatch(updateSettings({infoBoxContent})); +}; + +const StateLess = (props) => + + + + + {lang.t('configure.enable-pre-moderation')} + + + + + + + {lang.t('configure.include-comment-stream')} +

+ {lang.t('configure.include-comment-stream-desc')} +

+
+
+ + + + + +
; + +export default StateLess; + +const lang = new I18n(translations); diff --git a/client/coral-admin/src/containers/Configure/Configure.js b/client/coral-admin/src/containers/Configure/Configure.js index 93935a630..4ff268c78 100644 --- a/client/coral-admin/src/containers/Configure/Configure.js +++ b/client/coral-admin/src/containers/Configure/Configure.js @@ -5,30 +5,20 @@ import { List, ListItem, ListItemContent, - ListItemAction, - Textfield, - Checkbox, Button, Icon } from 'react-mdl'; import styles from './Configure.css'; import I18n from 'coral-framework/modules/i18n/i18n'; import translations from '../../translations.json'; +import EmbedLink from './EmbedLink'; +import CommentSettings from './CommentSettings'; class Configure extends React.Component { constructor (props) { super(props); - this.state = {activeSection: 'comments', copied: false}; - - this.copyToClipBoard = this.copyToClipBoard.bind(this); - - // Update settings - this.updateModeration = this.updateModeration.bind(this); - // InfoBox has two settings. Enable or not and the content of it if it is enable. - this.updateInfoBoxEnable = this.updateInfoBoxEnable.bind(this); - this.updateInfoBoxContent = this.updateInfoBoxContent.bind(this); - + this.state = {activeSection: 'comments'}; this.saveSettings = this.saveSettings.bind(this); } @@ -36,95 +26,37 @@ class Configure extends React.Component { this.props.dispatch(fetchSettings()); } - updateModeration () { - const moderation = this.props.settings.moderation === 'pre' ? 'post' : 'pre'; - this.props.dispatch(updateSettings({moderation})); - } - - updateInfoBoxEnable () { - const infoBoxEnable = !this.props.settings.infoBoxEnable; - this.props.dispatch(updateSettings({infoBoxEnable})); - } - - updateInfoBoxContent (event) { - const infoBoxContent = event.target.value; - this.props.dispatch(updateSettings({infoBoxContent})); - } - saveSettings () { this.props.dispatch(saveSettingsToServer()); } - getCommentSettings () { - return - - - - - {lang.t('configure.enable-pre-moderation')} - - - - - - - {lang.t('configure.include-comment-stream')} -

- {lang.t('configure.include-comment-stream-desc')} -

-
-
- - - - - -
; - } - - copyToClipBoard () { - const copyTextarea = document.querySelector(`.${ styles.embedInput}`); - copyTextarea.select(); - - try { - document.execCommand('copy'); - this.setState({copied: true}); - } catch (err) { - console.error('Unable to copy', err); - } - } - - getEmbed () { - const embedText = `
`; - - return - -

{lang.t('configure.copy-and-paste')}

-