From: Dessalines Date: Mon, 19 Jun 2023 14:04:19 +0000 (-0400) Subject: Merge branch 'main' into breakout-role-utils X-Git-Url: http://these/git/?a=commitdiff_plain;h=02ffa85b589ea630b259f6c2617b399e05972716;hp=-c;p=lemmy-ui.git Merge branch 'main' into breakout-role-utils --- 02ffa85b589ea630b259f6c2617b399e05972716 diff --combined src/shared/components/home/home.tsx index 54378f3,4f9b969..39753c4 --- a/src/shared/components/home/home.tsx +++ b/src/shared/components/home/home.tsx @@@ -57,6 -57,7 +57,6 @@@ import { UserService } from "../../serv import { FirstLoadService } from "../../services/FirstLoadService"; import { HttpService, RequestState } from "../../services/HttpService"; import { - canCreateCommunity, commentsToFlatNodes, editComment, editPost, @@@ -67,10 -68,13 +67,10 @@@ getCommentParentId, getDataTypeString, getPageFromString, - getQueryParams, - getQueryString, getRandomFromList, mdToHtml, myAuth, postToCommentSortType, - QueryParams, relTags, restoreScrollPosition, RouteDataResponse, @@@ -82,10 -86,6 +82,10 @@@ trendingFetchLimit, updatePersonBlock, } from "../../utils"; +import { getQueryParams } from "../../utils/helpers/get-query-params"; +import { getQueryString } from "../../utils/helpers/get-query-string"; +import { canCreateCommunity } from "../../utils/roles/can-create-community"; +import type { QueryParams } from "../../utils/types/query-params"; import { CommentNodes } from "../comment/comment-nodes"; import { DataTypeSelect } from "../common/data-type-select"; import { HtmlTags } from "../common/html-tags"; @@@ -443,16 -443,17 +443,17 @@@ export class Home extends Component )} {showTrendingMobile && ( -
-
{this.trendingCommunities(true)}
+
+ {this.trendingCommunities()}
)} {showSubscribedMobile && ( -
-
{this.subscribedCommunities}
+
+ {this.subscribedCommunities(true)}
)}
@@@ -471,19 -472,7 +472,7 @@@ return (
-
- {this.trendingCommunities()} - {canCreateCommunity(this.state.siteRes) && ( - - )} - -
+ {this.trendingCommunities()}
{this.hasFollows && ( -
-
{this.subscribedCommunities}
-
+
+
+ {this.subscribedCommunities(false)} +
+
)}
); } - trendingCommunities(isMobile = false) { + trendingCommunities() { switch (this.state.trendingCommunitiesRes?.state) { case "loading": return ( @@@ -514,68 -505,103 +505,103 @@@ case "success": { const trending = this.state.trendingCommunitiesRes.data.communities; return ( -
-
- - # - + <> +
+
+ # - - -
-
    - {trending.map(cv => ( -
  • - -
  • - ))} -
-
+ + # + + + + +
+ {trending.length > 0 && ( +
    + {trending.map(cv => ( +
  • + +
  • + ))} +
+ )} + {canCreateCommunity(this.state.siteRes) && ( + + )} + +
+ ); } } } - get subscribedCommunities() { + subscribedCommunities(isMobile = false) { const { subscribedCollapsed } = this.state; return ( -
-
- - # - + <> +
+
+ # - - - -
- {!subscribedCollapsed && ( -
    - {UserService.Instance.myUserInfo?.follows.map(cfv => ( -
  • - -
  • - ))} -
- )} -
+ + # + + + + {!isMobile && ( + + )} + +
+
+
    + {UserService.Instance.myUserInfo?.follows.map(cfv => ( +
  • + +
  • + ))} +
+
+
+ ); } diff --combined src/shared/components/home/signup.tsx index 192393d,71398a8..c730695 --- a/src/shared/components/home/signup.tsx +++ b/src/shared/components/home/signup.tsx @@@ -13,6 -13,7 +13,6 @@@ import { i18n } from "../../i18next" import { UserService } from "../../services"; import { HttpService, RequestState } from "../../services/HttpService"; import { - isBrowser, joinLemmyUrl, mdToHtml, myAuth, @@@ -20,7 -21,6 +20,7 @@@ toast, validEmail, } from "../../utils"; +import { isBrowser } from "../../utils/browser/is-browser"; import { HtmlTags } from "../common/html-tags"; import { Icon, Spinner } from "../common/icon"; import { MarkdownTextArea } from "../common/markdown-textarea"; @@@ -298,27 -298,22 +298,22 @@@ export class Signup extends Component )} {this.renderCaptcha()} - {siteView.local_site.enable_nsfw && ( -
-
-
- - -
+
+
+
+ +
- )} +
- {enableNsfw(this.state.siteRes) && ( -
-
- - -
+
+
+ +
- )} +
+
{!this.state.showEdit ? ( <> {this.listing()} @@@ -386,10 -386,10 +386,10 @@@ )} {this.props.showCommunity && ( - - {i18n.t("to")} - - + <> + {" "} + {i18n.t("to")} + )} {post_view.post.language_id !== 0 && ( @@@ -497,7 -497,7 +497,7 @@@ const post = this.postView.post; return ( -
@@@ -519,88 -519,78 +519,78 @@@ return (
-
- {url ? ( - this.props.showBody ? ( - -
- - ) : ( - this.postLink - ) +
+ {url && this.props.showBody ? ( + ) : ( this.postLink )} - {(url && isImage(url)) || - (post.thumbnail_url && ( - - ))} - {post.removed && ( - - {i18n.t("removed")} - - )} - {post.deleted && ( - - - - )} - {post.locked && ( - - - - )} - {post.featured_community && ( - - - - )} - {post.featured_local && ( - - - - )} - {post.nsfw && ( - - {i18n.t("nsfw")} - - )}
+ {(url && isImage(url)) || + (post.thumbnail_url && ( + + ))} + {post.removed && ( + + {i18n.t("removed")} + + )} + {post.deleted && ( + + + + )} + {post.locked && ( + + + + )} + {post.featured_community && ( + + + + )} + {post.featured_local && ( + + + + )} + {post.nsfw && ( + {i18n.t("nsfw")} + )}
); } @@@ -631,11 -621,11 +621,11 @@@ const post = this.postView.post; return ( -
+
{this.commentsButton} {canShare() && (
); } - postActions(mobile = false) { + get hasAdvancedButtons() { + return ( + this.myPost || + (this.showBody && this.postView.post.body) || + amMod(this.props.moderators) || + amAdmin() || + this.canMod_ || + this.canAdmin_ + ); + } + + 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. const post_view = this.postView; @@@ -667,37 -668,53 +668,53 @@@ <> {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} ); } @@@ -706,7 -723,7 +723,7 @@@ const post_view = this.postView; return ( - + + {i18n.t("create_report")} ); } @@@ -859,12 -876,16 +876,16 @@@ get blockButton() { return ( ); } @@@ -872,12 -893,12 +893,12 @@@ get editButton() { return ( ); } @@@ -887,37 -908,26 +908,26 @@@ 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") @@@ -969,48 -981,56 +981,56 @@@ ? i18n.t("unfeature_from_local") : i18n.t("feature_in_local"); return ( - - - {amAdmin() && ( + <> +
  • - )} - +
  • +
  • + {amAdmin() && ( + + )} +
  • + ); } @@@ -1018,7 -1038,7 +1038,7 @@@ const removed = this.postView.post.removed; return (