From 35ccc5070d6b2235a539c75ba2e6e4ebc6ae8599 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 27 Jun 2017 14:52:12 -0300 Subject: [PATCH] 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