From: Dessalines Date: Sun, 1 Mar 2020 03:06:42 +0000 (-0500) Subject: Adding more for advanced actions on comments and posts. X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/readmes/%7B%7D/%22%7Burl%7D/%24%7Bargs.pageFn.jump%20n%7D?a=commitdiff_plain;h=399be2370d375e49183968ba56872c0c198e1812;p=lemmy.git Adding more for advanced actions on comments and posts. - Fixes #561 --- diff --git a/ui/src/components/comment-node.tsx b/ui/src/components/comment-node.tsx index 1d0b12ca..a904eae3 100644 --- a/ui/src/components/comment-node.tsx +++ b/ui/src/components/comment-node.tsx @@ -48,6 +48,7 @@ interface CommentNodeState { showConfirmAppointAsAdmin: boolean; collapsed: boolean; viewSource: boolean; + showAdvanced: boolean; my_vote: number; score: number; upvotes: number; @@ -81,6 +82,7 @@ export class CommentNode extends Component { banType: BanType.Community, collapsed: false, viewSource: false, + showAdvanced: false, showConfirmTransferSite: false, showConfirmTransferCommunity: false, showConfirmAppointAsMod: false, @@ -300,201 +302,259 @@ export class CommentNode extends Component { )} -
  • •
  • -
  • - - {i18n.t('view_source')} - -
  • -
  • - - {i18n.t('link')} - -
  • - {/* Admins and mods can remove comments */} - {(this.canMod || this.canAdmin) && ( + {!this.state.showAdvanced ? ( +
  • + + {i18n.t('more')} + +
  • + ) : ( <>
  • •
  • - {!node.comment.removed ? ( - - {i18n.t('remove')} - - ) : ( - - {i18n.t('restore')} - - )} + + {i18n.t('view_source')} +
  • - - )} - {/* Mods can ban from community, and appoint as mods to community */} - {this.canMod && ( - <> - {!this.isMod && ( -
  • - {!node.comment.banned_from_community ? ( - - {i18n.t('ban')} - - ) : ( - - {i18n.t('unban')} - - )} -
  • - )} - {!node.comment.banned_from_community && ( -
  • - {!this.state.showConfirmAppointAsMod ? ( - - {this.isMod - ? i18n.t('remove_as_mod') - : i18n.t('appoint_as_mod')} - - ) : ( - <> - - {i18n.t('are_you_sure')} - +
  • + + {i18n.t('link')} + +
  • + {/* Admins and mods can remove comments */} + {(this.canMod || this.canAdmin) && ( + <> +
  • •
  • +
  • + {!node.comment.removed ? ( - {i18n.t('yes')} + {i18n.t('remove')} + ) : ( - {i18n.t('no')} + {i18n.t('restore')} - - )} -
  • + )} + + )} - - )} - {/* Community creators and admins can transfer community to another mod */} - {(this.amCommunityCreator || this.canAdmin) && this.isMod && ( -
  • - {!this.state.showConfirmTransferCommunity ? ( - - {i18n.t('transfer_community')} - - ) : ( + {/* Mods can ban from community, and appoint as mods to community */} + {this.canMod && ( <> - - {i18n.t('are_you_sure')} - - - {i18n.t('yes')} - - - {i18n.t('no')} - + {!this.isMod && ( +
  • + {!node.comment.banned_from_community ? ( + + {i18n.t('ban')} + + ) : ( + + {i18n.t('unban')} + + )} +
  • + )} + {!node.comment.banned_from_community && ( +
  • + {!this.state.showConfirmAppointAsMod ? ( + + {this.isMod + ? i18n.t('remove_as_mod') + : i18n.t('appoint_as_mod')} + + ) : ( + <> + + {i18n.t('are_you_sure')} + + + {i18n.t('yes')} + + + {i18n.t('no')} + + + )} +
  • + )} )} - - )} - {/* Admins can ban from all, and appoint other admins */} - {this.canAdmin && ( - <> - {!this.isAdmin && ( -
  • - {!node.comment.banned ? ( - - {i18n.t('ban_from_site')} - - ) : ( - + {!this.state.showConfirmTransferCommunity ? ( + + {i18n.t('transfer_community')} + + ) : ( + <> + + {i18n.t('are_you_sure')} + + + {i18n.t('yes')} + + + {i18n.t('no')} + + + )} +
  • + )} + {/* Admins can ban from all, and appoint other admins */} + {this.canAdmin && ( + <> + {!this.isAdmin && ( +
  • + {!node.comment.banned ? ( + + {i18n.t('ban_from_site')} + + ) : ( + + {i18n.t('unban_from_site')} + )} - > - {i18n.t('unban_from_site')} - +
  • )} - + {!node.comment.banned && ( +
  • + {!this.state.showConfirmAppointAsAdmin ? ( + + {this.isAdmin + ? i18n.t('remove_as_admin') + : i18n.t('appoint_as_admin')} + + ) : ( + <> + + {i18n.t('are_you_sure')} + + + {i18n.t('yes')} + + + {i18n.t('no')} + + + )} +
  • + )} + )} - {!node.comment.banned && ( + {/* Site Creator can transfer to another admin */} + {this.amSiteCreator && this.isAdmin && (
  • - {!this.state.showConfirmAppointAsAdmin ? ( + {!this.state.showConfirmTransferSite ? ( - {this.isAdmin - ? i18n.t('remove_as_admin') - : i18n.t('appoint_as_admin')} + {i18n.t('transfer_site')} ) : ( <> @@ -503,7 +563,10 @@ export class CommentNode extends Component { {i18n.t('yes')} @@ -511,7 +574,7 @@ export class CommentNode extends Component { class="pointer d-inline-block" onClick={linkEvent( this, - this.handleCancelConfirmAppointAsAdmin + this.handleCancelShowConfirmTransferSite )} > {i18n.t('no')} @@ -522,43 +585,6 @@ export class CommentNode extends Component { )} )} - {/* Site Creator can transfer to another admin */} - {this.amSiteCreator && this.isAdmin && ( -
  • - {!this.state.showConfirmTransferSite ? ( - - {i18n.t('transfer_site')} - - ) : ( - <> - - {i18n.t('are_you_sure')} - - - {i18n.t('yes')} - - - {i18n.t('no')} - - - )} -
  • - )} )} @@ -1016,4 +1042,9 @@ export class CommentNode extends Component { i.state.viewSource = !i.state.viewSource; i.setState(i.state); } + + handleShowAdvanced(i: CommentNode) { + i.state.showAdvanced = !i.state.showAdvanced; + i.setState(i.state); + } } diff --git a/ui/src/components/post-listing.tsx b/ui/src/components/post-listing.tsx index 1fdfad2d..d57aa663 100644 --- a/ui/src/components/post-listing.tsx +++ b/ui/src/components/post-listing.tsx @@ -45,6 +45,7 @@ interface PostListingState { showConfirmTransferCommunity: boolean; imageExpanded: boolean; viewSource: boolean; + showAdvanced: boolean; my_vote: number; score: number; upvotes: number; @@ -75,6 +76,7 @@ export class PostListing extends Component { showConfirmTransferCommunity: false, imageExpanded: false, viewSource: false, + showAdvanced: false, my_vote: this.props.post.my_vote, score: this.props.post.score, upvotes: this.props.post.upvotes, @@ -511,211 +513,238 @@ export class PostListing extends Component { )} - {this.canModOnSelf && ( - <> -
  • - - {post.locked ? i18n.t('unlock') : i18n.t('lock')} - -
  • -
  • - - {post.stickied - ? i18n.t('unsticky') - : i18n.t('sticky')} - -
  • - - )} - {/* Mods can ban from community, and appoint as mods to community */} - {(this.canMod || this.canAdmin) && ( + + {!this.state.showAdvanced && this.props.showBody ? (
  • - {!post.removed ? ( - - {i18n.t('remove')} - - ) : ( - - {i18n.t('restore')} - - )} + + {i18n.t('more')} +
  • - )} - {this.canMod && ( + ) : ( <> - {!this.isMod && ( + {this.canModOnSelf && ( + <> +
  • + + {post.locked + ? i18n.t('unlock') + : i18n.t('lock')} + +
  • +
  • + + {post.stickied + ? i18n.t('unsticky') + : i18n.t('sticky')} + +
  • + + )} + {/* Mods can ban from community, and appoint as mods to community */} + {(this.canMod || this.canAdmin) && (
  • - {!post.banned_from_community ? ( + {!post.removed ? ( - {i18n.t('ban')} + {i18n.t('remove')} ) : ( - {i18n.t('unban')} + {i18n.t('restore')} )}
  • )} - {!post.banned_from_community && ( -
  • - - {this.isMod - ? i18n.t('remove_as_mod') - : i18n.t('appoint_as_mod')} - -
  • - )} - - )} - {/* Community creators and admins can transfer community to another mod */} - {(this.amCommunityCreator || this.canAdmin) && this.isMod && ( -
  • - {!this.state.showConfirmTransferCommunity ? ( - - {i18n.t('transfer_community')} - - ) : ( + {this.canMod && ( <> - - {i18n.t('are_you_sure')} - - - {i18n.t('yes')} - - + {!post.banned_from_community ? ( + + {i18n.t('ban')} + + ) : ( + + {i18n.t('unban')} + + )} +
  • + )} + {!post.banned_from_community && ( +
  • + + {this.isMod + ? i18n.t('remove_as_mod') + : i18n.t('appoint_as_mod')} + +
  • + )} + + )} + {/* Community creators and admins can transfer community to another mod */} + {(this.amCommunityCreator || this.canAdmin) && + this.isMod && ( +
  • + {!this.state.showConfirmTransferCommunity ? ( + + {i18n.t('transfer_community')} + + ) : ( + <> + + {i18n.t('are_you_sure')} + + + {i18n.t('yes')} + + + {i18n.t('no')} + + )} - > - {i18n.t('no')} - +
  • + )} + {/* Admins can ban from all, and appoint other admins */} + {this.canAdmin && ( + <> + {!this.isAdmin && ( +
  • + {!post.banned ? ( + + {i18n.t('ban_from_site')} + + ) : ( + + {i18n.t('unban_from_site')} + + )} +
  • + )} + {!post.banned && ( +
  • + + {this.isAdmin + ? i18n.t('remove_as_admin') + : i18n.t('appoint_as_admin')} + +
  • + )} )} - - )} - {/* Admins can ban from all, and appoint other admins */} - {this.canAdmin && ( - <> - {!this.isAdmin && ( + {/* Site Creator can transfer to another admin */} + {this.amSiteCreator && this.isAdmin && (
  • - {!post.banned ? ( - - {i18n.t('ban_from_site')} - - ) : ( + {!this.state.showConfirmTransferSite ? ( - {i18n.t('unban_from_site')} + {i18n.t('transfer_site')} + ) : ( + <> + + {i18n.t('are_you_sure')} + + + {i18n.t('yes')} + + + {i18n.t('no')} + + )}
  • )} - {!post.banned && ( -
  • - - {this.isAdmin - ? i18n.t('remove_as_admin') - : i18n.t('appoint_as_admin')} - -
  • - )} )} - {/* Site Creator can transfer to another admin */} - {this.amSiteCreator && this.isAdmin && ( -
  • - {!this.state.showConfirmTransferSite ? ( - - {i18n.t('transfer_site')} - - ) : ( - <> - - {i18n.t('are_you_sure')} - - - {i18n.t('yes')} - - - {i18n.t('no')} - - - )} -
  • - )} )} {this.props.showBody && post.body && ( @@ -1201,4 +1230,9 @@ export class PostListing extends Component { i.state.viewSource = !i.state.viewSource; i.setState(i.state); } + + handleShowAdvanced(i: PostListing) { + i.state.showAdvanced = !i.state.showAdvanced; + i.setState(i.state); + } } diff --git a/ui/translations/en.json b/ui/translations/en.json index 54460022..8b719c71 100644 --- a/ui/translations/en.json +++ b/ui/translations/en.json @@ -29,6 +29,7 @@ "message": "Message", "edit": "edit", "reply": "reply", + "more": "more", "cancel": "Cancel", "preview": "Preview", "upload_image": "upload image",