From a860bdd70098eb4a41e091403e9cbc363780248e Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> Date: Thu, 14 Mar 2024 16:09:11 +0000 Subject: [PATCH] Community visibility setting (#2376) * Update deps * Add community visibility to community form for editing and creating * Add translations * Make visibility display * Add translations --------- Co-authored-by: SleeplessOne1917 Co-authored-by: Dessalines --- lemmy-translations | 2 +- src/assets/symbols.svg | 13 +++++++++ .../components/community/community-form.tsx | 27 +++++++++++++++++++ src/shared/components/community/sidebar.tsx | 26 +++++++++++++++++- 4 files changed, 66 insertions(+), 2 deletions(-) diff --git a/lemmy-translations b/lemmy-translations index b4cb42fb..62c84180 160000 --- a/lemmy-translations +++ b/lemmy-translations @@ -1 +1 @@ -Subproject commit b4cb42fbdd63dece5de2abf7f33249e489166501 +Subproject commit 62c8418021bc39543c87b4ae3dcf2419d13f61e0 diff --git a/src/assets/symbols.svg b/src/assets/symbols.svg index 5019ed1e..64002a32 100644 --- a/src/assets/symbols.svg +++ b/src/assets/symbols.svg @@ -279,5 +279,18 @@ + + + + + + + + + + + + + diff --git a/src/shared/components/community/community-form.tsx b/src/shared/components/community/community-form.tsx index ec0ded36..327a75b1 100644 --- a/src/shared/components/community/community-form.tsx +++ b/src/shared/components/community/community-form.tsx @@ -3,6 +3,7 @@ import { Component, linkEvent } from "inferno"; import { Prompt } from "inferno-router"; import { CommunityView, + CommunityVisibility, CreateCommunity, EditCommunity, Language, @@ -34,6 +35,7 @@ interface CommunityFormState { nsfw?: boolean; posting_restricted_to_mods?: boolean; discussion_languages?: number[]; + visibilty?: CommunityVisibility; }; submitted: boolean; } @@ -78,6 +80,7 @@ export class CommunityForm extends Component< banner: cv.community.banner, posting_restricted_to_mods: cv.community.posting_restricted_to_mods, discussion_languages: this.props.communityLanguages, + visibilty: cv.community.visibility, }, }; } @@ -217,6 +220,24 @@ export class CommunityForm extends Component< )} +
+ + {I18NextService.i18n.t("community_visibility")} + +
+ +
+
{I18NextService.i18n.t("only_mods_can_post_in_community")} @@ -291,6 +312,7 @@ export class CommunityForm extends Component< nsfw: cForm.nsfw, posting_restricted_to_mods: cForm.posting_restricted_to_mods, discussion_languages: cForm.discussion_languages, + visibility: cForm.visibilty, }); } else { if (cForm.title && cForm.name) { @@ -303,6 +325,7 @@ export class CommunityForm extends Component< nsfw: cForm.nsfw, posting_restricted_to_mods: cForm.posting_restricted_to_mods, discussion_languages: cForm.discussion_languages, + visibility: cForm.visibilty, }); } } @@ -330,6 +353,10 @@ export class CommunityForm extends Component< ); } + handleCommunityVisibilityChange(i: CommunityForm, event: any) { + i.setState(s => ((s.form.visibilty = event.target.value), s)); + } + handleCancel(i: CommunityForm) { i.props.onCancel?.(); } diff --git a/src/shared/components/community/sidebar.tsx b/src/shared/components/community/sidebar.tsx index 5413998b..76f7c254 100644 --- a/src/shared/components/community/sidebar.tsx +++ b/src/shared/components/community/sidebar.tsx @@ -124,7 +124,7 @@ export class Sidebar extends Component { sidebar() { const myUserInfo = UserService.Instance.myUserInfo; const { - community: { name, actor_id, id, posting_restricted_to_mods }, + community: { name, actor_id, id, posting_restricted_to_mods, visibility }, counts, } = this.props.community_view; return ( @@ -175,6 +175,30 @@ export class Sidebar extends Component {
)} {this.description()} +
+
+ + {I18NextService.i18n.t("community_visibility")}:  + + + {I18NextService.i18n.t( + visibility === "Public" ? "public" : "local_only", + )} + + +
+

+ {I18NextService.i18n.t( + visibility === "Public" + ? "public_blurb" + : "local_only_blurb", + )} +

+
{this.mods()}