]> Untitled Git - lemmy-ui.git/commitdiff
Removing save and read config hjson. Fixes #695 (#696)
authorDessalines <dessalines@users.noreply.github.com>
Thu, 23 Jun 2022 14:05:56 +0000 (10:05 -0400)
committerGitHub <noreply@github.com>
Thu, 23 Jun 2022 14:05:56 +0000 (10:05 -0400)
package.json
src/shared/components/community/community.tsx
src/shared/components/home/admin-settings.tsx
src/shared/components/home/home.tsx
src/shared/components/home/site-form.tsx
src/shared/components/post/post.tsx
yarn.lock

index a64332244c7b187ffb35aa2773a4b9ee0d03092b..3fa26dbfe2b8c84be21867c3b7c1bbdbaafb648d 100644 (file)
@@ -77,7 +77,7 @@
     "eslint-plugin-prettier": "^4.0.0",
     "husky": "^7.0.4",
     "import-sort-style-module": "^6.0.0",
-    "lemmy-js-client": "0.17.0-rc.31",
+    "lemmy-js-client": "0.17.0-rc.32",
     "lint-staged": "^12.4.1",
     "mini-css-extract-plugin": "^2.6.0",
     "node-fetch": "^2.6.1",
index 732cba2f9037faf47f02c2ea4500ea85c09344c3..ab00af14a683af0be8720f24fcd6c9ba07925996 100644 (file)
@@ -171,7 +171,6 @@ export class Community extends Component<any, State> {
   componentWillUnmount() {
     saveScrollPosition(this.context);
     this.subscription.unsubscribe();
-    window.isoData.path = undefined;
   }
 
   static getDerivedStateFromProps(props: any): CommunityProps {
index 67a000c5df44e751575ac9d2490f6cb60715fe48..e01a09d7ac612a04ac274d987fd0b4d6b257f785 100644 (file)
@@ -1,16 +1,12 @@
-import { None, Option, Some } from "@sniptt/monads";
+import { None, Some } from "@sniptt/monads";
 import autosize from "autosize";
 import { Component, linkEvent } from "inferno";
 import {
   BannedPersonsResponse,
   GetBannedPersons,
-  GetSiteConfig,
-  GetSiteConfigResponse,
   GetSiteResponse,
   PersonViewSafe,
-  SaveSiteConfig,
   SiteResponse,
-  toUndefined,
   UserOperation,
   wsJsonToRes,
   wsUserOp,
@@ -37,29 +33,19 @@ import { SiteForm } from "./site-form";
 
 interface AdminSettingsState {
   siteRes: GetSiteResponse;
-  siteConfigRes: Option<GetSiteConfigResponse>;
-  siteConfigHjson: Option<string>;
   banned: PersonViewSafe[];
   loading: boolean;
-  siteConfigLoading: boolean;
   leaveAdminTeamLoading: boolean;
 }
 
 export class AdminSettings extends Component<any, AdminSettingsState> {
   private siteConfigTextAreaId = `site-config-${randomStr()}`;
-  private isoData = setIsoData(
-    this.context,
-    GetSiteConfigResponse,
-    BannedPersonsResponse
-  );
+  private isoData = setIsoData(this.context, BannedPersonsResponse);
   private subscription: Subscription;
   private emptyState: AdminSettingsState = {
     siteRes: this.isoData.site_res,
-    siteConfigHjson: None,
-    siteConfigRes: None,
     banned: [],
     loading: true,
-    siteConfigLoading: null,
     leaveAdminTeamLoading: null,
   };
 
@@ -73,23 +59,11 @@ export class AdminSettings extends Component<any, AdminSettingsState> {
 
     // Only fetch the data if coming from another route
     if (this.isoData.path == this.context.router.route.match.url) {
-      this.state.siteConfigRes = Some(
-        this.isoData.routeData[0] as GetSiteConfigResponse
-      );
-      this.state.siteConfigHjson = this.state.siteConfigRes.map(
-        s => s.config_hjson
-      );
       this.state.banned = (
-        this.isoData.routeData[1] as BannedPersonsResponse
+        this.isoData.routeData[0] as BannedPersonsResponse
       ).banned;
-      this.state.siteConfigLoading = false;
       this.state.loading = false;
     } else {
-      WebSocketService.Instance.send(
-        wsClient.getSiteConfig({
-          auth: auth().unwrap(),
-        })
-      );
       WebSocketService.Instance.send(
         wsClient.getBannedPersons({
           auth: auth().unwrap(),
@@ -101,9 +75,6 @@ export class AdminSettings extends Component<any, AdminSettingsState> {
   static fetchInitialData(req: InitialFetchRequest): Promise<any>[] {
     let promises: Promise<any>[] = [];
 
-    let siteConfigForm = new GetSiteConfig({ auth: req.auth.unwrap() });
-    promises.push(req.client.getSiteConfig(siteConfigForm));
-
     let bannedPersonsForm = new GetBannedPersons({ auth: req.auth.unwrap() });
     promises.push(req.client.getBannedPersons(bannedPersonsForm));
 
@@ -155,10 +126,11 @@ export class AdminSettings extends Component<any, AdminSettingsState> {
                 ),
                 none: <></>,
               })}
+            </div>
+            <div class="col-12 col-md-6">
               {this.admins()}
               {this.bannedUsers()}
             </div>
-            <div class="col-12 col-md-6">{this.adminSettings()}</div>
           </div>
         )}
       </div>
@@ -211,60 +183,6 @@ export class AdminSettings extends Component<any, AdminSettingsState> {
     );
   }
 
-  adminSettings() {
-    return (
-      <div>
-        <h5>{i18n.t("admin_settings")}</h5>
-        <form onSubmit={linkEvent(this, this.handleSiteConfigSubmit)}>
-          <div class="form-group row">
-            <label
-              class="col-12 col-form-label"
-              htmlFor={this.siteConfigTextAreaId}
-            >
-              {i18n.t("site_config")}
-            </label>
-            <div class="col-12">
-              <textarea
-                id={this.siteConfigTextAreaId}
-                value={toUndefined(this.state.siteConfigHjson)}
-                onInput={linkEvent(this, this.handleSiteConfigHjsonChange)}
-                class="form-control text-monospace"
-                rows={3}
-              />
-            </div>
-          </div>
-          <div class="form-group row">
-            <div class="col-12">
-              <button type="submit" class="btn btn-secondary mr-2">
-                {this.state.siteConfigLoading ? (
-                  <Spinner />
-                ) : (
-                  capitalizeFirstLetter(i18n.t("save"))
-                )}
-              </button>
-            </div>
-          </div>
-        </form>
-      </div>
-    );
-  }
-
-  handleSiteConfigSubmit(i: AdminSettings, event: any) {
-    event.preventDefault();
-    i.state.siteConfigLoading = true;
-    let form = new SaveSiteConfig({
-      config_hjson: toUndefined(i.state.siteConfigHjson),
-      auth: auth().unwrap(),
-    });
-    WebSocketService.Instance.send(wsClient.saveSiteConfig(form));
-    i.setState(i.state);
-  }
-
-  handleSiteConfigHjsonChange(i: AdminSettings, event: any) {
-    i.state.siteConfigHjson = event.target.value;
-    i.setState(i.state);
-  }
-
   handleLeaveAdminTeam(i: AdminSettings) {
     i.state.leaveAdminTeamLoading = true;
     WebSocketService.Instance.send(
@@ -290,17 +208,8 @@ export class AdminSettings extends Component<any, AdminSettingsState> {
     } else if (op == UserOperation.GetBannedPersons) {
       let data = wsJsonToRes<BannedPersonsResponse>(msg, BannedPersonsResponse);
       this.state.banned = data.banned;
-      this.setState(this.state);
-    } else if (op == UserOperation.GetSiteConfig) {
-      let data = wsJsonToRes<GetSiteConfigResponse>(msg, GetSiteConfigResponse);
-      this.state.siteConfigRes = Some(data);
       this.state.loading = false;
-      this.state.siteConfigHjson = this.state.siteConfigRes.map(
-        s => s.config_hjson
-      );
       this.setState(this.state);
-      var textarea: any = document.getElementById(this.siteConfigTextAreaId);
-      autosize(textarea);
     } else if (op == UserOperation.LeaveAdmin) {
       let data = wsJsonToRes<GetSiteResponse>(msg, GetSiteResponse);
       this.state.siteRes.site_view = data.site_view;
@@ -309,15 +218,6 @@ export class AdminSettings extends Component<any, AdminSettingsState> {
       toast(i18n.t("left_admin_team"));
       this.setState(this.state);
       this.context.router.history.push("/");
-    } else if (op == UserOperation.SaveSiteConfig) {
-      let data = wsJsonToRes<GetSiteConfigResponse>(msg, GetSiteConfigResponse);
-      this.state.siteConfigRes = Some(data);
-      this.state.siteConfigHjson = this.state.siteConfigRes.map(
-        s => s.config_hjson
-      );
-      this.state.siteConfigLoading = false;
-      toast(i18n.t("site_saved"));
-      this.setState(this.state);
     }
   }
 }
index 5ae35883b4fd7fff885bd8a6ef8fed9753349369..6baea78326c35acb4b0e59a5139319ff4256922d 100644 (file)
@@ -194,7 +194,6 @@ export class Home extends Component<any, HomeState> {
   componentWillUnmount() {
     saveScrollPosition(this.context);
     this.subscription.unsubscribe();
-    window.isoData.path = undefined;
   }
 
   static getDerivedStateFromProps(props: any): HomeProps {
index c6533710229df5f2c7c85033942aa6aa6b1e6149..09a7ca352e26f46109cc0b2fec355d08f814d5b4 100644 (file)
@@ -98,7 +98,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
           default_theme: Some(site.default_theme),
           default_post_listing_type: Some(site.default_post_listing_type),
           legal_information: site.legal_information,
-          auth: auth(false).unwrap(),
+          auth: undefined,
         });
       },
       none: void 0,
index 00d2789973f755355f42daa4f7b7ffef7ff5da6c..9b42282d67f1e5c987b0510133391105cc99bf18 100644 (file)
@@ -198,7 +198,6 @@ export class Post extends Component<any, PostState> {
     this.subscription.unsubscribe();
     document.removeEventListener("scroll", this.commentScrollDebounced);
 
-    window.isoData.path = undefined;
     saveScrollPosition(this.context);
   }
 
index 571c0a49b79d9cf7e8d594a1c6b66344d4ff6732..a5a342a86aab29a35053e78ebfd9abc24c6b1489 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
@@ -4948,10 +4948,10 @@ lcid@^1.0.0:
   dependencies:
     invert-kv "^1.0.0"
 
-lemmy-js-client@0.17.0-rc.31:
-  version "0.17.0-rc.31"
-  resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.17.0-rc.31.tgz#373ad2dcbb1305bd82e7fb13704fbdb8d2f1c438"
-  integrity sha512-hcjFcOxgplffQullf9HuAGv2ko9wWySrnv+s8FWPPpg4EsixuBjXI+Dh7y0GR/KVs6fRmeXn4YBhR2YdJsBc7A==
+lemmy-js-client@0.17.0-rc.32:
+  version "0.17.0-rc.32"
+  resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.17.0-rc.32.tgz#d67f432f1fffc54c267f915278fe260ec554b018"
+  integrity sha512-qPLybaesu3GVr1DMStsyCYanW4maxHrqX71UHadFMeuh+aUK8taC3zfsLRK9dlIlSDRS283xd8IZkI6ZlcOVEQ==
 
 levn@^0.4.1:
   version "0.4.1"