From: Jay Sitter Date: Thu, 29 Jun 2023 02:43:44 +0000 (-0400) Subject: fix: Add user action buttons to post dropdown #1653 (#1655) X-Git-Url: http://these/git/%7B%60%24%7BarchiveUrl%7D/static/gitweb.js?a=commitdiff_plain;h=a30c112048848e208f3048d3231cdb12332088d9;p=lemmy-ui.git fix: Add user action buttons to post dropdown #1653 (#1655) * fix: Add user action buttons to post dropdown #1653 * fix: Fix alignment of preview mini-overlay buttons on thumbs * fix: Restore mdNoImages import * fix: Change style and capitalization of post user action buttons * fix: Move Trasnfer Community button to dropdown * fix: Remove some changes that shouldn't have been in here * chore: Empty commit to re-trigger Woodpecker * fix: Remove some unnecessary aria-labels * fix: Capitalize first letter on transfer community button * chore: Empty commit to re-trigger Woodpecker --------- Co-authored-by: Alec Armbruster <35377827+alectrocute@users.noreply.github.com> Co-authored-by: Dessalines --- diff --git a/src/shared/components/post/post-listing.tsx b/src/shared/components/post/post-listing.tsx index eb3d0f6..15b015f 100644 --- a/src/shared/components/post/post-listing.tsx +++ b/src/shared/components/post/post-listing.tsx @@ -702,6 +702,50 @@ export class PostListing extends Component { {(this.canMod_ || this.canAdmin_) && (
  • {this.modRemoveButton}
  • )} + + {this.canMod_ && ( + <> +
  • +
    +
  • + {!this.creatorIsMod_ && + (!post_view.creator_banned_from_community ? ( +
  • {this.modBanFromCommunityButton}
  • + ) : ( +
  • {this.modUnbanFromCommunityButton}
  • + ))} + {!post_view.creator_banned_from_community && ( +
  • {this.addModToCommunityButton}
  • + )} + + )} + + {(amCommunityCreator(post_view.creator.id, this.props.moderators) || + this.canAdmin_) && + this.creatorIsMod_ &&
  • {this.transferCommunityButton}
  • } + + {/* Admins can ban from all, and appoint other admins */} + {this.canAdmin_ && ( + <> +
  • +
    +
  • + {!this.creatorIsAdmin_ && ( + <> + {!isBanned(post_view.creator) ? ( +
  • {this.modBanButton}
  • + ) : ( +
  • {this.modUnbanButton}
  • + )} +
  • {this.purgePersonButton}
  • +
  • {this.purgePostButton}
  • + + )} + {!isBanned(post_view.creator) && post_view.creator.local && ( +
  • {this.toggleAdminButton}
  • + )} + + )} @@ -969,9 +1013,8 @@ export class PostListing extends Component { get modBanFromCommunityButton() { return ( @@ -981,9 +1024,8 @@ export class PostListing extends Component { get modUnbanFromCommunityButton() { return ( @@ -993,20 +1035,15 @@ export class PostListing extends Component { get addModToCommunityButton() { return ( ); @@ -1015,11 +1052,10 @@ export class PostListing extends Component { get modBanButton() { return ( ); } @@ -1027,14 +1063,13 @@ export class PostListing extends Component { get modUnbanButton() { return ( ); @@ -1043,11 +1078,10 @@ export class PostListing extends Component { get purgePersonButton() { return ( ); } @@ -1055,11 +1089,10 @@ export class PostListing extends Component { get purgePostButton() { return ( ); } @@ -1067,20 +1100,31 @@ export class PostListing extends Component { get toggleAdminButton() { return ( ); } + get transferCommunityButton() { + return ( + + ); + } + get modRemoveButton() { const removed = this.postView.post.removed; return ( @@ -1095,102 +1139,17 @@ export class PostListing extends Component { {this.state.removeLoading ? ( ) : !removed ? ( - I18NextService.i18n.t("remove") + capitalizeFirstLetter(I18NextService.i18n.t("remove_post")) ) : ( - I18NextService.i18n.t("restore") + <> + {capitalizeFirstLetter(I18NextService.i18n.t("restore"))}{" "} + {I18NextService.i18n.t("post")} + )} ); } - /** - * Mod/Admin actions to be taken against the author. - */ - userActionsLine() { - // TODO: make nicer - const post_view = this.postView; - return ( - this.state.showAdvanced && ( -
    - {this.canMod_ && ( - <> - {!this.creatorIsMod_ && - (!post_view.creator_banned_from_community - ? this.modBanFromCommunityButton - : this.modUnbanFromCommunityButton)} - {!post_view.creator_banned_from_community && - this.addModToCommunityButton} - - )} - - {/* Community creators and admins can transfer community to another mod */} - {(amCommunityCreator(post_view.creator.id, this.props.moderators) || - this.canAdmin_) && - this.creatorIsMod_ && - (!this.state.showConfirmTransferCommunity ? ( - - ) : ( - <> - - - - - ))} - {/* Admins can ban from all, and appoint other admins */} - {this.canAdmin_ && ( - <> - {!this.creatorIsAdmin_ && ( - <> - {!isBanned(post_view.creator) - ? this.modBanButton - : this.modUnbanButton} - {this.purgePersonButton} - {this.purgePostButton} - - )} - {!isBanned(post_view.creator) && - post_view.creator.local && - this.toggleAdminButton} - - )} -
    - ) - ); - } - removeAndBanDialogs() { const post = this.postView; const purgeTypeText = @@ -1218,11 +1177,7 @@ export class PostListing extends Component { value={this.state.removeReason} onInput={linkEvent(this, this.handleModRemoveReasonChange)} /> - )} + {this.state.showConfirmTransferCommunity && ( + <> + + + + + )} {this.state.showBanDialog && (
    @@ -1284,11 +1266,7 @@ export class PostListing extends Component { {/* */} {/*
    */}
    - )} @@ -1409,7 +1379,6 @@ export class PostListing extends Component { {this.mobileThumbnail()} {this.commentsLine(true)} - {this.userActionsLine()} {this.duplicatesLine()} {this.removeAndBanDialogs()}
    @@ -1441,7 +1410,6 @@ export class PostListing extends Component { {this.createdLine()} {this.commentsLine()} {this.duplicatesLine()} - {this.userActionsLine()} {this.removeAndBanDialogs()}