From: Jay Sitter Date: Sun, 25 Jun 2023 22:01:25 +0000 (-0400) Subject: chore: Separate post mod buttons into functions X-Git-Url: http://these/git/ui/assets/static/%7Bthis.state.url%7D?a=commitdiff_plain;h=f27bb07fcd0658e4b5a6e9024ad87ad8c4d56027;p=lemmy-ui.git chore: Separate post mod buttons into functions --- diff --git a/src/shared/components/post/post-listing.tsx b/src/shared/components/post/post-listing.tsx index ac90b0d..3cc931b 100644 --- a/src/shared/components/post/post-listing.tsx +++ b/src/shared/components/post/post-listing.tsx @@ -718,6 +718,94 @@ 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}
  • + )} + + )} + + {/* 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) ? ( +
  • {modBanButton}
  • + ) : ( +
  • {modUnbanButton}
  • + )} +
  • {purgePersonButton}
  • +
  • {purgePostButton}
  • + + )} + {!isBanned(post_view.creator) && post_view.creator.local && ( +
  • {toggleAdminButton}
  • + )} + + )} @@ -982,6 +1070,121 @@ export class PostListing extends Component { ); } + get modBanFromCommunityButton() { + return ( + + ); + } + + get modUnbanFromCommunityButton() { + return ( + + ); + } + + get addModToCommunityButton() { + return ( + + ); + } + + get modBanButton() { + return ( + + ); + } + + get modUnbanButton() { + return ( + + ); + } + + get purgePersonButton() { + return ( + + ); + } + + get purgePostButton() { + return ( + + ); + } + + get toggleAdminButton() { + return ( + + ); + } + get modRemoveButton() { const removed = this.postView.post.removed; return ( @@ -1011,170 +1214,7 @@ export class PostListing extends Component { // TODO: make nicer const post_view = this.postView; return ( - this.state.showAdvanced && ( -
    - {this.canMod_ && ( - <> - {!this.creatorIsMod_ && - (!post_view.creator_banned_from_community ? ( - - ) : ( - - ))} - {!post_view.creator_banned_from_community && ( - - )} - - )} - {/* 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) ? ( - - ) : ( - - )} - - - - )} - {!isBanned(post_view.creator) && post_view.creator.local && ( - - )} - - )} -
    - ) + this.state.showAdvanced &&
    ); }