mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-12-01 17:38:58 +00:00
* fix: Add user action buttons to post dropdown #1653 * fix: Fix alignment of preview mini-overlay buttons on thumbs * fix: Restore mdNoImages import * fix: Change style and capitalization of post user action buttons * fix: Move Trasnfer Community button to dropdown * fix: Remove some changes that shouldn't have been in here * chore: Empty commit to re-trigger Woodpecker * fix: Remove some unnecessary aria-labels * fix: Capitalize first letter on transfer community button * chore: Empty commit to re-trigger Woodpecker --------- Co-authored-by: Alec Armbruster <35377827+alectrocute@users.noreply.github.com> Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
This commit is contained in:
parent
4674f6ff57
commit
a30c112048
|
@ -702,6 +702,50 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
{(this.canMod_ || this.canAdmin_) && (
|
{(this.canMod_ || this.canAdmin_) && (
|
||||||
<li>{this.modRemoveButton}</li>
|
<li>{this.modRemoveButton}</li>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{this.canMod_ && (
|
||||||
|
<>
|
||||||
|
<li>
|
||||||
|
<hr className="dropdown-divider" />
|
||||||
|
</li>
|
||||||
|
{!this.creatorIsMod_ &&
|
||||||
|
(!post_view.creator_banned_from_community ? (
|
||||||
|
<li>{this.modBanFromCommunityButton}</li>
|
||||||
|
) : (
|
||||||
|
<li>{this.modUnbanFromCommunityButton}</li>
|
||||||
|
))}
|
||||||
|
{!post_view.creator_banned_from_community && (
|
||||||
|
<li>{this.addModToCommunityButton}</li>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{(amCommunityCreator(post_view.creator.id, this.props.moderators) ||
|
||||||
|
this.canAdmin_) &&
|
||||||
|
this.creatorIsMod_ && <li>{this.transferCommunityButton}</li>}
|
||||||
|
|
||||||
|
{/* Admins can ban from all, and appoint other admins */}
|
||||||
|
{this.canAdmin_ && (
|
||||||
|
<>
|
||||||
|
<li>
|
||||||
|
<hr className="dropdown-divider" />
|
||||||
|
</li>
|
||||||
|
{!this.creatorIsAdmin_ && (
|
||||||
|
<>
|
||||||
|
{!isBanned(post_view.creator) ? (
|
||||||
|
<li>{this.modBanButton}</li>
|
||||||
|
) : (
|
||||||
|
<li>{this.modUnbanButton}</li>
|
||||||
|
)}
|
||||||
|
<li>{this.purgePersonButton}</li>
|
||||||
|
<li>{this.purgePostButton}</li>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{!isBanned(post_view.creator) && post_view.creator.local && (
|
||||||
|
<li>{this.toggleAdminButton}</li>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
@ -969,9 +1013,8 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
get modBanFromCommunityButton() {
|
get modBanFromCommunityButton() {
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
className="btn btn-link btn-animate text-muted py-0"
|
className="btn btn-link btn-sm d-flex align-items-center rounded-0 dropdown-item"
|
||||||
onClick={linkEvent(this, this.handleModBanFromCommunityShow)}
|
onClick={linkEvent(this, this.handleModBanFromCommunityShow)}
|
||||||
aria-label={I18NextService.i18n.t("ban_from_community")}
|
|
||||||
>
|
>
|
||||||
{I18NextService.i18n.t("ban_from_community")}
|
{I18NextService.i18n.t("ban_from_community")}
|
||||||
</button>
|
</button>
|
||||||
|
@ -981,9 +1024,8 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
get modUnbanFromCommunityButton() {
|
get modUnbanFromCommunityButton() {
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
className="btn btn-link btn-animate text-muted py-0"
|
className="btn btn-link btn-sm d-flex align-items-center rounded-0 dropdown-item"
|
||||||
onClick={linkEvent(this, this.handleModBanFromCommunitySubmit)}
|
onClick={linkEvent(this, this.handleModBanFromCommunitySubmit)}
|
||||||
aria-label={I18NextService.i18n.t("unban")}
|
|
||||||
>
|
>
|
||||||
{this.state.banLoading ? <Spinner /> : I18NextService.i18n.t("unban")}
|
{this.state.banLoading ? <Spinner /> : I18NextService.i18n.t("unban")}
|
||||||
</button>
|
</button>
|
||||||
|
@ -993,20 +1035,15 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
get addModToCommunityButton() {
|
get addModToCommunityButton() {
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
className="btn btn-link btn-animate text-muted py-0"
|
className="btn btn-link btn-sm d-flex align-items-center rounded-0 dropdown-item"
|
||||||
onClick={linkEvent(this, this.handleAddModToCommunity)}
|
onClick={linkEvent(this, this.handleAddModToCommunity)}
|
||||||
aria-label={
|
|
||||||
this.creatorIsMod_
|
|
||||||
? I18NextService.i18n.t("remove_as_mod")
|
|
||||||
: I18NextService.i18n.t("appoint_as_mod")
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
{this.state.addModLoading ? (
|
{this.state.addModLoading ? (
|
||||||
<Spinner />
|
<Spinner />
|
||||||
) : this.creatorIsMod_ ? (
|
) : this.creatorIsMod_ ? (
|
||||||
I18NextService.i18n.t("remove_as_mod")
|
capitalizeFirstLetter(I18NextService.i18n.t("remove_as_mod"))
|
||||||
) : (
|
) : (
|
||||||
I18NextService.i18n.t("appoint_as_mod")
|
capitalizeFirstLetter(I18NextService.i18n.t("appoint_as_mod"))
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
|
@ -1015,11 +1052,10 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
get modBanButton() {
|
get modBanButton() {
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
className="btn btn-link btn-animate text-muted py-0"
|
className="btn btn-link btn-sm d-flex align-items-center rounded-0 dropdown-item"
|
||||||
onClick={linkEvent(this, this.handleModBanShow)}
|
onClick={linkEvent(this, this.handleModBanShow)}
|
||||||
aria-label={I18NextService.i18n.t("ban_from_site")}
|
|
||||||
>
|
>
|
||||||
{I18NextService.i18n.t("ban_from_site")}
|
{capitalizeFirstLetter(I18NextService.i18n.t("ban_from_site"))}
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1027,14 +1063,13 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
get modUnbanButton() {
|
get modUnbanButton() {
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
className="btn btn-link btn-animate text-muted py-0"
|
className="btn btn-link btn-sm d-flex align-items-center rounded-0 dropdown-item"
|
||||||
onClick={linkEvent(this, this.handleModBanSubmit)}
|
onClick={linkEvent(this, this.handleModBanSubmit)}
|
||||||
aria-label={I18NextService.i18n.t("unban_from_site")}
|
|
||||||
>
|
>
|
||||||
{this.state.banLoading ? (
|
{this.state.banLoading ? (
|
||||||
<Spinner />
|
<Spinner />
|
||||||
) : (
|
) : (
|
||||||
I18NextService.i18n.t("unban_from_site")
|
capitalizeFirstLetter(I18NextService.i18n.t("unban_from_site"))
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
|
@ -1043,11 +1078,10 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
get purgePersonButton() {
|
get purgePersonButton() {
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
className="btn btn-link btn-animate text-muted py-0"
|
className="btn btn-link btn-sm d-flex align-items-center rounded-0 dropdown-item"
|
||||||
onClick={linkEvent(this, this.handlePurgePersonShow)}
|
onClick={linkEvent(this, this.handlePurgePersonShow)}
|
||||||
aria-label={I18NextService.i18n.t("purge_user")}
|
|
||||||
>
|
>
|
||||||
{I18NextService.i18n.t("purge_user")}
|
{capitalizeFirstLetter(I18NextService.i18n.t("purge_user"))}
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1055,11 +1089,10 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
get purgePostButton() {
|
get purgePostButton() {
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
className="btn btn-link btn-animate text-muted py-0"
|
className="btn btn-link btn-sm d-flex align-items-center rounded-0 dropdown-item"
|
||||||
onClick={linkEvent(this, this.handlePurgePostShow)}
|
onClick={linkEvent(this, this.handlePurgePostShow)}
|
||||||
aria-label={I18NextService.i18n.t("purge_post")}
|
|
||||||
>
|
>
|
||||||
{I18NextService.i18n.t("purge_post")}
|
{capitalizeFirstLetter(I18NextService.i18n.t("purge_post"))}
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1067,20 +1100,31 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
get toggleAdminButton() {
|
get toggleAdminButton() {
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
className="btn btn-link btn-animate text-muted py-0"
|
className="btn btn-link btn-sm d-flex align-items-center rounded-0 dropdown-item"
|
||||||
onClick={linkEvent(this, this.handleAddAdmin)}
|
onClick={linkEvent(this, this.handleAddAdmin)}
|
||||||
>
|
>
|
||||||
{this.state.addAdminLoading ? (
|
{this.state.addAdminLoading ? (
|
||||||
<Spinner />
|
<Spinner />
|
||||||
) : this.creatorIsAdmin_ ? (
|
) : this.creatorIsAdmin_ ? (
|
||||||
I18NextService.i18n.t("remove_as_admin")
|
capitalizeFirstLetter(I18NextService.i18n.t("remove_as_admin"))
|
||||||
) : (
|
) : (
|
||||||
I18NextService.i18n.t("appoint_as_admin")
|
capitalizeFirstLetter(I18NextService.i18n.t("appoint_as_admin"))
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get transferCommunityButton() {
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
className="btn btn-link btn-sm d-flex align-items-center rounded-0 dropdown-item"
|
||||||
|
onClick={linkEvent(this, this.handleShowConfirmTransferCommunity)}
|
||||||
|
>
|
||||||
|
{capitalizeFirstLetter(I18NextService.i18n.t("transfer_community"))}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
get modRemoveButton() {
|
get modRemoveButton() {
|
||||||
const removed = this.postView.post.removed;
|
const removed = this.postView.post.removed;
|
||||||
return (
|
return (
|
||||||
|
@ -1095,99 +1139,14 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
{this.state.removeLoading ? (
|
{this.state.removeLoading ? (
|
||||||
<Spinner />
|
<Spinner />
|
||||||
) : !removed ? (
|
) : !removed ? (
|
||||||
I18NextService.i18n.t("remove")
|
capitalizeFirstLetter(I18NextService.i18n.t("remove_post"))
|
||||||
) : (
|
|
||||||
I18NextService.i18n.t("restore")
|
|
||||||
)}
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mod/Admin actions to be taken against the author.
|
|
||||||
*/
|
|
||||||
userActionsLine() {
|
|
||||||
// TODO: make nicer
|
|
||||||
const post_view = this.postView;
|
|
||||||
return (
|
|
||||||
this.state.showAdvanced && (
|
|
||||||
<div className="mt-3">
|
|
||||||
{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 ? (
|
|
||||||
<button
|
|
||||||
className="btn btn-link btn-animate text-muted py-0"
|
|
||||||
onClick={linkEvent(
|
|
||||||
this,
|
|
||||||
this.handleShowConfirmTransferCommunity
|
|
||||||
)}
|
|
||||||
aria-label={I18NextService.i18n.t("transfer_community")}
|
|
||||||
>
|
|
||||||
{I18NextService.i18n.t("transfer_community")}
|
|
||||||
</button>
|
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<button
|
{capitalizeFirstLetter(I18NextService.i18n.t("restore"))}{" "}
|
||||||
className="d-inline-block me-1 btn btn-link btn-animate text-muted py-0"
|
{I18NextService.i18n.t("post")}
|
||||||
aria-label={I18NextService.i18n.t("are_you_sure")}
|
|
||||||
>
|
|
||||||
{I18NextService.i18n.t("are_you_sure")}
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
className="btn btn-link btn-animate text-muted py-0 d-inline-block me-1"
|
|
||||||
aria-label={I18NextService.i18n.t("yes")}
|
|
||||||
onClick={linkEvent(this, this.handleTransferCommunity)}
|
|
||||||
>
|
|
||||||
{this.state.transferLoading ? (
|
|
||||||
<Spinner />
|
|
||||||
) : (
|
|
||||||
I18NextService.i18n.t("yes")
|
|
||||||
)}
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
className="btn btn-link btn-animate text-muted py-0 d-inline-block"
|
|
||||||
onClick={linkEvent(
|
|
||||||
this,
|
|
||||||
this.handleCancelShowConfirmTransferCommunity
|
|
||||||
)}
|
|
||||||
aria-label={I18NextService.i18n.t("no")}
|
|
||||||
>
|
|
||||||
{I18NextService.i18n.t("no")}
|
|
||||||
</button>
|
|
||||||
</>
|
|
||||||
))}
|
|
||||||
{/* 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) &&
|
</button>
|
||||||
post_view.creator.local &&
|
|
||||||
this.toggleAdminButton}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1218,11 +1177,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
value={this.state.removeReason}
|
value={this.state.removeReason}
|
||||||
onInput={linkEvent(this, this.handleModRemoveReasonChange)}
|
onInput={linkEvent(this, this.handleModRemoveReasonChange)}
|
||||||
/>
|
/>
|
||||||
<button
|
<button type="submit" className="btn btn-secondary">
|
||||||
type="submit"
|
|
||||||
className="btn btn-secondary"
|
|
||||||
aria-label={I18NextService.i18n.t("remove_post")}
|
|
||||||
>
|
|
||||||
{this.state.removeLoading ? (
|
{this.state.removeLoading ? (
|
||||||
<Spinner />
|
<Spinner />
|
||||||
) : (
|
) : (
|
||||||
|
@ -1231,6 +1186,33 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
)}
|
)}
|
||||||
|
{this.state.showConfirmTransferCommunity && (
|
||||||
|
<>
|
||||||
|
<button className="d-inline-block me-1 btn btn-link btn-animate text-muted py-0">
|
||||||
|
{I18NextService.i18n.t("are_you_sure")}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="btn btn-link btn-animate text-muted py-0 d-inline-block me-1"
|
||||||
|
onClick={linkEvent(this, this.handleTransferCommunity)}
|
||||||
|
>
|
||||||
|
{this.state.transferLoading ? (
|
||||||
|
<Spinner />
|
||||||
|
) : (
|
||||||
|
I18NextService.i18n.t("yes")
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="btn btn-link btn-animate text-muted py-0 d-inline-block"
|
||||||
|
onClick={linkEvent(
|
||||||
|
this,
|
||||||
|
this.handleCancelShowConfirmTransferCommunity
|
||||||
|
)}
|
||||||
|
aria-label={I18NextService.i18n.t("no")}
|
||||||
|
>
|
||||||
|
{I18NextService.i18n.t("no")}
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
{this.state.showBanDialog && (
|
{this.state.showBanDialog && (
|
||||||
<form onSubmit={linkEvent(this, this.handleModBanBothSubmit)}>
|
<form onSubmit={linkEvent(this, this.handleModBanBothSubmit)}>
|
||||||
<div className="mb-3 row col-12">
|
<div className="mb-3 row col-12">
|
||||||
|
@ -1284,11 +1266,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
{/* <input type="date" class="form-control me-2" placeholder={I18NextService.i18n.t('expires')} value={this.state.banExpires} onInput={linkEvent(this, this.handleModBanExpiresChange)} /> */}
|
{/* <input type="date" class="form-control me-2" placeholder={I18NextService.i18n.t('expires')} value={this.state.banExpires} onInput={linkEvent(this, this.handleModBanExpiresChange)} /> */}
|
||||||
{/* </div> */}
|
{/* </div> */}
|
||||||
<div className="mb-3 row">
|
<div className="mb-3 row">
|
||||||
<button
|
<button type="submit" className="btn btn-secondary">
|
||||||
type="submit"
|
|
||||||
className="btn btn-secondary"
|
|
||||||
aria-label={I18NextService.i18n.t("ban")}
|
|
||||||
>
|
|
||||||
{this.state.banLoading ? (
|
{this.state.banLoading ? (
|
||||||
<Spinner />
|
<Spinner />
|
||||||
) : (
|
) : (
|
||||||
|
@ -1317,11 +1295,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
value={this.state.reportReason}
|
value={this.state.reportReason}
|
||||||
onInput={linkEvent(this, this.handleReportReasonChange)}
|
onInput={linkEvent(this, this.handleReportReasonChange)}
|
||||||
/>
|
/>
|
||||||
<button
|
<button type="submit" className="btn btn-secondary">
|
||||||
type="submit"
|
|
||||||
className="btn btn-secondary"
|
|
||||||
aria-label={I18NextService.i18n.t("create_report")}
|
|
||||||
>
|
|
||||||
{this.state.reportLoading ? (
|
{this.state.reportLoading ? (
|
||||||
<Spinner />
|
<Spinner />
|
||||||
) : (
|
) : (
|
||||||
|
@ -1350,11 +1324,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
{this.state.purgeLoading ? (
|
{this.state.purgeLoading ? (
|
||||||
<Spinner />
|
<Spinner />
|
||||||
) : (
|
) : (
|
||||||
<button
|
<button type="submit" className="btn btn-secondary">
|
||||||
type="submit"
|
|
||||||
className="btn btn-secondary"
|
|
||||||
aria-label={purgeTypeText}
|
|
||||||
>
|
|
||||||
{this.state.purgeLoading ? <Spinner /> : { purgeTypeText }}
|
{this.state.purgeLoading ? <Spinner /> : { purgeTypeText }}
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
|
@ -1409,7 +1379,6 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
{this.mobileThumbnail()}
|
{this.mobileThumbnail()}
|
||||||
|
|
||||||
{this.commentsLine(true)}
|
{this.commentsLine(true)}
|
||||||
{this.userActionsLine()}
|
|
||||||
{this.duplicatesLine()}
|
{this.duplicatesLine()}
|
||||||
{this.removeAndBanDialogs()}
|
{this.removeAndBanDialogs()}
|
||||||
</div>
|
</div>
|
||||||
|
@ -1441,7 +1410,6 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
{this.createdLine()}
|
{this.createdLine()}
|
||||||
{this.commentsLine()}
|
{this.commentsLine()}
|
||||||
{this.duplicatesLine()}
|
{this.duplicatesLine()}
|
||||||
{this.userActionsLine()}
|
|
||||||
{this.removeAndBanDialogs()}
|
{this.removeAndBanDialogs()}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue