]> Untitled Git - lemmy-ui.git/commitdiff
Legal info dess (#666)
authorDessalines <dessalines@users.noreply.github.com>
Thu, 26 May 2022 20:48:58 +0000 (16:48 -0400)
committerGitHub <noreply@github.com>
Thu, 26 May 2022 20:48:58 +0000 (16:48 -0400)
* Add legal information (fixes #652)

* add legal_info field to SiteForm, add missing file

* Moving legal to SiteForm.

Co-authored-by: Felix Ableitner <me@nutomic.com>
lemmy-translations
src/shared/components/app/footer.tsx
src/shared/components/home/admin-settings.tsx
src/shared/components/home/legal.tsx [new file with mode: 0644]
src/shared/components/home/site-form.tsx
src/shared/routes.ts

index 1cbac3a1521e26b9b5c1c97a0c9852655ddcf00b..29c689af8d16417c1b84d9491f6bcea888720a87 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 1cbac3a1521e26b9b5c1c97a0c9852655ddcf00b
+Subproject commit 29c689af8d16417c1b84d9491f6bcea888720a87
index d4edd78cb7207e12fbd035afe51a8b5735fbe6e8..601551b5ea9032af57c0da90ddd74026d981904b 100644 (file)
@@ -32,6 +32,13 @@ export class Footer extends Component<FooterProps, any> {
                 {i18n.t("modlog")}
               </NavLink>
             </li>
+            {this.props.site.site_view?.site.legal_information && (
+              <li className="nav-item">
+                <NavLink className="nav-link" to="/legal">
+                  {i18n.t("legal_information")}
+                </NavLink>
+              </li>
+            )}
             {this.props.site.federated_instances && (
               <li class="nav-item">
                 <NavLink className="nav-link" to="/instances">
index f848f8a35868b190fb5e2c01595123c001c5e44f..cb7848426c08b58cbf3e20a5dff2123e4a3b0d0a 100644 (file)
@@ -237,7 +237,7 @@ export class AdminSettings extends Component<any, AdminSettingsState> {
     event.preventDefault();
     i.state.siteConfigLoading = true;
     let form: SaveSiteConfig = {
-      config_hjson: this.state.siteConfigHjson,
+      config_hjson: i.state.siteConfigHjson,
       auth: authField(),
     };
     WebSocketService.Instance.send(wsClient.saveSiteConfig(form));
diff --git a/src/shared/components/home/legal.tsx b/src/shared/components/home/legal.tsx
new file mode 100644 (file)
index 0000000..b2904c8
--- /dev/null
@@ -0,0 +1,42 @@
+import { Component } from "inferno";
+import { GetSiteResponse } from "lemmy-js-client";
+import { i18n } from "../../i18next";
+import { mdToHtml, setIsoData } from "../../utils";
+import { HtmlTags } from "../common/html-tags";
+
+interface LegalState {
+  siteRes: GetSiteResponse;
+}
+
+export class Legal extends Component<any, LegalState> {
+  private isoData = setIsoData(this.context);
+  private emptyState: LegalState = {
+    siteRes: this.isoData.site_res,
+  };
+
+  constructor(props: any, context: any) {
+    super(props, context);
+    this.state = this.emptyState;
+  }
+
+  get documentTitle(): string {
+    return i18n.t("legal_information");
+  }
+
+  render() {
+    return (
+      <div class="container">
+        <HtmlTags
+          title={this.documentTitle}
+          path={this.context.router.route.match.url}
+        />
+        <div
+          className="md-div"
+          dangerouslySetInnerHTML={mdToHtml(
+            this.state.siteRes.site_view.site.legal_information
+          )}
+        />
+      </div>
+    );
+  }
+}
index f364059627277a7ebed1e40060da54d6192c9b67..7016e6f7485cfbe00d2dc67e368d1b870c0a4c13 100644 (file)
@@ -42,6 +42,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
       private_instance: null,
       default_theme: null,
       default_post_listing_type: null,
+      legal_information: null,
       auth: authField(false),
     },
     loading: false,
@@ -53,6 +54,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
 
     this.state = this.emptyState;
     this.handleSiteSidebarChange = this.handleSiteSidebarChange.bind(this);
+    this.handleSiteLegalInfoChange = this.handleSiteLegalInfoChange.bind(this);
     this.handleSiteApplicationQuestionChange =
       this.handleSiteApplicationQuestionChange.bind(this);
 
@@ -83,6 +85,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
         private_instance: site.private_instance,
         default_theme: site.default_theme,
         default_post_listing_type: site.default_post_listing_type,
+        legal_information: site.legal_information,
         auth: authField(false),
       };
     }
@@ -199,6 +202,18 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
               />
             </div>
           </div>
+          <div class="form-group row">
+            <label class="col-12 col-form-label">
+              {i18n.t("legal_information")}
+            </label>
+            <div class="col-12">
+              <MarkdownTextArea
+                initialContent={this.state.siteForm.legal_information}
+                onContentChange={this.handleSiteLegalInfoChange}
+                hideNavigationWarnings
+              />
+            </div>
+          </div>
           {this.state.siteForm.require_application && (
             <div class="form-group row">
               <label class="col-12 col-form-label">
@@ -448,6 +463,11 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
     this.setState(this.state);
   }
 
+  handleSiteLegalInfoChange(val: string) {
+    this.state.siteForm.legal_information = val;
+    this.setState(this.state);
+  }
+
   handleSiteApplicationQuestionChange(val: string) {
     this.state.siteForm.application_question = val;
     this.setState(this.state);
index 86c0b3c35f1d5fbc0684079566cdf47beab288ff..8035471b9028bb88b55711b35d07daf71398d0fc 100644 (file)
@@ -5,6 +5,7 @@ import { CreateCommunity } from "./components/community/create-community";
 import { AdminSettings } from "./components/home/admin-settings";
 import { Home } from "./components/home/home";
 import { Instances } from "./components/home/instances";
+import { Legal } from "./components/home/legal";
 import { Login } from "./components/home/login";
 import { Setup } from "./components/home/setup";
 import { Signup } from "./components/home/signup";
@@ -154,4 +155,5 @@ export const routes: IRoutePropsWithFetch[] = [
     component: VerifyEmail,
   },
   { path: `/instances`, component: Instances },
+  { path: `/legal`, component: Legal },
 ];