mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-12-27 11:08:30 +00:00
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:
parent
fcb85efb19
commit
36297366fa
|
@ -1 +1 @@
|
|||
Subproject commit 1cbac3a1521e26b9b5c1c97a0c9852655ddcf00b
|
||||
Subproject commit 29c689af8d16417c1b84d9491f6bcea888720a87
|
|
@ -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">
|
||||
|
|
|
@ -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));
|
||||
|
|
42
src/shared/components/home/legal.tsx
Normal file
42
src/shared/components/home/legal.tsx
Normal 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>
|
||||
);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
|
|
@ -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 },
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue