mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-22 20:31:13 +00:00
Merge pull request #272 from LemmyNet/feature/site_desc
Adding site desc. Fixes #266
This commit is contained in:
commit
e8a33d3427
5 changed files with 43 additions and 19 deletions
|
@ -1 +1 @@
|
|||
Subproject commit 764d35d913453d1fd8eeec6007f0d94f59c8b0ee
|
||||
Subproject commit 12e8d61e9ba2620b0031e237d87367480452b6fb
|
|
@ -68,7 +68,7 @@
|
|||
"eslint-plugin-prettier": "^3.3.1",
|
||||
"husky": "^6.0.0",
|
||||
"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",
|
||||
"mini-css-extract-plugin": "^1.4.1",
|
||||
"node-fetch": "^2.6.1",
|
||||
|
|
|
@ -398,10 +398,11 @@ export class Main extends Component<any, MainState> {
|
|||
}
|
||||
|
||||
siteInfo() {
|
||||
let site = this.state.siteRes.site_view.site;
|
||||
return (
|
||||
<div>
|
||||
{this.state.siteRes.site_view.site.description &&
|
||||
this.siteDescription()}
|
||||
{site.description && <h6>{site.description}</h6>}
|
||||
{site.sidebar && this.siteSidebar()}
|
||||
{this.badges()}
|
||||
{this.admins()}
|
||||
</div>
|
||||
|
@ -527,12 +528,12 @@ export class Main extends Component<any, MainState> {
|
|||
);
|
||||
}
|
||||
|
||||
siteDescription() {
|
||||
siteSidebar() {
|
||||
return (
|
||||
<div
|
||||
className="md-div"
|
||||
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);
|
||||
|
||||
this.state = this.emptyState;
|
||||
this.handleSiteDescriptionChange = this.handleSiteDescriptionChange.bind(
|
||||
this
|
||||
);
|
||||
this.handleSiteSidebarChange = this.handleSiteSidebarChange.bind(this);
|
||||
|
||||
this.handleIconUpload = this.handleIconUpload.bind(this);
|
||||
this.handleIconRemove = this.handleIconRemove.bind(this);
|
||||
|
@ -55,6 +53,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
|||
if (this.props.site) {
|
||||
this.state.siteForm = {
|
||||
name: this.props.site.name,
|
||||
sidebar: this.props.site.sidebar,
|
||||
description: this.props.site.description,
|
||||
enable_downvotes: this.props.site.enable_downvotes,
|
||||
open_registration: this.props.site.open_registration,
|
||||
|
@ -76,7 +75,9 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
|||
if (
|
||||
!this.state.loading &&
|
||||
!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;
|
||||
} else {
|
||||
|
@ -95,7 +96,9 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
|||
when={
|
||||
!this.state.loading &&
|
||||
!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")}
|
||||
/>
|
||||
|
@ -141,14 +144,29 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
|||
onRemove={this.handleBannerRemove}
|
||||
/>
|
||||
</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">
|
||||
<label class="col-12 col-form-label" htmlFor={this.id}>
|
||||
{i18n.t("sidebar")}
|
||||
</label>
|
||||
<div class="col-12">
|
||||
<MarkdownTextArea
|
||||
initialContent={this.state.siteForm.description}
|
||||
onContentChange={this.handleSiteDescriptionChange}
|
||||
initialContent={this.state.siteForm.sidebar}
|
||||
onContentChange={this.handleSiteSidebarChange}
|
||||
hideNavigationWarnings
|
||||
/>
|
||||
</div>
|
||||
|
@ -264,11 +282,16 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
|||
i.setState(i.state);
|
||||
}
|
||||
|
||||
handleSiteDescriptionChange(val: string) {
|
||||
this.state.siteForm.description = val;
|
||||
handleSiteSidebarChange(val: string) {
|
||||
this.state.siteForm.sidebar = val;
|
||||
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) {
|
||||
i.state.siteForm.enable_nsfw = event.target.checked;
|
||||
i.setState(i.state);
|
||||
|
|
|
@ -5125,10 +5125,10 @@ lcid@^1.0.0:
|
|||
dependencies:
|
||||
invert-kv "^1.0.0"
|
||||
|
||||
lemmy-js-client@0.11.0-rc.9:
|
||||
version "0.11.0-rc.9"
|
||||
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.11.0-rc.9.tgz#f8b1e3924388c6e7f719f052ba1568f4d210cabc"
|
||||
integrity sha512-697hLvHPr5+ZkJkFTaXl3y7Dt1va2Dghx9uvu/kZyZQZGVk2lL10R50SDaWsThyQKFBT4kiS1JZI+R3szzZEZQ==
|
||||
lemmy-js-client@0.11.0-rc.10:
|
||||
version "0.11.0-rc.10"
|
||||
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.11.0-rc.10.tgz#304b5b941a00fe251fb50c81e5ae795e8bf0bd8d"
|
||||
integrity sha512-bVLMnE1xm7mmmUC9gLIQ7wFNZn8HD3nmE56EhNGgqR76zdjZSSk+8ZqBYHUJ2yOikGebzIm0heMFryIsJuqwTg==
|
||||
|
||||
levn@^0.4.1:
|
||||
version "0.4.1"
|
||||
|
|
Loading…
Reference in a new issue