From 123ba07b6342ec452cdc6c7274876bdf19b396e5 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Mon, 19 Dec 2016 16:43:00 -0700 Subject: [PATCH] add tag package to simplify wordlist ui --- .../src/containers/Configure/Configure.js | 33 ++++-------- .../src/containers/Configure/Wordlist.js | 30 +++++------ client/coral-admin/src/reducers/settings.js | 2 +- package.json | 1 + views/admin.ejs | 50 +++++++++++++++++++ 5 files changed, 77 insertions(+), 39 deletions(-) diff --git a/client/coral-admin/src/containers/Configure/Configure.js b/client/coral-admin/src/containers/Configure/Configure.js index 1f31807ff..c45297af4 100644 --- a/client/coral-admin/src/containers/Configure/Configure.js +++ b/client/coral-admin/src/containers/Configure/Configure.js @@ -19,6 +19,7 @@ import translations from '../../translations.json'; import EmbedLink from './EmbedLink'; import CommentSettings from './CommentSettings'; import Wordlist from './Wordlist'; +import has from 'lodash/has'; class Configure extends React.Component { constructor (props) { @@ -26,8 +27,6 @@ class Configure extends React.Component { this.state = { activeSection: 'comments', - banned: [], - suspect: [], changed: false, errors: {} }; @@ -37,18 +36,6 @@ class Configure extends React.Component { this.props.dispatch(fetchSettings()); } - componentWillUpdate = (newProps) => { - if ((!this.props.settings - || !this.props.settings.wordlist) - && newProps.settings.wordlist - && newProps.settings.wordlist.length !== 0 ) { - this.setState({ - banned: newProps.settings.wordlist.banned.join(', '), - suspect: newProps.settings.wordlist.suspect.join(', ') - }); - } - } - saveSettings = () => { this.props.dispatch(saveSettingsToServer()); this.setState({changed: false}); @@ -58,11 +45,8 @@ class Configure extends React.Component { this.setState({activeSection}); } - onChangeWordlist = (event, list) => { - event.preventDefault(); - const newlist = event.target.value.toLowerCase(); - this.setState({[list]: newlist, changed: true}); - this.props.dispatch(updateWordlist(list, newlist.split(',').map(word => word.trim()) )); + onChangeWordlist = (listName, list) => { + this.props.dispatch(updateWordlist(listName, list)); } onSettingUpdate = (setting) => { @@ -81,6 +65,7 @@ class Configure extends React.Component { getSection (section) { const pageTitle = this.getPageTitle(section); + console.log('getSection', this.props); switch(section){ case 'comments': return ; case 'wordlist': - return ; + return has(this, 'props.settings.wordlist') + ? + :

loading wordlists

; } } diff --git a/client/coral-admin/src/containers/Configure/Wordlist.js b/client/coral-admin/src/containers/Configure/Wordlist.js index ad7db36a5..29f3f67fc 100644 --- a/client/coral-admin/src/containers/Configure/Wordlist.js +++ b/client/coral-admin/src/containers/Configure/Wordlist.js @@ -1,10 +1,14 @@ import React from 'react'; import I18n from 'coral-framework/modules/i18n/i18n'; import translations from '../../translations.json'; +import TagsInput from 'react-tagsinput'; +import tagStyles from 'react-tagsinput/react-tagsinput.css'; + import styles from './Configure.css'; -import { - Card -} from 'react-mdl'; + +import {Card} from 'react-mdl'; + +console.log('tagStyles', tagStyles); const Wordlist = ({suspectWords, bannedWords, onChangeWordlist}) => (
@@ -12,23 +16,19 @@ const Wordlist = ({suspectWords, bannedWords, onChangeWordlist}) => (

{lang.t('configure.banned-word-header')}

{lang.t('configure.banned-word-text')}

-