From: Dessalines Date: Thu, 2 Jan 2020 03:09:07 +0000 (-0500) Subject: Add are you sure dialogs to mod actions. X-Git-Url: http://these/git/%22https:/image.com/README.es.md?a=commitdiff_plain;h=f05b50020f571857f92ea22e49e03bb9b9bb1c46;p=lemmy.git Add are you sure dialogs to mod actions. - Fixes #386 --- diff --git a/ui/src/components/comment-node.tsx b/ui/src/components/comment-node.tsx index 34ec0dfb..b3ca682b 100644 --- a/ui/src/components/comment-node.tsx +++ b/ui/src/components/comment-node.tsx @@ -42,6 +42,8 @@ interface CommentNodeState { banType: BanType; showConfirmTransferSite: boolean; showConfirmTransferCommunity: boolean; + showConfirmAppointAsMod: boolean; + showConfirmAppointAsAdmin: boolean; collapsed: boolean; viewSource: boolean; } @@ -71,6 +73,8 @@ export class CommentNode extends Component { viewSource: false, showConfirmTransferSite: false, showConfirmTransferCommunity: false, + showConfirmAppointAsMod: false, + showConfirmAppointAsAdmin: false, }; constructor(props: any, context: any) { @@ -206,6 +210,18 @@ export class CommentNode extends Component { /> )}
    + {this.props.markable && ( +
  • + + {node.comment.read + ? i18n.t('mark_as_unread') + : i18n.t('mark_as_read')} + +
  • + )} {UserService.Instance.user && !this.props.viewOnly && ( <>
  • @@ -246,28 +262,51 @@ export class CommentNode extends Component {
  • )} +
  • •
  • +
  • + + # + +
  • +
  • + + # + +
  • {/* Admins and mods can remove comments */} {(this.canMod || this.canAdmin) && ( -
  • - {!node.comment.removed ? ( - - # - - ) : ( - - # - - )} -
  • + <> +
  • •
  • +
  • + {!node.comment.removed ? ( + + # + + ) : ( + + # + + )} +
  • + )} {/* Mods can ban from community, and appoint as mods to community */} {this.canMod && ( @@ -299,17 +338,43 @@ export class CommentNode extends Component { )} {!node.comment.banned_from_community && (
  • - - {this.isMod - ? i18n.t('remove_as_mod') - : i18n.t('appoint_as_mod')} - + {!this.state.showConfirmAppointAsMod ? ( + + {this.isMod + ? i18n.t('remove_as_mod') + : i18n.t('appoint_as_mod')} + + ) : ( + <> + + # + + + # + + + # + + + )}
  • )} @@ -381,14 +446,40 @@ export class CommentNode extends Component { )} {!node.comment.banned && (
  • - - {this.isAdmin - ? i18n.t('remove_as_admin') - : i18n.t('appoint_as_admin')} - + {!this.state.showConfirmAppointAsAdmin ? ( + + {this.isAdmin + ? i18n.t('remove_as_admin') + : i18n.t('appoint_as_admin')} + + ) : ( + <> + + # + + + # + + + # + + + )}
  • )} @@ -432,34 +523,6 @@ export class CommentNode extends Component { )} )} -
  • - - # - -
  • -
  • - - # - -
  • - {this.props.markable && ( -
  • - - {node.comment.read - ? i18n.t('mark_as_unread') - : i18n.t('mark_as_read')} - -
  • - )}
)} @@ -725,13 +788,13 @@ export class CommentNode extends Component { } handleModBanFromCommunityShow(i: CommentNode) { - i.state.showBanDialog = true; + i.state.showBanDialog = !i.state.showBanDialog; i.state.banType = BanType.Community; i.setState(i.state); } handleModBanShow(i: CommentNode) { - i.state.showBanDialog = true; + i.state.showBanDialog = !i.state.showBanDialog; i.state.banType = BanType.Site; i.setState(i.state); } @@ -784,6 +847,16 @@ export class CommentNode extends Component { i.setState(i.state); } + handleShowConfirmAppointAsMod(i: CommentNode) { + i.state.showConfirmAppointAsMod = true; + i.setState(i.state); + } + + handleCancelConfirmAppointAsMod(i: CommentNode) { + i.state.showConfirmAppointAsMod = false; + i.setState(i.state); + } + handleAddModToCommunity(i: CommentNode) { let form: AddModToCommunityForm = { user_id: i.props.node.comment.creator_id, @@ -791,6 +864,17 @@ export class CommentNode extends Component { added: !i.isMod, }; WebSocketService.Instance.addModToCommunity(form); + i.state.showConfirmAppointAsMod = false; + i.setState(i.state); + } + + handleShowConfirmAppointAsAdmin(i: CommentNode) { + i.state.showConfirmAppointAsAdmin = true; + i.setState(i.state); + } + + handleCancelConfirmAppointAsAdmin(i: CommentNode) { + i.state.showConfirmAppointAsAdmin = false; i.setState(i.state); } @@ -800,6 +884,7 @@ export class CommentNode extends Component { added: !i.isAdmin, }; WebSocketService.Instance.addAdmin(form); + i.state.showConfirmAppointAsAdmin = false; i.setState(i.state); }