mirror of
https://github.com/wassname/talk.git
synced 2026-09-09 11:38:08 +08:00
replaced eslint:recommended with prettier
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
import {OPEN_MENU, CLOSE_MENU, OPEN_BAN_DIALOG, CLOSE_BAN_DIALOG} from './constants';
|
||||
import {
|
||||
OPEN_MENU,
|
||||
CLOSE_MENU,
|
||||
OPEN_BAN_DIALOG,
|
||||
CLOSE_BAN_DIALOG,
|
||||
} from './constants';
|
||||
|
||||
export const openMenu = (id) => ({
|
||||
export const openMenu = id => ({
|
||||
type: OPEN_MENU,
|
||||
id,
|
||||
});
|
||||
@@ -9,11 +14,11 @@ export const closeMenu = () => ({
|
||||
type: CLOSE_MENU,
|
||||
});
|
||||
|
||||
export const openBanDialog = ({commentId, authorId, commentStatus}) => ({
|
||||
export const openBanDialog = ({ commentId, authorId, commentStatus }) => ({
|
||||
type: OPEN_BAN_DIALOG,
|
||||
commentId,
|
||||
authorId,
|
||||
commentStatus
|
||||
commentStatus,
|
||||
});
|
||||
|
||||
export const closeBanDialog = () => ({
|
||||
|
||||
@@ -1,25 +1,27 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import styles from './styles.css';
|
||||
import {t} from 'plugin-api/beta/client/services';
|
||||
import {Icon} from 'plugin-api/beta/client/components/ui';
|
||||
import { t } from 'plugin-api/beta/client/services';
|
||||
import { Icon } from 'plugin-api/beta/client/components/ui';
|
||||
import cn from 'classnames';
|
||||
|
||||
const isApproved = (status) => (status === 'ACCEPTED');
|
||||
const isApproved = status => status === 'ACCEPTED';
|
||||
|
||||
const ApproveCommentAction = ({approveComment, comment: {status}}) => (
|
||||
const ApproveCommentAction = ({ approveComment, comment: { status } }) =>
|
||||
isApproved(status) ? (
|
||||
<span className={styles.approved}>
|
||||
<Icon name="check_circle" className={styles.icon} />
|
||||
{t('talk-plugin-moderation-actions.approved_comment')}
|
||||
</span>
|
||||
) : (
|
||||
<button className={cn(styles.button, 'talk-plugin-moderation-actions-approve')} onClick={approveComment}>
|
||||
<button
|
||||
className={cn(styles.button, 'talk-plugin-moderation-actions-approve')}
|
||||
onClick={approveComment}
|
||||
>
|
||||
<Icon name="done" className={styles.icon} />
|
||||
{t('talk-plugin-moderation-actions.approve_comment')}
|
||||
</button>
|
||||
)
|
||||
);
|
||||
);
|
||||
|
||||
ApproveCommentAction.propTypes = {
|
||||
approveComment: PropTypes.func,
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import styles from './styles.css';
|
||||
import {t} from 'plugin-api/beta/client/services';
|
||||
import {Icon} from 'plugin-api/beta/client/components/ui';
|
||||
import { t } from 'plugin-api/beta/client/services';
|
||||
import { Icon } from 'plugin-api/beta/client/components/ui';
|
||||
import cn from 'classnames';
|
||||
|
||||
const BanUserAction = ({onBanUser}) => (
|
||||
<button
|
||||
const BanUserAction = ({ onBanUser }) => (
|
||||
<button
|
||||
className={cn(styles.button, 'talk-plugin-moderation-actions-ban')}
|
||||
onClick={onBanUser} >
|
||||
onClick={onBanUser}
|
||||
>
|
||||
<Icon name="block" className={styles.icon} />
|
||||
{t('talk-plugin-moderation-actions.ban_user')}
|
||||
</button>
|
||||
|
||||
@@ -2,12 +2,17 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import cn from 'classnames';
|
||||
import styles from './BanUserDialog.css';
|
||||
import {t} from 'plugin-api/beta/client/services';
|
||||
import {Dialog, Button} from 'plugin-api/beta/client/components/ui';
|
||||
import { t } from 'plugin-api/beta/client/services';
|
||||
import { Dialog, Button } from 'plugin-api/beta/client/components/ui';
|
||||
|
||||
const BanUserDialog = ({showBanDialog, closeBanDialog, banUser}) => (
|
||||
<Dialog open={showBanDialog} className={cn(styles.dialog, 'talk-ban-user-dialog')}>
|
||||
<span className={styles.close} onClick={closeBanDialog}>×</span>
|
||||
const BanUserDialog = ({ showBanDialog, closeBanDialog, banUser }) => (
|
||||
<Dialog
|
||||
open={showBanDialog}
|
||||
className={cn(styles.dialog, 'talk-ban-user-dialog')}
|
||||
>
|
||||
<span className={styles.close} onClick={closeBanDialog}>
|
||||
×
|
||||
</span>
|
||||
<h2>{t('talk-plugin-moderation-actions.ban_user_dialog_headline')}</h2>
|
||||
<h3>{t('talk-plugin-moderation-actions.ban_user_dialog_sub')}</h3>
|
||||
<p className={styles.copy}>
|
||||
@@ -18,14 +23,16 @@ const BanUserDialog = ({showBanDialog, closeBanDialog, banUser}) => (
|
||||
cStyle="cancel"
|
||||
onClick={closeBanDialog}
|
||||
className={cn(styles.cancel, 'talk-ban-user-dialog-button-cancel')}
|
||||
raised >
|
||||
raised
|
||||
>
|
||||
{t('talk-plugin-moderation-actions.ban_user_dialog_cancel')}
|
||||
</Button>
|
||||
<Button
|
||||
cStyle="black"
|
||||
onClick={banUser}
|
||||
className={cn(styles.confirm, 'talk-ban-user-dialog-button-confirm')}
|
||||
raised >
|
||||
raised
|
||||
>
|
||||
{t('talk-plugin-moderation-actions.ban_user_dialog_yes')}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -2,9 +2,9 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import cn from 'classnames';
|
||||
import styles from './Menu.css';
|
||||
import {t} from 'plugin-api/beta/client/services';
|
||||
import { t } from 'plugin-api/beta/client/services';
|
||||
|
||||
const Menu = ({className = '', children}) => (
|
||||
const Menu = ({ className = '', children }) => (
|
||||
<div className={cn(styles.menu, className)}>
|
||||
<h3 className={styles.headline}>
|
||||
{t('talk-plugin-moderation-actions.moderation_actions')}
|
||||
|
||||
@@ -3,35 +3,58 @@ import PropTypes from 'prop-types';
|
||||
import cn from 'classnames';
|
||||
import Menu from './Menu';
|
||||
import styles from './ModerationActions.css';
|
||||
import {Icon} from 'plugin-api/beta/client/components/ui';
|
||||
import { Icon } from 'plugin-api/beta/client/components/ui';
|
||||
import ClickOutside from 'coral-framework/components/ClickOutside';
|
||||
import RejectCommentAction from '../containers/RejectCommentAction';
|
||||
import ApproveCommentAction from '../containers/ApproveCommentAction';
|
||||
import BanUserAction from '../containers/BanUserAction';
|
||||
import {Slot} from 'plugin-api/beta/client/components';
|
||||
import { Slot } from 'plugin-api/beta/client/components';
|
||||
|
||||
export default class ModerationActions extends React.Component {
|
||||
render() {
|
||||
const {comment, root, asset, data, menuVisible, toogleMenu, hideMenu} = this.props;
|
||||
const {
|
||||
comment,
|
||||
root,
|
||||
asset,
|
||||
data,
|
||||
menuVisible,
|
||||
toogleMenu,
|
||||
hideMenu,
|
||||
} = this.props;
|
||||
|
||||
return(
|
||||
return (
|
||||
<ClickOutside onClickOutside={hideMenu}>
|
||||
<div className={cn(styles.moderationActions, 'talk-plugin-moderation-actions')}>
|
||||
<span onClick={toogleMenu} className={cn(styles.arrow, 'talk-plugin-moderation-actions-arrow')}>
|
||||
{menuVisible ? <Icon name="keyboard_arrow_up" className={styles.icon} /> :
|
||||
<Icon name="keyboard_arrow_down" className={styles.icon} />}
|
||||
<div
|
||||
className={cn(
|
||||
styles.moderationActions,
|
||||
'talk-plugin-moderation-actions'
|
||||
)}
|
||||
>
|
||||
<span
|
||||
onClick={toogleMenu}
|
||||
className={cn(styles.arrow, 'talk-plugin-moderation-actions-arrow')}
|
||||
>
|
||||
{menuVisible ? (
|
||||
<Icon name="keyboard_arrow_up" className={styles.icon} />
|
||||
) : (
|
||||
<Icon name="keyboard_arrow_down" className={styles.icon} />
|
||||
)}
|
||||
</span>
|
||||
{menuVisible && (
|
||||
<Menu className="talk-plugin-modetarion-actions-menu">
|
||||
<Slot
|
||||
className="talk-plugin-modetarion-actions-slot"
|
||||
fill="moderationActions"
|
||||
queryData={{comment, asset}}
|
||||
queryData={{ comment, asset }}
|
||||
data={data}
|
||||
/>
|
||||
<ApproveCommentAction comment={comment} hideMenu={hideMenu} />
|
||||
<RejectCommentAction comment={comment} hideMenu={hideMenu} />
|
||||
<BanUserAction comment={comment} root={root} hideMenu={hideMenu} />
|
||||
<BanUserAction
|
||||
comment={comment}
|
||||
root={root}
|
||||
hideMenu={hideMenu}
|
||||
/>
|
||||
</Menu>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -2,11 +2,14 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import cn from 'classnames';
|
||||
import styles from './styles.css';
|
||||
import {t} from 'plugin-api/beta/client/services';
|
||||
import {Icon} from 'plugin-api/beta/client/components/ui';
|
||||
import { t } from 'plugin-api/beta/client/services';
|
||||
import { Icon } from 'plugin-api/beta/client/components/ui';
|
||||
|
||||
const RejectCommentAction = ({rejectComment}) => (
|
||||
<button className={cn(styles.button, 'talk-plugin-moderation-actions-reject')} onClick={rejectComment}>
|
||||
const RejectCommentAction = ({ rejectComment }) => (
|
||||
<button
|
||||
className={cn(styles.button, 'talk-plugin-moderation-actions-reject')}
|
||||
onClick={rejectComment}
|
||||
>
|
||||
<Icon name="clear" className={styles.icon} />
|
||||
{t('talk-plugin-moderation-actions.reject_comment')}
|
||||
</button>
|
||||
|
||||
@@ -1,38 +1,44 @@
|
||||
import React from 'react';
|
||||
import {compose} from 'react-apollo';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import {getErrorMessages} from 'plugin-api/beta/client/utils';
|
||||
import {notify} from 'plugin-api/beta/client/actions/notification';
|
||||
import { compose } from 'react-apollo';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import { getErrorMessages } from 'plugin-api/beta/client/utils';
|
||||
import { notify } from 'plugin-api/beta/client/actions/notification';
|
||||
import ApproveCommentAction from '../components/ApproveCommentAction';
|
||||
import {connect, withSetCommentStatus} from 'plugin-api/beta/client/hocs';
|
||||
import { connect, withSetCommentStatus } from 'plugin-api/beta/client/hocs';
|
||||
|
||||
class ApproveCommentActionContainer extends React.Component {
|
||||
|
||||
approveComment = async () => {
|
||||
const {setCommentStatus, comment, hideMenu, notify} = this.props;
|
||||
const { setCommentStatus, comment, hideMenu, notify } = this.props;
|
||||
|
||||
try {
|
||||
await setCommentStatus({
|
||||
commentId: comment.id,
|
||||
status: 'ACCEPTED'
|
||||
status: 'ACCEPTED',
|
||||
});
|
||||
}
|
||||
catch(err) {
|
||||
} catch (err) {
|
||||
notify('error', getErrorMessages(err));
|
||||
}
|
||||
|
||||
hideMenu();
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
return <ApproveCommentAction comment={this.props.comment} approveComment={this.approveComment}/>;
|
||||
return (
|
||||
<ApproveCommentAction
|
||||
comment={this.props.comment}
|
||||
approveComment={this.approveComment}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch) =>
|
||||
bindActionCreators({
|
||||
notify
|
||||
}, dispatch);
|
||||
const mapDispatchToProps = dispatch =>
|
||||
bindActionCreators(
|
||||
{
|
||||
notify,
|
||||
},
|
||||
dispatch
|
||||
);
|
||||
|
||||
const enhance = compose(
|
||||
connect(null, mapDispatchToProps),
|
||||
|
||||
@@ -1,36 +1,35 @@
|
||||
import React from 'react';
|
||||
import {compose} from 'react-apollo';
|
||||
import {openBanDialog} from '../actions';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import { compose } from 'react-apollo';
|
||||
import { openBanDialog } from '../actions';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import BanUserAction from '../components/BanUserAction';
|
||||
import {connect} from 'plugin-api/beta/client/hocs';
|
||||
import { connect } from 'plugin-api/beta/client/hocs';
|
||||
|
||||
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
|
||||
authorId: this.props.comment.user.id,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const {root: {me}, comment} = this.props;
|
||||
return (me.id !== comment.user.id) ?
|
||||
<BanUserAction
|
||||
onBanUser={this.onBanUser}
|
||||
comment={this.props.comment}
|
||||
/> : null;
|
||||
const { root: { me }, comment } = this.props;
|
||||
return me.id !== comment.user.id ? (
|
||||
<BanUserAction onBanUser={this.onBanUser} comment={this.props.comment} />
|
||||
) : null;
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch) =>
|
||||
bindActionCreators({
|
||||
openBanDialog
|
||||
}, dispatch);
|
||||
const mapDispatchToProps = dispatch =>
|
||||
bindActionCreators(
|
||||
{
|
||||
openBanDialog,
|
||||
},
|
||||
dispatch
|
||||
);
|
||||
|
||||
const enhance = compose(
|
||||
connect(null, mapDispatchToProps)
|
||||
);
|
||||
const enhance = compose(connect(null, mapDispatchToProps));
|
||||
|
||||
export default enhance(BanUserActionContainer);
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import {compose} from 'react-apollo';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import {closeBanDialog, closeMenu} from '../actions';
|
||||
import {notify} from 'plugin-api/beta/client/actions/notification';
|
||||
import {connect, withSetCommentStatus, withBanUser} from 'plugin-api/beta/client/hocs';
|
||||
import {getErrorMessages} from 'plugin-api/beta/client/utils';
|
||||
import { compose } from 'react-apollo';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import { closeBanDialog, closeMenu } from '../actions';
|
||||
import { notify } from 'plugin-api/beta/client/actions/notification';
|
||||
import {
|
||||
connect,
|
||||
withSetCommentStatus,
|
||||
withBanUser,
|
||||
} from 'plugin-api/beta/client/hocs';
|
||||
import { getErrorMessages } from 'plugin-api/beta/client/utils';
|
||||
import BanUserDialog from '../components/BanUserDialog';
|
||||
|
||||
class BanUserDialogContainer extends React.Component {
|
||||
|
||||
class BanUserDialogContainer extends React.Component {
|
||||
banUser = async () => {
|
||||
const {
|
||||
notify,
|
||||
@@ -35,19 +37,18 @@ class BanUserDialogContainer extends React.Component {
|
||||
if (commentStatus !== 'REJECTED') {
|
||||
await setCommentStatus({
|
||||
commentId: commentId,
|
||||
status: 'REJECTED'
|
||||
status: 'REJECTED',
|
||||
});
|
||||
}
|
||||
}
|
||||
catch(err) {
|
||||
} catch (err) {
|
||||
notify('error', getErrorMessages(err));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<BanUserDialog
|
||||
banUser={this.banUser}
|
||||
<BanUserDialog
|
||||
banUser={this.banUser}
|
||||
showBanDialog={this.props.showBanDialog}
|
||||
closeBanDialog={this.props.closeBanDialog}
|
||||
/>
|
||||
@@ -60,23 +61,26 @@ BanUserDialogContainer.propTypes = {
|
||||
closeBanDialog: PropTypes.func,
|
||||
};
|
||||
|
||||
const mapStateToProps = ({talkPluginModerationActions: state}) => ({
|
||||
const mapStateToProps = ({ talkPluginModerationActions: state }) => ({
|
||||
showBanDialog: state.showBanDialog,
|
||||
commentId: state.commentId,
|
||||
authorId: state.authorId,
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) =>
|
||||
bindActionCreators({
|
||||
notify,
|
||||
closeBanDialog,
|
||||
closeMenu,
|
||||
}, dispatch);
|
||||
const mapDispatchToProps = dispatch =>
|
||||
bindActionCreators(
|
||||
{
|
||||
notify,
|
||||
closeBanDialog,
|
||||
closeMenu,
|
||||
},
|
||||
dispatch
|
||||
);
|
||||
|
||||
const enhance = compose(
|
||||
connect(mapStateToProps, mapDispatchToProps),
|
||||
withSetCommentStatus,
|
||||
withBanUser,
|
||||
withBanUser
|
||||
);
|
||||
|
||||
export default enhance(BanUserDialogContainer);
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
import React from 'react';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import {gql, compose} from 'react-apollo';
|
||||
import {openMenu, closeMenu} from '../actions';
|
||||
import {can} from 'plugin-api/beta/client/services';
|
||||
import {getShallowChanges} from 'plugin-api/beta/client/utils';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import { gql, compose } from 'react-apollo';
|
||||
import { openMenu, closeMenu } from '../actions';
|
||||
import { can } from 'plugin-api/beta/client/services';
|
||||
import { getShallowChanges } from 'plugin-api/beta/client/utils';
|
||||
import ModerationActions from '../components/ModerationActions';
|
||||
import {connect, excludeIf, withFragments} from 'plugin-api/beta/client/hocs';
|
||||
import { connect, excludeIf, withFragments } from 'plugin-api/beta/client/hocs';
|
||||
|
||||
class ModerationActionsContainer extends React.Component {
|
||||
|
||||
shouldComponentUpdate(nextProps) {
|
||||
|
||||
// Specifically handle `showMenuForComment` if it is the only change.
|
||||
const changes = getShallowChanges(this.props, nextProps);
|
||||
if (changes.length === 1 && changes[0] === 'showMenuForComment') {
|
||||
@@ -22,7 +20,7 @@ class ModerationActionsContainer extends React.Component {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Prevent Slot from rerendering when no props has shallowly changed.
|
||||
return changes.length !== 0;
|
||||
}
|
||||
@@ -33,37 +31,42 @@ class ModerationActionsContainer extends React.Component {
|
||||
} else {
|
||||
this.props.openMenu(this.props.comment.id);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
hideMenu = () => {
|
||||
if (this.props.showMenuForComment === this.props.comment.id) {
|
||||
this.props.closeMenu();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
return <ModerationActions
|
||||
data={this.props.data}
|
||||
root={this.props.root}
|
||||
asset={this.props.asset}
|
||||
comment={this.props.comment}
|
||||
toogleMenu={this.toogleMenu}
|
||||
hideMenu={this.hideMenu}
|
||||
menuVisible={this.props.showMenuForComment === this.props.comment.id}
|
||||
/>;
|
||||
return (
|
||||
<ModerationActions
|
||||
data={this.props.data}
|
||||
root={this.props.root}
|
||||
asset={this.props.asset}
|
||||
comment={this.props.comment}
|
||||
toogleMenu={this.toogleMenu}
|
||||
hideMenu={this.hideMenu}
|
||||
menuVisible={this.props.showMenuForComment === this.props.comment.id}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = ({auth, talkPluginModerationActions: state}) => ({
|
||||
const mapStateToProps = ({ auth, talkPluginModerationActions: state }) => ({
|
||||
user: auth.user,
|
||||
showMenuForComment: state.showMenuForComment,
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) =>
|
||||
bindActionCreators({
|
||||
openMenu,
|
||||
closeMenu,
|
||||
}, dispatch);
|
||||
const mapDispatchToProps = dispatch =>
|
||||
bindActionCreators(
|
||||
{
|
||||
openMenu,
|
||||
closeMenu,
|
||||
},
|
||||
dispatch
|
||||
);
|
||||
|
||||
const enhance = compose(
|
||||
connect(mapStateToProps, mapDispatchToProps),
|
||||
@@ -73,13 +76,13 @@ const enhance = compose(
|
||||
me {
|
||||
id
|
||||
}
|
||||
}`
|
||||
,
|
||||
}
|
||||
`,
|
||||
asset: gql`
|
||||
fragment TalkModerationActions_asset on Asset {
|
||||
id
|
||||
}`
|
||||
,
|
||||
}
|
||||
`,
|
||||
comment: gql`
|
||||
fragment TalkModerationActions_comment on Comment {
|
||||
id
|
||||
@@ -93,8 +96,9 @@ const enhance = compose(
|
||||
}
|
||||
}
|
||||
}
|
||||
`}),
|
||||
excludeIf((props) => !can(props.user, 'MODERATE_COMMENTS')),
|
||||
`,
|
||||
}),
|
||||
excludeIf(props => !can(props.user, 'MODERATE_COMMENTS'))
|
||||
);
|
||||
|
||||
export default enhance(ModerationActionsContainer);
|
||||
|
||||
@@ -1,38 +1,39 @@
|
||||
import React from 'react';
|
||||
import {compose} from 'react-apollo';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import {getErrorMessages} from 'plugin-api/beta/client/utils';
|
||||
import {notify} from 'plugin-api/beta/client/actions/notification';
|
||||
import { compose } from 'react-apollo';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import { getErrorMessages } from 'plugin-api/beta/client/utils';
|
||||
import { notify } from 'plugin-api/beta/client/actions/notification';
|
||||
import RejectCommentAction from '../components/RejectCommentAction';
|
||||
import {connect, withSetCommentStatus} from 'plugin-api/beta/client/hocs';
|
||||
import { connect, withSetCommentStatus } from 'plugin-api/beta/client/hocs';
|
||||
|
||||
class RejectCommentActionContainer extends React.Component {
|
||||
|
||||
rejectComment = async () => {
|
||||
const {setCommentStatus, comment, hideMenu, notify} = this.props;
|
||||
const { setCommentStatus, comment, hideMenu, notify } = this.props;
|
||||
|
||||
try {
|
||||
await setCommentStatus({
|
||||
commentId: comment.id,
|
||||
status: 'REJECTED'
|
||||
status: 'REJECTED',
|
||||
});
|
||||
}
|
||||
catch(err) {
|
||||
} catch (err) {
|
||||
notify('error', getErrorMessages(err));
|
||||
}
|
||||
|
||||
hideMenu();
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
return <RejectCommentAction rejectComment={this.rejectComment}/>;
|
||||
return <RejectCommentAction rejectComment={this.rejectComment} />;
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch) =>
|
||||
bindActionCreators({
|
||||
notify
|
||||
}, dispatch);
|
||||
const mapDispatchToProps = dispatch =>
|
||||
bindActionCreators(
|
||||
{
|
||||
notify,
|
||||
},
|
||||
dispatch
|
||||
);
|
||||
|
||||
const enhance = compose(
|
||||
connect(null, mapDispatchToProps),
|
||||
|
||||
@@ -9,5 +9,5 @@ export default {
|
||||
commentInfoBar: [ModerationActions],
|
||||
},
|
||||
reducer,
|
||||
translations
|
||||
translations,
|
||||
};
|
||||
|
||||
@@ -1,42 +1,47 @@
|
||||
import {OPEN_MENU, CLOSE_MENU, OPEN_BAN_DIALOG, CLOSE_BAN_DIALOG} from './constants';
|
||||
import {
|
||||
OPEN_MENU,
|
||||
CLOSE_MENU,
|
||||
OPEN_BAN_DIALOG,
|
||||
CLOSE_BAN_DIALOG,
|
||||
} from './constants';
|
||||
|
||||
const initialState = {
|
||||
showMenuForComment: null,
|
||||
showBanDialog: false,
|
||||
authorId: null,
|
||||
commentId: null,
|
||||
commentStatus: null
|
||||
commentStatus: null,
|
||||
};
|
||||
|
||||
export default function reducer(state = initialState, action) {
|
||||
switch (action.type) {
|
||||
case OPEN_MENU:
|
||||
return {
|
||||
...state,
|
||||
showMenuForComment: action.id
|
||||
};
|
||||
case CLOSE_MENU:
|
||||
return {
|
||||
...state,
|
||||
showMenuForComment: null
|
||||
};
|
||||
case OPEN_BAN_DIALOG:
|
||||
return {
|
||||
...state,
|
||||
showBanDialog: true,
|
||||
authorId: action.authorId,
|
||||
commentId: action.commentId,
|
||||
commentStatus: action.commentStatus
|
||||
};
|
||||
case CLOSE_BAN_DIALOG:
|
||||
return {
|
||||
...state,
|
||||
showBanDialog: false,
|
||||
authorId: null,
|
||||
commentId: null,
|
||||
commentStatus: null
|
||||
};
|
||||
default :
|
||||
return state;
|
||||
case OPEN_MENU:
|
||||
return {
|
||||
...state,
|
||||
showMenuForComment: action.id,
|
||||
};
|
||||
case CLOSE_MENU:
|
||||
return {
|
||||
...state,
|
||||
showMenuForComment: null,
|
||||
};
|
||||
case OPEN_BAN_DIALOG:
|
||||
return {
|
||||
...state,
|
||||
showBanDialog: true,
|
||||
authorId: action.authorId,
|
||||
commentId: action.commentId,
|
||||
commentStatus: action.commentStatus,
|
||||
};
|
||||
case CLOSE_BAN_DIALOG:
|
||||
return {
|
||||
...state,
|
||||
showBanDialog: false,
|
||||
authorId: null,
|
||||
commentId: null,
|
||||
commentStatus: null,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user