From 35ccc5070d6b2235a539c75ba2e6e4ebc6ae8599 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 27 Jun 2017 14:52:12 -0300 Subject: [PATCH 1/3] Flag refactor --- .../src/components/Comment.js | 2 +- .../{ => components}/FlagButton.js | 0 .../{ => components}/FlagComment.js | 19 ++++++++++--------- client/coral-plugin-flags/helpers/flagMap.js | 15 +++++++++++++++ client/coral-plugin-flags/index.js | 1 + 5 files changed, 27 insertions(+), 10 deletions(-) rename client/coral-plugin-flags/{ => components}/FlagButton.js (100%) rename client/coral-plugin-flags/{ => components}/FlagComment.js (56%) create mode 100644 client/coral-plugin-flags/helpers/flagMap.js create mode 100644 client/coral-plugin-flags/index.js diff --git a/client/coral-embed-stream/src/components/Comment.js b/client/coral-embed-stream/src/components/Comment.js index 754f44558..efa88d0dd 100644 --- a/client/coral-embed-stream/src/components/Comment.js +++ b/client/coral-embed-stream/src/components/Comment.js @@ -5,7 +5,7 @@ import AuthorName from 'coral-plugin-author-name/AuthorName'; import TagLabel from 'coral-plugin-tag-label/TagLabel'; import PubDate from 'coral-plugin-pubdate/PubDate'; import {ReplyBox, ReplyButton} from 'coral-plugin-replies'; -import FlagComment from 'coral-plugin-flags/FlagComment'; +import {FlagComment} from 'coral-plugin-flags'; import {can} from 'coral-framework/services/perms'; import {TransitionGroup} from 'react-transition-group'; import cn from 'classnames'; diff --git a/client/coral-plugin-flags/FlagButton.js b/client/coral-plugin-flags/components/FlagButton.js similarity index 100% rename from client/coral-plugin-flags/FlagButton.js rename to client/coral-plugin-flags/components/FlagButton.js diff --git a/client/coral-plugin-flags/FlagComment.js b/client/coral-plugin-flags/components/FlagComment.js similarity index 56% rename from client/coral-plugin-flags/FlagComment.js rename to client/coral-plugin-flags/components/FlagComment.js index efc4c282f..ddad63b7e 100644 --- a/client/coral-plugin-flags/FlagComment.js +++ b/client/coral-plugin-flags/components/FlagComment.js @@ -2,6 +2,7 @@ import React from 'react'; import FlagButton from './FlagButton'; import t from 'coral-framework/services/i18n'; +import * as flagReason from '../helpers/flagMap'; const FlagComment = (props) => ; @@ -20,17 +21,17 @@ const getPopupMenu = [ (itemType) => { const options = itemType === 'COMMENTS' ? [ - {val: 'This comment is offensive', text: t('comment_offensive')}, - {val: 'This looks like an ad/marketing', text: t('marketing')}, - {val: 'I don\'t agree with this comment', text: t('no_agree_comment')}, - {val: 'Other', text: t('other')} + {val: flagReason.commment.offensive, text: t('comment_offensive')}, + {val: flagReason.commment.spam, text: t('marketing')}, + {val: flagReason.commment.noagree, text: t('no_agree_comment')}, + {val: flagReason.commment.other, text: t('other')} ] : [ - {val: 'This username is offensive', text: t('username_offensive')}, - {val: 'I don\'t like this username', text: t('no_like_username')}, - {val: 'This user is impersonating', text: t('user_impersonating')}, - {val: 'This looks like an ad/marketing', text: t('marketing')}, - {val: 'Other', text: t('other')} + {val: flagReason.username.offensive, text: t('username_offensive')}, + {val: flagReason.username.nolike, text: t('no_like_username')}, + {val: flagReason.username.impersonating, text: t('user_impersonating')}, + {val: flagReason.username.spam, text: t('marketing')}, + {val: flagReason.username.other, text: t('other')} ]; return { header: t('step_2_header'), diff --git a/client/coral-plugin-flags/helpers/flagMap.js b/client/coral-plugin-flags/helpers/flagMap.js new file mode 100644 index 000000000..514c57398 --- /dev/null +++ b/client/coral-plugin-flags/helpers/flagMap.js @@ -0,0 +1,15 @@ +export default { + username: { + offensive: 'USERNAME_OFFENSIVE', + nolike: 'USERNAME_NOLIKE', + impersonating: 'USERNAME_IMPERSONATING', + spam: 'USERNAME_SPAM', + other: 'USERNAME_OTHER' + }, + comment: { + offensive: 'COMMENT_OFFENSIVE', + spam: 'COMMENT_SPAM', + noagree: 'COMMENT_NOAGREE', + other: 'COMMENT_OTHER' + } +}; diff --git a/client/coral-plugin-flags/index.js b/client/coral-plugin-flags/index.js new file mode 100644 index 000000000..d896d34f5 --- /dev/null +++ b/client/coral-plugin-flags/index.js @@ -0,0 +1 @@ +export {default as FlagComment} from './components/FlagComment'; \ No newline at end of file From f13682c12585ea98f9798d629ab4de2e0fc7695d Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 27 Jun 2017 16:12:13 -0300 Subject: [PATCH 2/3] flagMap added to the admin side --- .../src/routes/Community/components/User.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/client/coral-admin/src/routes/Community/components/User.js b/client/coral-admin/src/routes/Community/components/User.js index ee917e295..85f8cbd27 100644 --- a/client/coral-admin/src/routes/Community/components/User.js +++ b/client/coral-admin/src/routes/Community/components/User.js @@ -2,17 +2,18 @@ import React from 'react'; import styles from './Community.css'; import ActionButton from './ActionButton'; +import {username} from 'coral-plugin-flags/helpers/flagMap'; import ActionsMenu from 'coral-admin/src/components/ActionsMenu'; import ActionsMenuItem from 'coral-admin/src/components/ActionsMenuItem'; import t from 'coral-framework/services/i18n'; const shortReasons = { - 'This comment is offensive': t('community.offensive'), - 'This looks like an ad/marketing': t('community.spam_ads'), - 'This user is impersonating': t('community.impersonating'), - 'I don\'t like this username': t('community.dont_like_username'), - 'Other': t('community.other') + [username.other]: t('community.other'), + [username.spam]: t('community.spam_ads'), + [username.offensive]: t('community.offensive'), + [username.nolike]: t('community.dont_like_username'), + [username.impersonating]: t('community.impersonating'), }; // Render a single user for the list From e03e15fb3bf7d58690bdeec71d23ef92a362fe99 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 27 Jun 2017 16:20:08 -0300 Subject: [PATCH 3/3] renaming --- .../src/routes/Community/components/User.js | 2 +- .../components/FlagComment.js | 20 +++++++++---------- .../helpers/{flagMap.js => flagReasons.js} | 0 3 files changed, 11 insertions(+), 11 deletions(-) rename client/coral-plugin-flags/helpers/{flagMap.js => flagReasons.js} (100%) diff --git a/client/coral-admin/src/routes/Community/components/User.js b/client/coral-admin/src/routes/Community/components/User.js index 85f8cbd27..b6a01f016 100644 --- a/client/coral-admin/src/routes/Community/components/User.js +++ b/client/coral-admin/src/routes/Community/components/User.js @@ -2,7 +2,7 @@ import React from 'react'; import styles from './Community.css'; import ActionButton from './ActionButton'; -import {username} from 'coral-plugin-flags/helpers/flagMap'; +import {username} from 'coral-plugin-flags/helpers/flagReasons'; import ActionsMenu from 'coral-admin/src/components/ActionsMenu'; import ActionsMenuItem from 'coral-admin/src/components/ActionsMenuItem'; diff --git a/client/coral-plugin-flags/components/FlagComment.js b/client/coral-plugin-flags/components/FlagComment.js index ddad63b7e..fc67d4b71 100644 --- a/client/coral-plugin-flags/components/FlagComment.js +++ b/client/coral-plugin-flags/components/FlagComment.js @@ -2,7 +2,7 @@ import React from 'react'; import FlagButton from './FlagButton'; import t from 'coral-framework/services/i18n'; -import * as flagReason from '../helpers/flagMap'; +import {username, comment} from '../helpers/flagReasons'; const FlagComment = (props) => ; @@ -21,17 +21,17 @@ const getPopupMenu = [ (itemType) => { const options = itemType === 'COMMENTS' ? [ - {val: flagReason.commment.offensive, text: t('comment_offensive')}, - {val: flagReason.commment.spam, text: t('marketing')}, - {val: flagReason.commment.noagree, text: t('no_agree_comment')}, - {val: flagReason.commment.other, text: t('other')} + {val: comment.offensive, text: t('comment_offensive')}, + {val: comment.spam, text: t('marketing')}, + {val: comment.noagree, text: t('no_agree_comment')}, + {val: comment.other, text: t('other')} ] : [ - {val: flagReason.username.offensive, text: t('username_offensive')}, - {val: flagReason.username.nolike, text: t('no_like_username')}, - {val: flagReason.username.impersonating, text: t('user_impersonating')}, - {val: flagReason.username.spam, text: t('marketing')}, - {val: flagReason.username.other, text: t('other')} + {val: username.offensive, text: t('username_offensive')}, + {val: username.nolike, text: t('no_like_username')}, + {val: username.impersonating, text: t('user_impersonating')}, + {val: username.spam, text: t('marketing')}, + {val: username.other, text: t('other')} ]; return { header: t('step_2_header'), diff --git a/client/coral-plugin-flags/helpers/flagMap.js b/client/coral-plugin-flags/helpers/flagReasons.js similarity index 100% rename from client/coral-plugin-flags/helpers/flagMap.js rename to client/coral-plugin-flags/helpers/flagReasons.js