Legal info dess (#666)

* 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>
This commit is contained in:
Dessalines 2022-05-26 16:48:58 -04:00 committed by GitHub
parent fcb85efb19
commit 36297366fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 73 additions and 2 deletions

@ -1 +1 @@
Subproject commit 1cbac3a1521e26b9b5c1c97a0c9852655ddcf00b Subproject commit 29c689af8d16417c1b84d9491f6bcea888720a87

View file

@ -32,6 +32,13 @@ export class Footer extends Component<FooterProps, any> {
{i18n.t("modlog")} {i18n.t("modlog")}
</NavLink> </NavLink>
</li> </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 && ( {this.props.site.federated_instances && (
<li class="nav-item"> <li class="nav-item">
<NavLink className="nav-link" to="/instances"> <NavLink className="nav-link" to="/instances">

View file

@ -237,7 +237,7 @@ export class AdminSettings extends Component<any, AdminSettingsState> {
event.preventDefault(); event.preventDefault();
i.state.siteConfigLoading = true; i.state.siteConfigLoading = true;
let form: SaveSiteConfig = { let form: SaveSiteConfig = {
config_hjson: this.state.siteConfigHjson, config_hjson: i.state.siteConfigHjson,
auth: authField(), auth: authField(),
}; };
WebSocketService.Instance.send(wsClient.saveSiteConfig(form)); WebSocketService.Instance.send(wsClient.saveSiteConfig(form));

View file

@ -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>
);
}
}

View file

@ -42,6 +42,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
private_instance: null, private_instance: null,
default_theme: null, default_theme: null,
default_post_listing_type: null, default_post_listing_type: null,
legal_information: null,
auth: authField(false), auth: authField(false),
}, },
loading: false, loading: false,
@ -53,6 +54,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
this.state = this.emptyState; this.state = this.emptyState;
this.handleSiteSidebarChange = this.handleSiteSidebarChange.bind(this); this.handleSiteSidebarChange = this.handleSiteSidebarChange.bind(this);
this.handleSiteLegalInfoChange = this.handleSiteLegalInfoChange.bind(this);
this.handleSiteApplicationQuestionChange = this.handleSiteApplicationQuestionChange =
this.handleSiteApplicationQuestionChange.bind(this); this.handleSiteApplicationQuestionChange.bind(this);
@ -83,6 +85,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
private_instance: site.private_instance, private_instance: site.private_instance,
default_theme: site.default_theme, default_theme: site.default_theme,
default_post_listing_type: site.default_post_listing_type, default_post_listing_type: site.default_post_listing_type,
legal_information: site.legal_information,
auth: authField(false), auth: authField(false),
}; };
} }
@ -199,6 +202,18 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
/> />
</div> </div>
</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 && ( {this.state.siteForm.require_application && (
<div class="form-group row"> <div class="form-group row">
<label class="col-12 col-form-label"> <label class="col-12 col-form-label">
@ -448,6 +463,11 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
this.setState(this.state); this.setState(this.state);
} }
handleSiteLegalInfoChange(val: string) {
this.state.siteForm.legal_information = val;
this.setState(this.state);
}
handleSiteApplicationQuestionChange(val: string) { handleSiteApplicationQuestionChange(val: string) {
this.state.siteForm.application_question = val; this.state.siteForm.application_question = val;
this.setState(this.state); this.setState(this.state);

View file

@ -5,6 +5,7 @@ import { CreateCommunity } from "./components/community/create-community";
import { AdminSettings } from "./components/home/admin-settings"; import { AdminSettings } from "./components/home/admin-settings";
import { Home } from "./components/home/home"; import { Home } from "./components/home/home";
import { Instances } from "./components/home/instances"; import { Instances } from "./components/home/instances";
import { Legal } from "./components/home/legal";
import { Login } from "./components/home/login"; import { Login } from "./components/home/login";
import { Setup } from "./components/home/setup"; import { Setup } from "./components/home/setup";
import { Signup } from "./components/home/signup"; import { Signup } from "./components/home/signup";
@ -154,4 +155,5 @@ export const routes: IRoutePropsWithFetch[] = [
component: VerifyEmail, component: VerifyEmail,
}, },
{ path: `/instances`, component: Instances }, { path: `/instances`, component: Instances },
{ path: `/legal`, component: Legal },
]; ];