From 3463e09caba8687a3bfd9ec410d609537f7bc617 Mon Sep 17 00:00:00 2001 From: gaba Date: Fri, 2 Dec 2016 17:05:23 -0800 Subject: [PATCH] Setting the showuserdialog in the reducer for comments. --- client/coral-admin/src/actions/comments.js | 9 +++++++++ client/coral-admin/src/actions/users.js | 10 +--------- client/coral-admin/src/components/Comment.js | 9 +++++---- client/coral-admin/src/reducers/comments.js | 10 +++++++++- client/coral-admin/src/reducers/users.js | 7 ------- 5 files changed, 24 insertions(+), 21 deletions(-) diff --git a/client/coral-admin/src/actions/comments.js b/client/coral-admin/src/actions/comments.js index e4a55a893..a01ceecfd 100644 --- a/client/coral-admin/src/actions/comments.js +++ b/client/coral-admin/src/actions/comments.js @@ -1,3 +1,4 @@ +import actions from '../constants/users'; /** * Action disptacher related to comments @@ -16,3 +17,11 @@ export const flagComment = id => (dispatch, getState) => { export const createComment = (name, body) => dispatch => { dispatch({type: 'COMMENT_CREATE', name, body}); }; + +// Dialog Actions +export const showBanUserDialog = () => (dispatch) => { + dispatch({type: actions.SHOW_BANUSER_DIALOG}); +}; +export const hideBanUserDialog = () => (dispatch) => { + dispatch({type: actions.HIDE_BANUSER_DIALOG}); +}; diff --git a/client/coral-admin/src/actions/users.js b/client/coral-admin/src/actions/users.js index b84d99dc3..45c7675c0 100644 --- a/client/coral-admin/src/actions/users.js +++ b/client/coral-admin/src/actions/users.js @@ -1,16 +1,8 @@ -import actions from '../constants/users'; + /** * Action disptacher related to users */ -// Dialog Actions -export const showBanUserDialog = () => (dispatch) => { - dispatch({type: actions.SHOW_BANUSER_DIALOG}); -}; -export const hideBanUserDialog = () => (dispatch) => { - dispatch({type: actions.HIDE_BANUSER_DIALOG}); -}; - export const banUser = (status, id, author_id) => (dispatch) => { dispatch({type: 'USER_STATUS_UPDATE', id, author_id, status}); }; diff --git a/client/coral-admin/src/components/Comment.js b/client/coral-admin/src/components/Comment.js index 1bfeec4b2..0a950d402 100644 --- a/client/coral-admin/src/components/Comment.js +++ b/client/coral-admin/src/components/Comment.js @@ -11,6 +11,8 @@ import {Icon} from 'react-mdl'; import {FabButton, Button} from 'coral-ui'; import BanUserDialog from './BanUserDialog'; +import {showBanUserDialog, hideBanUserDialog} from '../actions/comments'; + const linkify = new Linkify(); // Render a single comment for the list @@ -60,7 +62,6 @@ const getActionButton = (action, i, props) => { return null; } if (action === 'ban') { - const showBanUserDialog = false; return ( // diff --git a/client/coral-admin/src/reducers/comments.js b/client/coral-admin/src/reducers/comments.js index 2c55ab20d..8515a4fd0 100644 --- a/client/coral-admin/src/reducers/comments.js +++ b/client/coral-admin/src/reducers/comments.js @@ -1,4 +1,5 @@ +import * as actions from '../constants/users'; import {Map, List, fromJS} from 'immutable'; /** @@ -11,7 +12,8 @@ import {Map, List, fromJS} from 'immutable'; const initialState = Map({ byId: Map(), ids: List(), - loading: false + loading: false, + showBanUserDialog: false }); // Handle the comment actions @@ -24,6 +26,12 @@ export default (state = initialState, action) => { case 'COMMENT_FLAG': return flag(state, action); case 'COMMENT_CREATE_SUCCESS': return addComment(state, action); case 'COMMENT_STREAM_FETCH_SUCCESS': return replaceComments(action, state); + case actions.SHOW_BANUSER_DIALOG: + return state + .set('showBanUserDialog', true); + case actions.HIDE_BANUSER_DIALOG: + return state + .set('showBanUserDialog', false); default: return state; } }; diff --git a/client/coral-admin/src/reducers/users.js b/client/coral-admin/src/reducers/users.js index dbfa61c9d..04375e143 100644 --- a/client/coral-admin/src/reducers/users.js +++ b/client/coral-admin/src/reducers/users.js @@ -1,5 +1,4 @@ import {Map, List, fromJS} from 'immutable'; -import * as actions from '../constants/users'; const initialState = Map({ byId: Map(), @@ -11,12 +10,6 @@ export default (state = initialState, action) => { switch (action.type) { case 'USERS_MODERATION_QUEUE_FETCH_SUCCESS': return replaceUsers(action, state); case 'USER_STATUS_UPDATE': return updateUserStatus(state, action); - case actions.SHOW_BANUSER_DIALOG: - return state - .set('showBanUserDialog', true); - case actions.HIDE_BANUSER_DIALOG: - return state - .set('showBanUserDialog', false); default: return state; } };