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/readmes/README.ja.md?a=commitdiff_plain;h=7e7bbde72108a85e89c8f00383ca39e85b937136;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 1c305e8..ed2658e 100644 --- a/src/shared/components/post/post-listing.tsx +++ b/src/shared/components/post/post-listing.tsx @@ -688,6 +688,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}
  • + )} + + )} @@ -952,6 +1040,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 ( @@ -981,170 +1184,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 &&
    ); }