]> Untitled Git - lemmy-ui.git/commitdiff
Adding site desc. Fixes #266
authorDessalines <tyhou13@gmx.com>
Fri, 23 Apr 2021 22:26:36 +0000 (18:26 -0400)
committerDessalines <tyhou13@gmx.com>
Fri, 23 Apr 2021 22:26:36 +0000 (18:26 -0400)
lemmy-translations
package.json
src/shared/components/main.tsx
src/shared/components/site-form.tsx
yarn.lock

index 764d35d913453d1fd8eeec6007f0d94f59c8b0ee..12e8d61e9ba2620b0031e237d87367480452b6fb 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 764d35d913453d1fd8eeec6007f0d94f59c8b0ee
+Subproject commit 12e8d61e9ba2620b0031e237d87367480452b6fb
index 1685494ad6ccbc087487977ab33da830a0c4648f..7cc904da46d1aa432dd09f5595512c10b2f424f8 100644 (file)
@@ -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",
index 5374be553a2478588ffe52ccc72f6aee1f111bf0..8fafeb103c5fdc42c1ed35491c3368fefb6bf391 100644 (file)
@@ -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
         )}
       />
     );
index 1e7f0cdf6a3dc32270c993c75ecd539df1332d2b..f68d79314605de22292103ccf52e06fad88eb465 100644 (file)
@@ -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);
index 35d861a9256bd8a5f18f3c3b4c9119057ef8c5da..712c0a6b1b56daabc7fe7f32aff4f1705c8de368 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
@@ -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"