From: Jay Sitter Date: Sat, 17 Jun 2023 22:03:12 +0000 (-0400) Subject: feat: Move advanced post menu into dropdown X-Git-Url: http://these/git/%7B%60%24%7Bdocument.location.origin%7D/feeds/static/%7Brss%7D?a=commitdiff_plain;h=7c264916a3f5ac329d4003abc5ce7068f0fd05ba;p=lemmy-ui.git feat: Move advanced post menu into dropdown --- diff --git a/src/shared/components/post/post-listing.tsx b/src/shared/components/post/post-listing.tsx index 36d96a9..99bec62 100644 --- a/src/shared/components/post/post-listing.tsx +++ b/src/shared/components/post/post-listing.tsx @@ -661,6 +661,17 @@ export class PostListing extends Component { ); } + get hasAdvancedButtons() { + return ( + this.myPost || + (this.showBody && this.postView.post.body) || + amMod(this.props.moderators) || + amAdmin() || + this.canMod_ || + this.canAdmin_ + ); + } + postActions(mobile = false) { // Possible enhancement: Priority+ pattern instead of just hard coding which get hidden behind the show more button. // Possible enhancement: Make each button a component. @@ -669,37 +680,52 @@ export class PostListing extends Component { <> {this.saveButton} {this.crossPostButton} - {mobile && this.showMoreButton} - {(!mobile || this.state.showAdvanced) && ( - <> - {!this.myPost && ( - <> - {this.reportButton} - {this.blockButton} - - )} - {this.myPost && (this.showBody || this.state.showAdvanced) && ( - <> - {this.editButton} - {this.deleteButton} - - )} - - )} - {this.state.showAdvanced && ( - <> - {this.showBody && post_view.post.body && this.viewSourceButton} - {/* Any mod can do these, not limited to hierarchy*/} - {(amMod(this.props.moderators) || amAdmin()) && ( - <> - {this.lockButton} - {this.featureButton} - - )} - {(this.canMod_ || this.canAdmin_) && <>{this.modRemoveButton}} - + + {this.showBody && post_view.post.body && this.viewSourceButton} + + {this.hasAdvancedButtons && ( +
+ + +
    + {!this.myPost ? ( + <> +
  • {this.reportButton}
  • +
  • {this.blockButton}
  • + + ) : ( + <> +
  • {this.editButton}
  • +
  • {this.deleteButton}
  • + + )} + + {/* Any mod can do these, not limited to hierarchy*/} + {(amMod(this.props.moderators) || amAdmin()) && ( + <> +
  • +
    +
  • +
  • {this.lockButton}
  • + {this.featureButtons} + + )} + + {(this.canMod_ || this.canAdmin_) && ( +
  • {this.modRemoveButton}
  • + )} +
+
)} - {!mobile && this.showMoreButton} ); } @@ -848,7 +874,7 @@ export class PostListing extends Component { get reportButton() { return ( ); } @@ -889,7 +916,7 @@ export class PostListing extends Component { const label = !deleted ? i18n.t("delete") : i18n.t("restore"); return ( ); } - get showMoreButton() { - return ( - - ); - } - get viewSourceButton() { return ( ); } - get featureButton() { + get featureButtons() { const featuredCommunity = this.postView.post.featured_community; const labelCommunity = featuredCommunity ? i18n.t("unfeature_from_community") @@ -971,48 +991,56 @@ export class PostListing extends Component { ? i18n.t("unfeature_from_local") : i18n.t("feature_in_local"); return ( - - - {amAdmin() && ( + <> +
  • - )} - +
  • +
  • + {amAdmin() && ( + + )} +
  • + ); } @@ -1020,7 +1048,7 @@ export class PostListing extends Component { const removed = this.postView.post.removed; return (