From b6d8a90084659de814a8800f88d1944479ea2742 Mon Sep 17 00:00:00 2001 From: David Jay Date: Thu, 26 Jan 2017 16:36:43 -0500 Subject: [PATCH] Updating style of UserActions and moving ActionButton to its own component. --- .../src/components/ActionButton.js | 48 ++++++++++++++++ client/coral-admin/src/components/Comment.js | 55 +++++-------------- .../src/components/ModerationList.js | 2 +- .../coral-admin/src/components/UserAction.js | 49 +++++------------ 4 files changed, 77 insertions(+), 77 deletions(-) create mode 100644 client/coral-admin/src/components/ActionButton.js diff --git a/client/coral-admin/src/components/ActionButton.js b/client/coral-admin/src/components/ActionButton.js new file mode 100644 index 000000000..61de1c669 --- /dev/null +++ b/client/coral-admin/src/components/ActionButton.js @@ -0,0 +1,48 @@ +import React from 'react'; +import styles from './ModerationList.css'; +import I18n from 'coral-framework/modules/i18n/i18n'; +import translations from '../translations.json'; +import {FabButton, Button, Icon} from 'coral-ui'; + +const ActionButton = ({option, type, comment = {}, user, menuOptionsMap, onClickAction, onClickShowBanDialog}) => +{ + const banned = user.status === 'BANNED'; + + if (option === 'flag' && (type === 'USERS' || comment.status || comment.flagged === true)) { + return null; + } + if (option === 'ban') { + return ( +
+ +
+ ); + } + const menuOption = menuOptionsMap[option]; + const action = { + item_type: type, + item_id: type === 'COMMENTS' ? comment.id : user.id + }; + return ( + onClickAction(menuOption.status, type === 'COMMENTS' ? comment : user, action)} + /> + ); +}; + +export default ActionButton; + +const lang = new I18n(translations); diff --git a/client/coral-admin/src/components/Comment.js b/client/coral-admin/src/components/Comment.js index 52b37af09..74b0361a2 100644 --- a/client/coral-admin/src/components/Comment.js +++ b/client/coral-admin/src/components/Comment.js @@ -8,7 +8,8 @@ import I18n from 'coral-framework/modules/i18n/i18n'; import translations from '../translations.json'; import Highlighter from 'react-highlight-words'; -import {FabButton, Button, Icon} from 'coral-ui'; +import {Icon} from 'coral-ui'; +import ActionButton from './ActionButton'; const linkify = new Linkify(); @@ -30,7 +31,18 @@ const Comment = props => { {links ? Contains Link : null}
- {props.modActions.map((action, i) => getActionButton(action, i, props))} + {props.modActions.map( + (action, i) => + + )}
{authorStatus === 'banned' ? {lang.t('comment.banned_user')} : null} @@ -49,45 +61,6 @@ const Comment = props => { ); }; -// Get the button of the action performed over a comment if any -const getActionButton = (option, i, props) => { - const {comment, author, menuOptionsMap} = props; - const status = comment.status; - const flagged = comment.flagged; - const banned = (author.status === 'banned'); - - if (option === 'flag' && (status || flagged === true)) { - return null; - } - if (option === 'ban') { - return ( -
- -
- ); - } - const menuOption = menuOptionsMap[option]; - return ( - props.onClickAction(menuOption.status, comment, {item_type: 'comments'})} - /> - ); -}; - export default Comment; const linkStyles = { diff --git a/client/coral-admin/src/components/ModerationList.js b/client/coral-admin/src/components/ModerationList.js index 9dec94587..8ce3ec4a4 100644 --- a/client/coral-admin/src/components/ModerationList.js +++ b/client/coral-admin/src/components/ModerationList.js @@ -177,7 +177,7 @@ export default class ModerationList extends React.Component { // If the item is an action... const user = users[item.item_id]; - modItem = { // Do not display unless the user status is 'pending' or 'banned'. // This means that they have already been reviewed and approved. return (userStatus === 'PENDING' || userStatus === 'BANNED') && -
  • +
  • person {user.displayName}
    -
    +
    {links ? Contains Link : null}
    - {props.modActions.map((action, i) => getActionButton(action, i, props))} + {props.modActions.map( + (action, i) => + + )}
    @@ -62,37 +72,6 @@ const UserAction = props => { export default UserAction; -// Get the button of the action performed over a comment if any -const getActionButton = (option, i, props) => { - const {user, onClickShowBanDialog, onClickAction, menuOptionsMap, action} = props; - const status = user.status; - const banned = (user.status === 'BANNED'); - - if (option === 'flag' && status) { - return null; - } - if (option === 'ban') { - return ; - } - const menuOption = menuOptionsMap[option]; - return ( - onClickAction(menuOption.status, user.id, action)} - /> - ); -}; - const linkStyles = { backgroundColor: 'rgb(255, 219, 135)', padding: '1px 2px'