mirror of
https://github.com/wassname/talk.git
synced 2026-07-10 11:01:41 +08:00
Correct branch
This commit is contained in:
@@ -29,12 +29,23 @@ export class ModActionButton extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
handleDeleteTag = () => {
|
||||
this.props.deleteTag();
|
||||
this.props.closeTooltip();
|
||||
}
|
||||
|
||||
handlePostTag = () => {
|
||||
this.props.postTag();
|
||||
this.props.closeTooltip();
|
||||
}
|
||||
|
||||
render() {
|
||||
const {alreadyTagged, deleteTag, postTag} = this.props;
|
||||
const {alreadyTagged} = this.props;
|
||||
const {handleDeleteTag, handlePostTag} = this;
|
||||
|
||||
return (
|
||||
<button className={cn(`${pluginName}-tag-button`, styles.button, {[styles.featured] : alreadyTagged})}
|
||||
onClick={alreadyTagged ? deleteTag : postTag}
|
||||
onClick={alreadyTagged ? handleDeleteTag : handlePostTag}
|
||||
onMouseEnter={this.handleMouseEnter}
|
||||
onMouseLeave={this.handleMouseLeave} >
|
||||
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
import {compose} from 'react-apollo';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import ModActionButton from '../components/ModActionButton';
|
||||
import {withTags} from 'plugin-api/beta/client/hocs';
|
||||
import {withTags, connect} from 'plugin-api/beta/client/hocs';
|
||||
import {closeTooltip} from 'plugins/talk-plugin-moderation-actions/client/actions';
|
||||
|
||||
const mapDispatchToProps = (dispatch) =>
|
||||
bindActionCreators({
|
||||
closeTooltip,
|
||||
}, dispatch);
|
||||
|
||||
const enhance = compose(
|
||||
withTags('featured'),
|
||||
connect(null, mapDispatchToProps),
|
||||
);
|
||||
|
||||
export default enhance(ModActionButton);
|
||||
|
||||
@@ -61,17 +61,6 @@ export default {
|
||||
if (previous.asset.comments) {
|
||||
updated = update(previous, {
|
||||
asset: {
|
||||
comments: {
|
||||
nodes: {
|
||||
$apply: (nodes) => nodes.map((node) => {
|
||||
if (node.id === variables.id) {
|
||||
node.status = 'ACCEPTED';
|
||||
}
|
||||
|
||||
return node;
|
||||
})
|
||||
}
|
||||
},
|
||||
featuredComments: {
|
||||
nodes: {
|
||||
$apply: (nodes) => prependNewNodes(nodes, [comment]),
|
||||
@@ -89,14 +78,14 @@ export default {
|
||||
},
|
||||
update: (proxy) => {
|
||||
|
||||
if (name !== 'FEATURED') {
|
||||
if (variables.name !== 'FEATURED') {
|
||||
return;
|
||||
}
|
||||
|
||||
const fragmentId = `Comment_${variables.id}`;
|
||||
|
||||
const fragment = gql`
|
||||
fragment Talk_ModerationActions_addTag on Comment {
|
||||
fragment Talk_FeaturedComments_addTag on Comment {
|
||||
status
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -7,17 +7,15 @@ import cn from 'classnames';
|
||||
const isApproved = (status) => (status === 'ACCEPTED');
|
||||
|
||||
export default ({approveComment, comment: {status}}) => (
|
||||
<button className={cn(styles.button, {[styles.approved]: isApproved(status)}, 'talk-plugin-moderation-actions-reject')} onClick={approveComment}>
|
||||
{isApproved(status) ? (
|
||||
<span>
|
||||
<Icon name="check_circle" className={styles.icon} />
|
||||
{t('talk-plugin-moderation-actions.approved_comment')}
|
||||
</span>
|
||||
) : (
|
||||
<span>
|
||||
<Icon name="done" className={styles.icon} />
|
||||
{t('talk-plugin-moderation-actions.approve_comment')}
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
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-reject')} onClick={approveComment}>
|
||||
<Icon name="done" className={styles.icon} />
|
||||
{t('talk-plugin-moderation-actions.approve_comment')}
|
||||
</button>
|
||||
)
|
||||
);
|
||||
|
||||
@@ -28,8 +28,8 @@ export default class ModerationActions extends React.Component {
|
||||
data={data}
|
||||
hideMenu={hideMenu}
|
||||
/>
|
||||
<ApproveCommentAction comment={comment} />
|
||||
<RejectCommentAction comment={comment} />
|
||||
<ApproveCommentAction comment={comment} hideTooltip={hideTooltip} />
|
||||
<RejectCommentAction comment={comment} hideTooltip={hideTooltip} />
|
||||
</Menu>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
}
|
||||
|
||||
.approved {
|
||||
display: inline-block;
|
||||
color: #519954;
|
||||
font-weight: bold;
|
||||
padding: 6px;
|
||||
}
|
||||
@@ -1,27 +1,28 @@
|
||||
import React from 'react';
|
||||
import {compose} from 'react-apollo';
|
||||
import {closeMenu} from '../actions';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import {connect} from 'plugin-api/beta/client/hocs';
|
||||
import {getErrorMessages} from 'plugin-api/beta/client/utils';
|
||||
import {withSetCommentStatus} from 'plugin-api/beta/client/hocs';
|
||||
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 = () => {
|
||||
const {setCommentStatus, closeMenu, comment} = this.props;
|
||||
|
||||
approveComment = async () => {
|
||||
const {setCommentStatus, comment, hideMenu, notify} = this.props;
|
||||
|
||||
try {
|
||||
setCommentStatus({
|
||||
await setCommentStatus({
|
||||
commentId: comment.id,
|
||||
status: 'ACCEPTED'
|
||||
});
|
||||
|
||||
closeMenu();
|
||||
} catch (err) {
|
||||
}
|
||||
catch(err) {
|
||||
notify('error', getErrorMessages(err));
|
||||
}
|
||||
|
||||
hideMenu();
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -31,8 +32,7 @@ class ApproveCommentActionContainer extends React.Component {
|
||||
|
||||
const mapDispatchToProps = (dispatch) =>
|
||||
bindActionCreators({
|
||||
notify,
|
||||
closeMenu
|
||||
notify
|
||||
}, dispatch);
|
||||
|
||||
const enhance = compose(
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React from 'react';
|
||||
import {compose} from 'react-apollo';
|
||||
import {closeMenu} from '../actions';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import {getErrorMessages} from 'plugin-api/beta/client/utils';
|
||||
import {connect} from 'plugin-api/beta/client/hocs';
|
||||
import {getErrorMessages} from 'plugin-api/beta/client/utils'
|
||||
import {withSetCommentStatus} from 'plugin-api/beta/client/hocs';
|
||||
import {notify} from 'plugin-api/beta/client/actions/notification';
|
||||
import RejectCommentAction from '../components/RejectCommentAction';
|
||||
import {connect, withSetCommentStatus} from 'plugin-api/beta/client/hocs';
|
||||
@@ -10,18 +10,19 @@ import {connect, withSetCommentStatus} from 'plugin-api/beta/client/hocs';
|
||||
class RejectCommentActionContainer extends React.Component {
|
||||
|
||||
rejectComment = () => {
|
||||
const {setCommentStatus, closeMenu, comment} = this.props;
|
||||
|
||||
const {setCommentStatus, comment, hideMenu, notify} = this.props;
|
||||
|
||||
try {
|
||||
setCommentStatus({
|
||||
await setCommentStatus({
|
||||
commentId: comment.id,
|
||||
status: 'REJECTED'
|
||||
});
|
||||
|
||||
closeMenu();
|
||||
} catch (err) {
|
||||
}
|
||||
catch(err) {
|
||||
notify('error', getErrorMessages(err));
|
||||
}
|
||||
|
||||
hideMenu();
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -31,8 +32,7 @@ class RejectCommentActionContainer extends React.Component {
|
||||
|
||||
const mapDispatchToProps = (dispatch) =>
|
||||
bindActionCreators({
|
||||
notify,
|
||||
closeMenu
|
||||
notify
|
||||
}, dispatch);
|
||||
|
||||
const enhance = compose(
|
||||
|
||||
Reference in New Issue
Block a user