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/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/%22https:/hacktivis.me/%7BinboxRss%7D?a=commitdiff_plain;h=ba5cafef08a293674d7e585ba7617e3fc74c9014;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 76a3e44..7669098 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 &&
    ); }