X-Git-Url: http://these/git/?a=blobdiff_plain;f=src%2Fshared%2Fcomponents%2Fpost%2Fpost-listing.tsx;h=eb4dc8d974807547758e5d785ece3debf0510c35;hb=9ce164245f51b834997f31f3f12497ee87474965;hp=3d373ee012cf3beb5adf1491a955ba987e3862a7;hpb=ee84634a73e2904f39bc7bb1b46fc102778ca156;p=lemmy-ui.git diff --git a/src/shared/components/post/post-listing.tsx b/src/shared/components/post/post-listing.tsx index 3d373ee..eb4dc8d 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"; @@ -105,6 +106,9 @@ interface PostListingProps { allLanguages: Language[]; siteLanguages: number[]; showCommunity?: boolean; + /** + * Controls whether to show both the body *and* the metadata preview card + */ showBody?: boolean; hideImage?: boolean; enableDownvotes?: boolean; @@ -200,7 +204,7 @@ export class PostListing extends Component { <> {this.listing()} {this.state.imageExpanded && !this.props.hideImage && this.img} - {post.url && this.state.showBody && post.embed_title && ( + {this.showBody && post.url && post.embed_title && ( )} {this.showBody && this.body()} @@ -330,7 +334,7 @@ export class PostListing extends Component { return ( - ); - } - postActions() { // Possible enhancement: Priority+ pattern instead of just hard coding which get hidden behind the show more button. // Possible enhancement: Make each button a component. @@ -662,18 +646,11 @@ export class PostListing extends Component { {this.saveButton} {this.crossPostButton} - {/** - * If there is a URL, or if the post has a body and we were told not to - * show the body, show the MetadataCard/body toggle. - */} - {(post.url || (post.body && !this.props.showBody)) && - this.showPreviewButton()} - - {this.showBody && post_view.post.body && this.viewSourceButton} + {this.props.showBody && post_view.post.body && this.viewSourceButton}
@@ -762,7 +783,7 @@ export class PostListing extends Component { : I18NextService.i18n.t("save"); return ( @@ -993,9 +1013,8 @@ export class PostListing extends Component { get modUnbanFromCommunityButton() { return ( @@ -1005,20 +1024,15 @@ export class PostListing extends Component { get addModToCommunityButton() { return ( ); @@ -1027,11 +1041,10 @@ export class PostListing extends Component { get modBanButton() { return ( ); } @@ -1039,14 +1052,13 @@ export class PostListing extends Component { get modUnbanButton() { return ( ); @@ -1055,11 +1067,10 @@ export class PostListing extends Component { get purgePersonButton() { return ( ); } @@ -1067,11 +1078,10 @@ export class PostListing extends Component { get purgePostButton() { return ( ); } @@ -1079,20 +1089,31 @@ export class PostListing extends Component { get toggleAdminButton() { return ( ); } + get transferCommunityButton() { + return ( + + ); + } + get modRemoveButton() { const removed = this.postView.post.removed; return ( @@ -1107,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 = @@ -1230,11 +1166,7 @@ export class PostListing extends Component { value={this.state.removeReason} onInput={linkEvent(this, this.handleModRemoveReasonChange)} /> - )} + {this.state.showConfirmTransferCommunity && ( + <> + + + + + )} {this.state.showBanDialog && (
@@ -1296,11 +1255,7 @@ export class PostListing extends Component { {/* */} {/*
*/}
- )} @@ -1380,10 +1327,10 @@ export class PostListing extends Component { const post = this.postView.post; return post.thumbnail_url || (post.url && isImage(post.url)) ? (
-
+
{this.postTitleLine()}
-
+
{/* Post thumbnail */} {!this.state.imageExpanded && this.thumbnail()}
@@ -1393,15 +1340,18 @@ export class PostListing extends Component { ); } - showBodyPreview() { - const { body, id } = this.postView.post; - - return !this.showBody && body ? ( - -
{body}
- - ) : ( - <> + showPreviewButton() { + return ( + ); } @@ -1418,7 +1368,6 @@ export class PostListing extends Component { {this.mobileThumbnail()} {this.commentsLine(true)} - {this.userActionsLine()} {this.duplicatesLine()} {this.removeAndBanDialogs()}
@@ -1442,15 +1391,14 @@ export class PostListing extends Component { )}
-
+
{this.thumbnail()}
-
+
{this.postTitleLine()} {this.createdLine()} {this.commentsLine()} {this.duplicatesLine()} - {this.userActionsLine()} {this.removeAndBanDialogs()}
@@ -1467,6 +1415,7 @@ export class PostListing extends Component { UserService.Instance.myUserInfo?.local_user_view.person.id ); } + handleEditClick(i: PostListing) { i.setState({ showEdit: true }); } @@ -1590,6 +1539,7 @@ export class PostListing extends Component { post_id: i.postView.post.id, removed: !i.postView.post.removed, auth: myAuthRequired(), + reason: i.state.removeReason, }); } @@ -1661,13 +1611,13 @@ export class PostListing extends Component { handlePurgeSubmit(i: PostListing, event: any) { event.preventDefault(); i.setState({ purgeLoading: true }); - if (i.state.purgeType == PurgeType.Person) { + if (i.state.purgeType === PurgeType.Person) { i.props.onPurgePerson({ person_id: i.postView.creator.id, reason: i.state.purgeReason, auth: myAuthRequired(), }); - } else if (i.state.purgeType == PurgeType.Post) { + } else if (i.state.purgeType === PurgeType.Post) { i.props.onPurgePost({ post_id: i.postView.post.id, reason: i.state.purgeReason,