Port plugins

This commit is contained in:
Chi Vinh Le
2018-01-23 20:06:55 +01:00
parent b196bb379a
commit 59cdc9fd5d
9 changed files with 39 additions and 68 deletions
@@ -1,23 +1,18 @@
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 ApproveCommentAction from '../components/ApproveCommentAction';
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 } = this.props;
try {
await setCommentStatus({
commentId: comment.id,
status: 'ACCEPTED',
});
} catch (err) {
notify('error', getErrorMessages(err));
}
await setCommentStatus({
commentId: comment.id,
status: 'ACCEPTED',
});
hideMenu();
};
@@ -9,13 +9,11 @@ import {
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 {
banUser = async () => {
const {
notify,
authorId,
commentId,
commentStatus,
@@ -25,23 +23,19 @@ class BanUserDialogContainer extends React.Component {
banUser,
} = this.props;
try {
await banUser({
id: authorId,
message: '',
await banUser({
id: authorId,
message: '',
});
closeMenu();
closeBanDialog();
if (commentStatus !== 'REJECTED') {
await setCommentStatus({
commentId: commentId,
status: 'REJECTED',
});
closeMenu();
closeBanDialog();
if (commentStatus !== 'REJECTED') {
await setCommentStatus({
commentId: commentId,
status: 'REJECTED',
});
}
} catch (err) {
notify('error', getErrorMessages(err));
}
};
@@ -1,23 +1,18 @@
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 RejectCommentAction from '../components/RejectCommentAction';
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 } = this.props;
try {
await setCommentStatus({
commentId: comment.id,
status: 'REJECTED',
});
} catch (err) {
notify('error', getErrorMessages(err));
}
await setCommentStatus({
commentId: comment.id,
status: 'REJECTED',
});
hideMenu();
};