X-Git-Url: http://these/git/?a=blobdiff_plain;f=src%2Fshared%2Fcomponents%2Fpost%2Fpost-listing.tsx;h=bc853b37f846594aaf1c2f044a3034eb6799c118;hb=9869b911cf480ee88c7b1e7d2f689cc2e1c65157;hp=b9a191316f0f121082eca5c213c93e809a8595a9;hpb=06736c3df1b3ed6fa8af9c362677e7be4a7a32d7;p=lemmy-ui.git diff --git a/src/shared/components/post/post-listing.tsx b/src/shared/components/post/post-listing.tsx index b9a1913..bc853b3 100644 --- a/src/shared/components/post/post-listing.tsx +++ b/src/shared/components/post/post-listing.tsx @@ -55,6 +55,7 @@ import { setupTippy } from "../../tippy"; import { Icon, PurgeWarning, Spinner } from "../common/icon"; import { MomentTime } from "../common/moment-time"; import { PictrsImage } from "../common/pictrs-image"; +import { UserBadges } from "../common/user-badges"; import { VoteButtons, VoteButtonsCompact } from "../common/vote-buttons"; import { CommunityLink } from "../community/community-link"; import { PersonListing } from "../person/person-listing"; @@ -331,27 +332,33 @@ export class PostListing extends Component { if (!this.props.hideImage && url && isImage(url) && this.imageSrc) { return ( - {this.imgThumb(this.imageSrc)} - - + + ); } else if (!this.props.hideImage && url && thumbnail && this.imageSrc) { return ( {this.imgThumb(this.imageSrc)} - + ); } else if (url) { @@ -397,24 +404,16 @@ export class PostListing extends Component { createdLine() { const post_view = this.postView; + return ( - +
- {this.creatorIsMod_ && ( - - {I18NextService.i18n.t("mod")} - - )} - {this.creatorIsAdmin_ && ( - - {I18NextService.i18n.t("admin")} - - )} - {post_view.creator.bot_account && ( - - {I18NextService.i18n.t("bot_account").toLowerCase()} - - )} + {this.props.showCommunity && ( <> {" "} @@ -436,7 +435,7 @@ export class PostListing extends Component { published={post_view.post.published} updated={post_view.post.updated} /> - +
); } @@ -692,6 +691,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}
  • + )} + + )} @@ -959,9 +1002,8 @@ export class PostListing extends Component { get modBanFromCommunityButton() { return ( @@ -971,9 +1013,8 @@ export class PostListing extends Component { get modUnbanFromCommunityButton() { return ( @@ -983,20 +1024,15 @@ export class PostListing extends Component { get addModToCommunityButton() { return ( ); @@ -1005,11 +1041,10 @@ export class PostListing extends Component { get modBanButton() { return ( ); } @@ -1017,14 +1052,13 @@ export class PostListing extends Component { get modUnbanButton() { return ( ); @@ -1033,11 +1067,10 @@ export class PostListing extends Component { get purgePersonButton() { return ( ); } @@ -1045,11 +1078,10 @@ export class PostListing extends Component { get purgePostButton() { return ( ); } @@ -1057,20 +1089,31 @@ export class PostListing extends Component { get toggleAdminButton() { return ( ); } + get transferCommunityButton() { + return ( + + ); + } + get modRemoveButton() { const removed = this.postView.post.removed; return ( @@ -1085,102 +1128,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 = @@ -1208,11 +1166,7 @@ export class PostListing extends Component { value={this.state.removeReason} onInput={linkEvent(this, this.handleModRemoveReasonChange)} /> - )} + {this.state.showConfirmTransferCommunity && ( + <> + + + + + )} {this.state.showBanDialog && (
    @@ -1274,11 +1255,7 @@ export class PostListing extends Component { {/* */} {/*
    */}
    - )} @@ -1399,7 +1368,6 @@ export class PostListing extends Component { {this.mobileThumbnail()} {this.commentsLine(true)} - {this.userActionsLine()} {this.duplicatesLine()} {this.removeAndBanDialogs()}
    @@ -1423,15 +1391,14 @@ export class PostListing extends Component { )}
    -
    +
    {this.thumbnail()}
    -
    +
    {this.postTitleLine()} {this.createdLine()} {this.commentsLine()} {this.duplicatesLine()} - {this.userActionsLine()} {this.removeAndBanDialogs()}