mirror of
https://github.com/wassname/talk.git
synced 2026-07-19 11:28:50 +08:00
Actions renamed
This commit is contained in:
@@ -9,10 +9,11 @@ export const closeMenu = () => ({
|
||||
type: CLOSE_MENU,
|
||||
});
|
||||
|
||||
export const openBanDialog = ({commentId, authorId}) => ({
|
||||
export const openBanDialog = ({commentId, authorId, commentStatus}) => ({
|
||||
type: OPEN_BAN_DIALOG,
|
||||
commentId,
|
||||
authorId
|
||||
authorId,
|
||||
commentStatus
|
||||
});
|
||||
|
||||
export const closeBanDialog = () => ({
|
||||
|
||||
@@ -3,15 +3,15 @@ import styles from './BanUserDialog.css';
|
||||
import {t} from 'plugin-api/beta/client/services';
|
||||
import {Dialog, Button} from 'plugin-api/beta/client/components/ui';
|
||||
|
||||
export default ({showDialog, closeDialog, banUser}) => (
|
||||
<Dialog open={showDialog} className={styles.dialog}>
|
||||
<span className={styles.close} onClick={closeDialog}>×</span>
|
||||
export default ({showBanDialog, closeBanDialog, banUser}) => (
|
||||
<Dialog open={showBanDialog} className={styles.dialog}>
|
||||
<span className={styles.close} onClick={closeBanDialog}>×</span>
|
||||
<h3>{t('talk-plugin-moderation-actions.ban_user_dialog_headline')}</h3>
|
||||
<p>
|
||||
{t('talk-plugin-moderation-actions.ban_user_dialog_copy')}
|
||||
</p>
|
||||
<div className={styles.buttons}>
|
||||
<Button cStyle="cancel" onClick={closeDialog} raised>
|
||||
<Button cStyle="cancel" onClick={closeBanDialog} raised>
|
||||
{t('talk-plugin-moderation-actions.ban_user_dialog_cancel')}
|
||||
</Button>
|
||||
<Button cStyle="black" onClick={banUser} raised>
|
||||
|
||||
@@ -9,6 +9,7 @@ class BanUserActionContainer extends React.Component {
|
||||
onBanUser = () => {
|
||||
this.props.openBanDialog({
|
||||
commentId: this.props.comment.id,
|
||||
commentStatus: this.props.comment.status,
|
||||
authorId: this.props.comment.user.id
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import React from 'react';
|
||||
import {compose} from 'react-apollo';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import {closeDialog, closeMenu} from '../actions';
|
||||
import {closeBanDialog, closeMenu} from '../actions';
|
||||
import {notify} from 'plugin-api/beta/client/actions/notification';
|
||||
import {connect, withSetCommentStatus, withSetUserStatus} from 'plugin-api/beta/client/hocs';
|
||||
import {getErrorMessages} from 'plugin-api/beta/client/utils';
|
||||
@@ -15,8 +15,9 @@ class BanUserDialogContainer extends React.Component {
|
||||
notify,
|
||||
authorId,
|
||||
commentId,
|
||||
commentStatus,
|
||||
closeMenu,
|
||||
closeDialog,
|
||||
closeBanDialog,
|
||||
setCommentStatus,
|
||||
setUserStatus
|
||||
} = this.props;
|
||||
@@ -28,9 +29,9 @@ class BanUserDialogContainer extends React.Component {
|
||||
});
|
||||
|
||||
closeMenu();
|
||||
closeDialog();
|
||||
closeBanDialog();
|
||||
|
||||
if (comment.status !== 'REJECTED') {
|
||||
if (commentStatus !== 'REJECTED') {
|
||||
await setCommentStatus({
|
||||
commentId: commentId,
|
||||
status: 'REJECTED'
|
||||
@@ -46,15 +47,15 @@ class BanUserDialogContainer extends React.Component {
|
||||
return (
|
||||
<BanUserDialog
|
||||
banUser={this.banUser}
|
||||
showDialog={this.props.showDialog}
|
||||
closeDialog={this.props.closeDialog}
|
||||
showBanDialog={this.props.showBanDialog}
|
||||
closeBanDialog={this.props.closeBanDialog}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = ({talkPluginModerationActions: state}) => ({
|
||||
showDialog: state.showDialog,
|
||||
showBanDialog: state.showBanDialog,
|
||||
commentId: state.commentId,
|
||||
authorId: state.authorId
|
||||
});
|
||||
@@ -62,7 +63,7 @@ const mapStateToProps = ({talkPluginModerationActions: state}) => ({
|
||||
const mapDispatchToProps = (dispatch) =>
|
||||
bindActionCreators({
|
||||
notify,
|
||||
closeDialog,
|
||||
closeBanDialog,
|
||||
closeMenu
|
||||
}, dispatch);
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import {OPEN_MENU, CLOSE_MENU, OPEN_DIALOG, CLOSE_DIALOG} from './constants';
|
||||
import {OPEN_MENU, CLOSE_MENU, OPEN_BAN_DIALOG, CLOSE_BAN_DIALOG} from './constants';
|
||||
|
||||
const initialState = {
|
||||
showMenuForComment: null,
|
||||
showDialog: false,
|
||||
comment: null
|
||||
showBanDialog: false,
|
||||
authorId: null,
|
||||
commentId: null,
|
||||
commentStatus: null
|
||||
};
|
||||
|
||||
export default function reducer(state = initialState, action) {
|
||||
@@ -18,18 +20,21 @@ export default function reducer(state = initialState, action) {
|
||||
...state,
|
||||
showMenuForComment: null
|
||||
};
|
||||
case OPEN_DIALOG:
|
||||
case OPEN_BAN_DIALOG:
|
||||
return {
|
||||
...state,
|
||||
showDialog: true,
|
||||
showBanDialog: true,
|
||||
authorId: action.authorId,
|
||||
commentId: action.commentId,
|
||||
authorId: action.authorId
|
||||
commentStatus: action.commentStatus
|
||||
};
|
||||
case CLOSE_DIALOG:
|
||||
case CLOSE_BAN_DIALOG:
|
||||
return {
|
||||
...state,
|
||||
showDialog: false,
|
||||
comment: null
|
||||
showBanDialog: false,
|
||||
authorId: null,
|
||||
commentId: null,
|
||||
commentStatus: null
|
||||
};
|
||||
default :
|
||||
return state;
|
||||
|
||||
Reference in New Issue
Block a user