Setting the showuserdialog in the reducer for comments.

This commit is contained in:
gaba
2016-12-02 17:05:23 -08:00
parent eb916099bd
commit 3463e09cab
5 changed files with 24 additions and 21 deletions
@@ -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});
};
+1 -9
View File
@@ -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});
};
+5 -4
View File
@@ -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 (
// <Button
// {...props.author.get('status') === 'banned' ? 'disabled' : 'raised'}
@@ -69,14 +70,14 @@ const getActionButton = (action, i, props) => {
<div key={i}>
<Button {...props.author.get('status') === 'banned' ? 'disabled' : 'raised'}
cStyle="black"
onClick={props.showBanUserDialog}
onClick={showBanUserDialog()}
key={i}
{...props} >
{lang.t('comment.ban_user')}
</Button>
<BanUserDialog
open={showBanUserDialog}
handleClose={props.hideBanUserDialog}
open={props.showBanUserDialog}
handleClose={hideBanUserDialog()}
authorName={props.author.get('displayName')}
/>
</div>
+9 -1
View File
@@ -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;
}
};
-7
View File
@@ -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;
}
};