From b92ea72b789d8e120d33691050da9f0452fabc82 Mon Sep 17 00:00:00 2001 From: David Jay Date: Thu, 2 Mar 2017 16:44:36 -0500 Subject: [PATCH 01/14] Re-enabling premod links in settings. --- .../components/ConfigureCommentStream.js | 12 ++++++++++++ .../containers/ConfigureStreamContainer.js | 18 +++++++++--------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/client/coral-configure/components/ConfigureCommentStream.js b/client/coral-configure/components/ConfigureCommentStream.js index d80e487de..348d26f53 100644 --- a/client/coral-configure/components/ConfigureCommentStream.js +++ b/client/coral-configure/components/ConfigureCommentStream.js @@ -34,6 +34,18 @@ export default ({handleChange, handleApply, changed, updateQuestionBoxContent, . description: lang.t('configureCommentStream.enablePremodDescription') }} /> +
  • + +
  • @@ -88,11 +88,11 @@ class ConfigureStreamContainer extends Component { handleChange={this.handleChange} handleApply={this.handleApply} changed={this.state.changed} - premodLinks={false} + premodLinks={settings.premodLinks} premod={premod} updateQuestionBoxContent={this.updateQuestionBoxContent} - questionBoxEnable={questionBoxEnable} - questionBoxContent={questionBoxContent} + questionBoxEnable={settings.questionBoxEnable} + questionBoxContent={settings.questionBoxContent} />

    {status === 'open' ? 'Close' : 'Open'} Comment Stream

    From cb88f0a9b79c91d2e0fb3b1a82f18d7046002e1a Mon Sep 17 00:00:00 2001 From: David Jay Date: Fri, 3 Mar 2017 14:32:57 -0500 Subject: [PATCH 02/14] Flagging links when settings are set appropriately. --- .../containers/ConfigureStreamContainer.js | 4 ++-- graph/mutators/comment.js | 24 +++++++++++++++---- graph/typeDefs.graphql | 1 + models/setting.js | 4 ++++ 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/client/coral-configure/containers/ConfigureStreamContainer.js b/client/coral-configure/containers/ConfigureStreamContainer.js index 35942288e..a621f0cbd 100644 --- a/client/coral-configure/containers/ConfigureStreamContainer.js +++ b/client/coral-configure/containers/ConfigureStreamContainer.js @@ -31,14 +31,14 @@ class ConfigureStreamContainer extends Component { const questionBoxEnable = elements.qboxenable.checked; const questionBoxContent = elements.qboxcontent.value; - const premodLinks = elements.premodLinks.checked; + const premodLinksEnable = elements.premodLinks.checked; const {changed} = this.state; const newConfig = { moderation: premod ? 'PRE' : 'POST', questionBoxEnable, questionBoxContent, - premodLinks + premodLinksEnable }; if (changed) { diff --git a/graph/mutators/comment.js b/graph/mutators/comment.js index d608eee57..73510d67a 100644 --- a/graph/mutators/comment.js +++ b/graph/mutators/comment.js @@ -54,13 +54,16 @@ const createComment = ({user, loaders: {Comments}}, {body, asset_id, parent_id = * @param {String} body body of a comment * @return {Object} resolves to the wordlist results */ -const filterNewComment = (context, {body}) => { +const filterNewComment = (context, {body, asset_id}) => { // Create a new instance of the Wordlist. const wl = new Wordlist(); // Load the wordlist and filter the comment content. - return wl.load().then(() => wl.scan('body', body)); + return Promise.all([ + wl.load().then(() => wl.scan('body', body)), + AssetsService.rectifySettings(AssetsService.findById(asset_id)) + ]); }; /** @@ -131,13 +134,13 @@ const createPublicComment = (context, commentInput) => { // We then take the wordlist and the comment into consideration when // considering what status to assign the new comment, and resolve the new // status to set the comment to. - .then((wordlist) => resolveNewCommentStatus(context, commentInput, wordlist) + .then(([wordlist, settings]) => resolveNewCommentStatus(context, commentInput, wordlist) // Then we actually create the comment with the new status. .then((status) => createComment(context, commentInput, status)) .then((comment) => { - // If the comment was flagged as being suspect, we need to add a + // If the comment has a suspect word or a link, we need to add a // flag to it to indicate that it needs to be looked at. // Otherwise just return the new comment. @@ -158,6 +161,19 @@ const createPublicComment = (context, commentInput) => { .then(() => comment); } + // If the comment contains a link. + if (settings.premodLinksEnable && /\S+\.\S+/.exec(comment.body)) { + return ActionsService.insertUserAction({ + item_id: comment.id, + item_type: 'COMMENTS', + action_type: 'FLAG', + user_id: null, + group_id: 'Contains link', + metadata: {} + }) + .then(() => comment); + } + // Finally, we return the comment. return comment; })); diff --git a/graph/typeDefs.graphql b/graph/typeDefs.graphql index 92f0d41e2..2777e7bdb 100644 --- a/graph/typeDefs.graphql +++ b/graph/typeDefs.graphql @@ -370,6 +370,7 @@ type Settings { infoBoxEnable: Boolean infoBoxContent: String + premodLinksEnable: Boolean questionBoxEnable: Boolean questionBoxContent: String closeTimeout: Int diff --git a/models/setting.js b/models/setting.js index 993384ff1..ac54584a4 100644 --- a/models/setting.js +++ b/models/setting.js @@ -40,6 +40,10 @@ const SettingSchema = new Schema({ type: String, default: '' }, + premodLinksEnable: { + type: Boolean, + default: false + }, organizationName: { type: String }, From a1a45a7969d7ea7f3c9b547c962d939d78253fe6 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Fri, 3 Mar 2017 15:10:15 -0500 Subject: [PATCH 03/14] Styles and disable and enable things --- .../src/containers/Configure/Configure.css | 17 +++++++++++------ .../src/containers/Configure/StreamSettings.js | 15 ++++++++++----- client/coral-admin/src/translations.json | 4 ++-- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/client/coral-admin/src/containers/Configure/Configure.css b/client/coral-admin/src/containers/Configure/Configure.css index 058ff7a64..54deadccf 100644 --- a/client/coral-admin/src/containers/Configure/Configure.css +++ b/client/coral-admin/src/containers/Configure/Configure.css @@ -41,7 +41,9 @@ .settingsHeader { margin-top: 3px; - margin-bottom: 10px; + margin-bottom: 7px; + font-size: 18px; + font-weight: 500; } .disabledSettingText { @@ -58,11 +60,6 @@ overflow: visible; } -.configSettingInfoBox p { - font-size: 12px; - bottom: 0; -} - .configSettingEmbed { border: 1px solid #ccc; border-radius: 4px; @@ -170,3 +167,11 @@ padding-left: 30px; } } + + +.Configure { + p { + line-height: 1.2; + max-width: 600px; + } +} diff --git a/client/coral-admin/src/containers/Configure/StreamSettings.js b/client/coral-admin/src/containers/Configure/StreamSettings.js index 568e0a075..bd4111006 100644 --- a/client/coral-admin/src/containers/Configure/StreamSettings.js +++ b/client/coral-admin/src/containers/Configure/StreamSettings.js @@ -64,7 +64,7 @@ const StreamSettings = ({updateSettings, settingsError, settings, errors}) => { const off = styles.disabledSetting; return ( -
    +
    { className={`${styles.charCountTexfield} ${settings.charCountEnable && styles.charCountTexfieldEnabled}`} htmlFor='charCount' onChange={updateCharCount(updateSettings, settingsError)} - value={settings.charCount}/> + value={settings.charCount} + disabled={settings.charCountEnable ? '' : 'disabled'} + /> {lang.t('configure.comment-count-text-post')} { errors.charCount && @@ -99,8 +101,10 @@ const StreamSettings = ({updateSettings, settingsError, settings, errors}) => { checked={settings.infoBoxEnable} />
    - {lang.t('configure.include-comment-stream')} -

    +

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

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

    @@ -109,7 +113,8 @@ const StreamSettings = ({updateSettings, settingsError, settings, errors}) => { onChange={updateInfoBoxContent(updateSettings)} value={settings.infoBoxContent} label={lang.t('configure.include-text')} - rows={3}/> + rows={3} + />
    diff --git a/client/coral-admin/src/translations.json b/client/coral-admin/src/translations.json index cebc499ca..686001f6a 100644 --- a/client/coral-admin/src/translations.json +++ b/client/coral-admin/src/translations.json @@ -63,7 +63,7 @@ "enable-pre-moderation-text": "Moderators must approve any comment before it is published.", "require-email-verification": "Require Email Verification", "require-email-verification-text": "New Users must verify their email before commenting", - "include-comment-stream": "Include Comment Stream Description for Readers.", + "include-comment-stream": "Include Comment Stream Description for Readers", "include-comment-stream-desc": "Write a message to be added to the top of your comment stream. Pose a topic, include community guidelines, etc.", "include-text": "Include your text here.", "comment-settings": "Settings", @@ -87,7 +87,7 @@ "close-after": "Close comments after", "comment-count-header": "Limit Comment Length", "comment-count-text-pre": "Comments will be limited to ", - "comment-count-text-post": " characters.", + "comment-count-text-post": " characters", "comment-count-error": "Please enter a valid number.", "domain-list-title": "Permitted Domains", "domain-list-text": "Enter the domains you would like to permit for Talk, e.g. your local, staging and production environments (ex. localhost:3000, staging.domain.com, domain.com)." From 2e5d453ea7eb32415aa4cb32a6597f43557b9628 Mon Sep 17 00:00:00 2001 From: David Jay Date: Fri, 3 Mar 2017 15:44:03 -0500 Subject: [PATCH 04/14] Updating link search and adding settings in admin panel. --- .../src/containers/Configure/StreamSettings.js | 18 ++++++++++++++++++ .../ModerationQueue/components/Comment.js | 1 + client/coral-admin/src/translations.json | 2 ++ graph/mutators/comment.js | 3 ++- package.json | 1 + 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/client/coral-admin/src/containers/Configure/StreamSettings.js b/client/coral-admin/src/containers/Configure/StreamSettings.js index 568e0a075..950c5a2aa 100644 --- a/client/coral-admin/src/containers/Configure/StreamSettings.js +++ b/client/coral-admin/src/containers/Configure/StreamSettings.js @@ -32,6 +32,11 @@ const updateInfoBoxEnable = (updateSettings, infoBox) => () => { updateSettings({infoBoxEnable}); }; +const updatePremodLinksEnable = (updateSettings, premodLinks) => () => { + const premodLinksEnable = !premodLinks; + updateSettings({premodLinksEnable}); +}; + const updateInfoBoxContent = (updateSettings) => (event) => { const infoBoxContent = event.target.value; updateSettings({infoBoxContent}); @@ -92,6 +97,19 @@ const StreamSettings = ({updateSettings, settingsError, settings, errors}) => {

    + +
    + +
    +
    + {lang.t('configure.enable-premod-links')} +

    + {lang.t('configure.enable-premod-links-text')} +

    +
    +
    { const links = linkify.getMatches(props.comment.body); + console.log('Links', links); const actionSummaries = props.comment.action_summaries; return (
  • { } // If the comment contains a link. - if (settings.premodLinksEnable && /\S+\.\S+/.exec(comment.body)) { + if (settings.premodLinksEnable && linkify.test(comment.body)) { return ActionsService.insertUserAction({ item_id: comment.id, item_type: 'COMMENTS', diff --git a/package.json b/package.json index 740063dd1..6f0fd24c1 100644 --- a/package.json +++ b/package.json @@ -70,6 +70,7 @@ "inquirer": "^3.0.1", "jsonwebtoken": "^7.1.9", "kue": "^0.11.5", + "linkify-it": "^2.0.3", "lodash": "^4.16.6", "metascraper": "^1.0.6", "minimist": "^1.2.0", From 1f0d102115f2619689ee5ac03975e80003cb5a63 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Fri, 3 Mar 2017 15:53:53 -0500 Subject: [PATCH 05/14] new components!! textarea stuff and configure bugs --- .../src/containers/Configure/Configure.css | 11 ++++++++++ .../containers/Configure/StreamSettings.js | 20 +++++++++---------- client/coral-ui/components/TextArea.css | 15 ++++++++++++++ client/coral-ui/components/TextArea.js | 14 +++++++++++++ client/coral-ui/index.js | 2 ++ 5 files changed, 51 insertions(+), 11 deletions(-) create mode 100644 client/coral-ui/components/TextArea.css create mode 100644 client/coral-ui/components/TextArea.js diff --git a/client/coral-admin/src/containers/Configure/Configure.css b/client/coral-admin/src/containers/Configure/Configure.css index 54deadccf..c262b01d3 100644 --- a/client/coral-admin/src/containers/Configure/Configure.css +++ b/client/coral-admin/src/containers/Configure/Configure.css @@ -78,6 +78,8 @@ border-color: #ccc; border-style: solid; border-width: 0px 0px 1px 0px; + font-size: 14px; + text-align: center; } .charCountTexfieldEnabled { @@ -174,4 +176,13 @@ line-height: 1.2; max-width: 600px; } + + .descriptionBox { + margin-top: 15px; + max-width: 550px; + + input { + height: 150px; + } + } } diff --git a/client/coral-admin/src/containers/Configure/StreamSettings.js b/client/coral-admin/src/containers/Configure/StreamSettings.js index bd4111006..c4f01f4bc 100644 --- a/client/coral-admin/src/containers/Configure/StreamSettings.js +++ b/client/coral-admin/src/containers/Configure/StreamSettings.js @@ -3,8 +3,8 @@ import {SelectField, Option} from 'react-mdl-selectfield'; import I18n from 'coral-framework/modules/i18n/i18n'; import translations from '../../translations.json'; import styles from './Configure.css'; -import {Textfield, Checkbox} from 'react-mdl'; -import {Card, Icon} from 'coral-ui'; +import {Checkbox} from 'react-mdl'; +import {Card, Icon, TextArea, Textfield} from 'coral-ui'; const TIMESTAMPS = { weeks: 60 * 60 * 24 * 7, @@ -108,12 +108,11 @@ const StreamSettings = ({updateSettings, settingsError, settings, errors}) => { {lang.t('configure.include-comment-stream-desc')}

    -
    - +