mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-25 15:39:25 +00:00
Adding site desc. Fixes #266
This commit is contained in:
parent
55e53582aa
commit
d43f22ede5
|
@ -1 +1 @@
|
||||||
Subproject commit 764d35d913453d1fd8eeec6007f0d94f59c8b0ee
|
Subproject commit 12e8d61e9ba2620b0031e237d87367480452b6fb
|
|
@ -68,7 +68,7 @@
|
||||||
"eslint-plugin-prettier": "^3.3.1",
|
"eslint-plugin-prettier": "^3.3.1",
|
||||||
"husky": "^6.0.0",
|
"husky": "^6.0.0",
|
||||||
"iso-639-1": "^2.1.9",
|
"iso-639-1": "^2.1.9",
|
||||||
"lemmy-js-client": "0.11.0-rc.9",
|
"lemmy-js-client": "0.11.0-rc.10",
|
||||||
"lint-staged": "^10.5.4",
|
"lint-staged": "^10.5.4",
|
||||||
"mini-css-extract-plugin": "^1.4.1",
|
"mini-css-extract-plugin": "^1.4.1",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
|
|
|
@ -398,10 +398,11 @@ export class Main extends Component<any, MainState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
siteInfo() {
|
siteInfo() {
|
||||||
|
let site = this.state.siteRes.site_view.site;
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{this.state.siteRes.site_view.site.description &&
|
{site.description && <h6>{site.description}</h6>}
|
||||||
this.siteDescription()}
|
{site.sidebar && this.siteSidebar()}
|
||||||
{this.badges()}
|
{this.badges()}
|
||||||
{this.admins()}
|
{this.admins()}
|
||||||
</div>
|
</div>
|
||||||
|
@ -527,12 +528,12 @@ export class Main extends Component<any, MainState> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
siteDescription() {
|
siteSidebar() {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="md-div"
|
className="md-div"
|
||||||
dangerouslySetInnerHTML={mdToHtml(
|
dangerouslySetInnerHTML={mdToHtml(
|
||||||
this.state.siteRes.site_view.site.description
|
this.state.siteRes.site_view.site.sidebar
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
@ -42,9 +42,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
||||||
super(props, context);
|
super(props, context);
|
||||||
|
|
||||||
this.state = this.emptyState;
|
this.state = this.emptyState;
|
||||||
this.handleSiteDescriptionChange = this.handleSiteDescriptionChange.bind(
|
this.handleSiteSidebarChange = this.handleSiteSidebarChange.bind(this);
|
||||||
this
|
|
||||||
);
|
|
||||||
|
|
||||||
this.handleIconUpload = this.handleIconUpload.bind(this);
|
this.handleIconUpload = this.handleIconUpload.bind(this);
|
||||||
this.handleIconRemove = this.handleIconRemove.bind(this);
|
this.handleIconRemove = this.handleIconRemove.bind(this);
|
||||||
|
@ -55,6 +53,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
||||||
if (this.props.site) {
|
if (this.props.site) {
|
||||||
this.state.siteForm = {
|
this.state.siteForm = {
|
||||||
name: this.props.site.name,
|
name: this.props.site.name,
|
||||||
|
sidebar: this.props.site.sidebar,
|
||||||
description: this.props.site.description,
|
description: this.props.site.description,
|
||||||
enable_downvotes: this.props.site.enable_downvotes,
|
enable_downvotes: this.props.site.enable_downvotes,
|
||||||
open_registration: this.props.site.open_registration,
|
open_registration: this.props.site.open_registration,
|
||||||
|
@ -76,7 +75,9 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
||||||
if (
|
if (
|
||||||
!this.state.loading &&
|
!this.state.loading &&
|
||||||
!this.props.site &&
|
!this.props.site &&
|
||||||
(this.state.siteForm.name || this.state.siteForm.description)
|
(this.state.siteForm.name ||
|
||||||
|
this.state.siteForm.sidebar ||
|
||||||
|
this.state.siteForm.description)
|
||||||
) {
|
) {
|
||||||
window.onbeforeunload = () => true;
|
window.onbeforeunload = () => true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -95,7 +96,9 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
||||||
when={
|
when={
|
||||||
!this.state.loading &&
|
!this.state.loading &&
|
||||||
!this.props.site &&
|
!this.props.site &&
|
||||||
(this.state.siteForm.name || this.state.siteForm.description)
|
(this.state.siteForm.name ||
|
||||||
|
this.state.siteForm.sidebar ||
|
||||||
|
this.state.siteForm.description)
|
||||||
}
|
}
|
||||||
message={i18n.t("block_leaving")}
|
message={i18n.t("block_leaving")}
|
||||||
/>
|
/>
|
||||||
|
@ -141,14 +144,29 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
||||||
onRemove={this.handleBannerRemove}
|
onRemove={this.handleBannerRemove}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label class="col-12 col-form-label" htmlFor="site-desc">
|
||||||
|
{i18n.t("description")}
|
||||||
|
</label>
|
||||||
|
<div class="col-12">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
class="form-control"
|
||||||
|
id="site-desc"
|
||||||
|
value={this.state.siteForm.description}
|
||||||
|
onInput={linkEvent(this, this.handleSiteDescChange)}
|
||||||
|
maxLength={150}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-12 col-form-label" htmlFor={this.id}>
|
<label class="col-12 col-form-label" htmlFor={this.id}>
|
||||||
{i18n.t("sidebar")}
|
{i18n.t("sidebar")}
|
||||||
</label>
|
</label>
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<MarkdownTextArea
|
<MarkdownTextArea
|
||||||
initialContent={this.state.siteForm.description}
|
initialContent={this.state.siteForm.sidebar}
|
||||||
onContentChange={this.handleSiteDescriptionChange}
|
onContentChange={this.handleSiteSidebarChange}
|
||||||
hideNavigationWarnings
|
hideNavigationWarnings
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -264,11 +282,16 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
||||||
i.setState(i.state);
|
i.setState(i.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSiteDescriptionChange(val: string) {
|
handleSiteSidebarChange(val: string) {
|
||||||
this.state.siteForm.description = val;
|
this.state.siteForm.sidebar = val;
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleSiteDescChange(i: SiteForm, event: any) {
|
||||||
|
i.state.siteForm.description = event.target.value;
|
||||||
|
i.setState(i.state);
|
||||||
|
}
|
||||||
|
|
||||||
handleSiteEnableNsfwChange(i: SiteForm, event: any) {
|
handleSiteEnableNsfwChange(i: SiteForm, event: any) {
|
||||||
i.state.siteForm.enable_nsfw = event.target.checked;
|
i.state.siteForm.enable_nsfw = event.target.checked;
|
||||||
i.setState(i.state);
|
i.setState(i.state);
|
||||||
|
|
|
@ -5125,10 +5125,10 @@ lcid@^1.0.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
invert-kv "^1.0.0"
|
invert-kv "^1.0.0"
|
||||||
|
|
||||||
lemmy-js-client@0.11.0-rc.9:
|
lemmy-js-client@0.11.0-rc.10:
|
||||||
version "0.11.0-rc.9"
|
version "0.11.0-rc.10"
|
||||||
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.11.0-rc.9.tgz#f8b1e3924388c6e7f719f052ba1568f4d210cabc"
|
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.11.0-rc.10.tgz#304b5b941a00fe251fb50c81e5ae795e8bf0bd8d"
|
||||||
integrity sha512-697hLvHPr5+ZkJkFTaXl3y7Dt1va2Dghx9uvu/kZyZQZGVk2lL10R50SDaWsThyQKFBT4kiS1JZI+R3szzZEZQ==
|
integrity sha512-bVLMnE1xm7mmmUC9gLIQ7wFNZn8HD3nmE56EhNGgqR76zdjZSSk+8ZqBYHUJ2yOikGebzIm0heMFryIsJuqwTg==
|
||||||
|
|
||||||
levn@^0.4.1:
|
levn@^0.4.1:
|
||||||
version "0.4.1"
|
version "0.4.1"
|
||||||
|
|
Loading…
Reference in a new issue