From aecf74951cecb4de9ca94dd93e48af6f62300a0f Mon Sep 17 00:00:00 2001
From: tobi <31960611+tsmethurst@users.noreply.github.com>
Date: Thu, 25 Apr 2024 18:24:24 +0200
Subject: [chore] Settings refactor 2: the re-refactoring-ing (#2866)
* [chore] Bit more refactoring of settings panel
* fix up some remaining things
* groovy baby yeah!
* remove unused Suspense
---
.../views/admin/actions/keys/expireremote.tsx | 2 +-
.../settings/views/admin/actions/media/cleanup.tsx | 2 +-
.../settings/views/admin/emoji/local/new-emoji.tsx | 2 +-
.../settings/views/admin/emoji/local/overview.tsx | 2 +-
.../settings/views/admin/instance/ruledetail.tsx | 103 +++++++++++
web/source/settings/views/admin/instance/rules.tsx | 75 ++++++++
.../settings/views/admin/instance/settings.tsx | 186 ++++++++++++++++++++
web/source/settings/views/admin/menu.tsx | 129 ++++++++++++++
web/source/settings/views/admin/router.tsx | 151 ++++++++++++++++
web/source/settings/views/admin/routes.tsx | 177 -------------------
web/source/settings/views/admin/settings/index.tsx | 190 ---------------------
web/source/settings/views/admin/settings/rules.tsx | 151 ----------------
12 files changed, 648 insertions(+), 522 deletions(-)
create mode 100644 web/source/settings/views/admin/instance/ruledetail.tsx
create mode 100644 web/source/settings/views/admin/instance/rules.tsx
create mode 100644 web/source/settings/views/admin/instance/settings.tsx
create mode 100644 web/source/settings/views/admin/menu.tsx
create mode 100644 web/source/settings/views/admin/router.tsx
delete mode 100644 web/source/settings/views/admin/routes.tsx
delete mode 100644 web/source/settings/views/admin/settings/index.tsx
delete mode 100644 web/source/settings/views/admin/settings/rules.tsx
(limited to 'web/source/settings/views/admin')
diff --git a/web/source/settings/views/admin/actions/keys/expireremote.tsx b/web/source/settings/views/admin/actions/keys/expireremote.tsx
index c7a410267..82045942c 100644
--- a/web/source/settings/views/admin/actions/keys/expireremote.tsx
+++ b/web/source/settings/views/admin/actions/keys/expireremote.tsx
@@ -18,10 +18,10 @@
*/
import React from "react";
-import { useInstanceKeysExpireMutation } from "../../../../lib/query";
import { TextInput } from "../../../../components/form/inputs";
import MutationButton from "../../../../components/form/mutation-button";
import { useTextInput } from "../../../../lib/form";
+import { useInstanceKeysExpireMutation } from "../../../../lib/query/admin";
export default function ExpireRemote({}) {
const domainField = useTextInput("domain");
diff --git a/web/source/settings/views/admin/actions/media/cleanup.tsx b/web/source/settings/views/admin/actions/media/cleanup.tsx
index d4bae24a6..c1df511e1 100644
--- a/web/source/settings/views/admin/actions/media/cleanup.tsx
+++ b/web/source/settings/views/admin/actions/media/cleanup.tsx
@@ -19,10 +19,10 @@
import React from "react";
-import { useMediaCleanupMutation } from "../../../../lib/query";
import { useTextInput } from "../../../../lib/form";
import { TextInput } from "../../../../components/form/inputs";
import MutationButton from "../../../../components/form/mutation-button";
+import { useMediaCleanupMutation } from "../../../../lib/query/admin";
export default function Cleanup({}) {
const daysField = useTextInput("days", { defaultValue: "30" });
diff --git a/web/source/settings/views/admin/emoji/local/new-emoji.tsx b/web/source/settings/views/admin/emoji/local/new-emoji.tsx
index 73e846f16..8ff8236a7 100644
--- a/web/source/settings/views/admin/emoji/local/new-emoji.tsx
+++ b/web/source/settings/views/admin/emoji/local/new-emoji.tsx
@@ -26,7 +26,7 @@ import { CategorySelect } from '../category-select';
import FakeToot from "../../../../components/fake-toot";
import MutationButton from "../../../../components/form/mutation-button";
import { useAddEmojiMutation } from "../../../../lib/query/admin/custom-emoji";
-import { useInstanceV1Query } from "../../../../lib/query";
+import { useInstanceV1Query } from "../../../../lib/query/gts-api";
export default function NewEmojiForm() {
const shortcode = useShortcode();
diff --git a/web/source/settings/views/admin/emoji/local/overview.tsx b/web/source/settings/views/admin/emoji/local/overview.tsx
index b28af59f3..b4fa48d74 100644
--- a/web/source/settings/views/admin/emoji/local/overview.tsx
+++ b/web/source/settings/views/admin/emoji/local/overview.tsx
@@ -29,7 +29,7 @@ import { TextInput } from "../../../../components/form/inputs";
import { useListEmojiQuery } from "../../../../lib/query/admin/custom-emoji";
import { CustomEmoji } from "../../../../lib/types/custom-emoji";
-export function EmojiOverview() {
+export default function EmojiOverview() {
const { data: emoji = [], isLoading, isError, error } = useListEmojiQuery({ filter: "domain:local" });
let content: React.JSX.Element;
diff --git a/web/source/settings/views/admin/instance/ruledetail.tsx b/web/source/settings/views/admin/instance/ruledetail.tsx
new file mode 100644
index 000000000..31447c74b
--- /dev/null
+++ b/web/source/settings/views/admin/instance/ruledetail.tsx
@@ -0,0 +1,103 @@
+/*
+ GoToSocial
+ Copyright (C) GoToSocial Authors admin@gotosocial.org
+ SPDX-License-Identifier: AGPL-3.0-or-later
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
+import React from "react";
+import { Redirect, useParams } from "wouter";
+import { useBaseUrl } from "../../../lib/navigation/util";
+import { useValue, useTextInput } from "../../../lib/form";
+import useFormSubmit from "../../../lib/form/submit";
+import { TextArea } from "../../../components/form/inputs";
+import MutationButton from "../../../components/form/mutation-button";
+import BackButton from "../../../components/back-button";
+import Loading from "../../../components/loading";
+import { useDeleteInstanceRuleMutation, useInstanceRulesQuery, useUpdateInstanceRuleMutation } from "../../../lib/query/admin";
+import { Error } from "../../../components/error";
+
+export default function InstanceRuleDetail() {
+ const baseUrl = useBaseUrl();
+ const params: { ruleId: string } = useParams();
+
+ const { data: rules, isLoading, isError, error } = useInstanceRulesQuery();
+ if (isLoading) {
+ return ;
+ } else if (isError) {
+ return ;
+ }
+
+ if (rules === undefined) {
+ throw "undefined rules";
+ }
+
+ return (
+ <>
+
+
+ >
+ );
+}
+
+function EditInstanceRuleForm({ rule }) {
+ const baseUrl = useBaseUrl();
+ const form = {
+ id: useValue("id", rule.id),
+ rule: useTextInput("text", { defaultValue: rule.text })
+ };
+
+ const [submitForm, result] = useFormSubmit(form, useUpdateInstanceRuleMutation());
+
+ const [deleteRule, deleteResult] = useDeleteInstanceRuleMutation({ fixedCacheKey: rule.id });
+
+ if (result.isSuccess || deleteResult.isSuccess) {
+ return (
+
+ );
+ }
+
+ return (
+
+
+
+ );
+}
diff --git a/web/source/settings/views/admin/instance/rules.tsx b/web/source/settings/views/admin/instance/rules.tsx
new file mode 100644
index 000000000..45ad90103
--- /dev/null
+++ b/web/source/settings/views/admin/instance/rules.tsx
@@ -0,0 +1,75 @@
+/*
+ GoToSocial
+ Copyright (C) GoToSocial Authors admin@gotosocial.org
+ SPDX-License-Identifier: AGPL-3.0-or-later
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
+import React from "react";
+import { Link } from "wouter";
+import { useInstanceRulesQuery, useAddInstanceRuleMutation } from "../../../lib/query/admin";
+import { useBaseUrl } from "../../../lib/navigation/util";
+import { useTextInput } from "../../../lib/form";
+import useFormSubmit from "../../../lib/form/submit";
+import { TextArea } from "../../../components/form/inputs";
+import MutationButton from "../../../components/form/mutation-button";
+import { InstanceRule, MappedRules } from "../../../lib/types/rules";
+import FormWithData from "../../../lib/form/form-with-data";
+
+export default function InstanceRules() {
+ return (
+ <>
+
Instance Rules
+
+ >
+ );
+}
+
+function InstanceRulesForm({ data: rules }: { data: MappedRules }) {
+ const baseUrl = useBaseUrl();
+ const newRule = useTextInput("text");
+
+ const [submitForm, result] = useFormSubmit({ newRule }, useAddInstanceRuleMutation(), {
+ changedOnly: true,
+ onFinish: () => newRule.reset()
+ });
+
+ return (
+
+ );
+}
diff --git a/web/source/settings/views/admin/instance/settings.tsx b/web/source/settings/views/admin/instance/settings.tsx
new file mode 100644
index 000000000..03a961589
--- /dev/null
+++ b/web/source/settings/views/admin/instance/settings.tsx
@@ -0,0 +1,186 @@
+/*
+ GoToSocial
+ Copyright (C) GoToSocial Authors admin@gotosocial.org
+ SPDX-License-Identifier: AGPL-3.0-or-later
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
+import React from "react";
+
+import { useTextInput, useFileInput } from "../../../lib/form";
+import { TextInput, TextArea, FileInput } from "../../../components/form/inputs";
+import MutationButton from "../../../components/form/mutation-button";
+import { useInstanceV1Query } from "../../../lib/query/gts-api";
+import { useUpdateInstanceMutation } from "../../../lib/query/admin";
+import { InstanceV1 } from "../../../lib/types/instance";
+import FormWithData from "../../../lib/form/form-with-data";
+import useFormSubmit from "../../../lib/form/submit";
+
+export default function InstanceSettings() {
+ return (
+
+ );
+}
+
+interface InstanceSettingsFormProps{
+ data: InstanceV1;
+}
+
+function InstanceSettingsForm({ data: instance }: InstanceSettingsFormProps) {
+ const titleLimit = 40;
+ const shortDescLimit = 500;
+ const descLimit = 5000;
+ const termsLimit = 5000;
+
+ const form = {
+ title: useTextInput("title", {
+ source: instance,
+ validator: (val: string) => val.length <= titleLimit ? "" : `Instance title is ${val.length} characters; must be ${titleLimit} characters or less`
+ }),
+ thumbnail: useFileInput("thumbnail", { withPreview: true }),
+ thumbnailDesc: useTextInput("thumbnail_description", { source: instance }),
+ shortDesc: useTextInput("short_description", {
+ source: instance,
+ // Select "raw" text version of parsed field for editing.
+ valueSelector: (s: InstanceV1) => s.short_description_text,
+ validator: (val: string) => val.length <= shortDescLimit ? "" : `Instance short description is ${val.length} characters; must be ${shortDescLimit} characters or less`
+ }),
+ description: useTextInput("description", {
+ source: instance,
+ // Select "raw" text version of parsed field for editing.
+ valueSelector: (s: InstanceV1) => s.description_text,
+ validator: (val: string) => val.length <= descLimit ? "" : `Instance description is ${val.length} characters; must be ${descLimit} characters or less`
+ }),
+ terms: useTextInput("terms", {
+ source: instance,
+ // Select "raw" text version of parsed field for editing.
+ valueSelector: (s: InstanceV1) => s.terms_text,
+ validator: (val: string) => val.length <= termsLimit ? "" : `Instance terms and conditions is ${val.length} characters; must be ${termsLimit} characters or less`
+ }),
+ contactUser: useTextInput("contact_username", { source: instance, valueSelector: (s) => s.contact_account?.username }),
+ contactEmail: useTextInput("contact_email", { source: instance, valueSelector: (s) => s.email })
+ };
+
+ const [submitForm, result] = useFormSubmit(form, useUpdateInstanceMutation());
+
+ return (
+
+ );
+}
\ No newline at end of file
diff --git a/web/source/settings/views/admin/menu.tsx b/web/source/settings/views/admin/menu.tsx
new file mode 100644
index 000000000..2cf5a35c2
--- /dev/null
+++ b/web/source/settings/views/admin/menu.tsx
@@ -0,0 +1,129 @@
+/*
+ GoToSocial
+ Copyright (C) GoToSocial Authors admin@gotosocial.org
+ SPDX-License-Identifier: AGPL-3.0-or-later
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
+import { MenuItem } from "../../lib/navigation/menu";
+import React from "react";
+import { useHasPermission } from "../../lib/navigation/util";
+
+/*
+ EXPORTED COMPONENTS
+*/
+
+/**
+ * - /settings/admin/instance/settings
+ * - /settings/admin/instance/rules
+ * - /settings/admin/instance/rules/:ruleId
+ * - /settings/admin/emojis
+ * - /settings/admin/emojis/local
+ * - /settings/admin/emojis/local/:emojiId
+ * - /settings/admin/emojis/remote
+ * - /settings/admin/actions
+ * - /settings/admin/actions/media
+ * - /settings/admin/actions/keys
+ */
+export default function AdminMenu() {
+ const permissions = ["admin"];
+ const admin = useHasPermission(permissions);
+ if (!admin) {
+ return null;
+ }
+
+ return (
+
+ );
+}
+
+/*
+ INTERNAL COMPONENTS
+*/
+
+function AdminInstanceMenu() {
+ return (
+
+ );
+}
+
+function AdminActionsMenu() {
+ return (
+
+
+
+
+ );
+}
+
+function AdminEmojisMenu() {
+ return (
+
+
+
+
+ );
+}
diff --git a/web/source/settings/views/admin/router.tsx b/web/source/settings/views/admin/router.tsx
new file mode 100644
index 000000000..95d146510
--- /dev/null
+++ b/web/source/settings/views/admin/router.tsx
@@ -0,0 +1,151 @@
+/*
+ GoToSocial
+ Copyright (C) GoToSocial Authors admin@gotosocial.org
+ SPDX-License-Identifier: AGPL-3.0-or-later
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+
+import React from "react";
+import { BaseUrlContext, useBaseUrl, useHasPermission } from "../../lib/navigation/util";
+import { Redirect, Route, Router, Switch } from "wouter";
+import { ErrorBoundary } from "../../lib/navigation/error";
+import InstanceSettings from "./instance/settings";
+import InstanceRules from "./instance/rules";
+import InstanceRuleDetail from "./instance/ruledetail";
+import Media from "./actions/media";
+import Keys from "./actions/keys";
+import EmojiOverview from "./emoji/local/overview";
+import EmojiDetail from "./emoji/local/detail";
+import RemoteEmoji from "./emoji/remote";
+
+/*
+ EXPORTED COMPONENTS
+*/
+
+/**
+ * - /settings/instance/settings
+ * - /settings/instance/rules
+ * - /settings/instance/rules/:ruleId
+ * - /settings/admin/emojis
+ * - /settings/admin/emojis/local
+ * - /settings/admin/emojis/local/:emojiId
+ * - /settings/admin/emojis/remote
+ * - /settings/admin/actions
+ * - /settings/admin/actions/media
+ * - /settings/admin/actions/keys
+ */
+export default function AdminRouter() {
+ const parentUrl = useBaseUrl();
+ const thisBase = "/admin";
+ const absBase = parentUrl + thisBase;
+
+ return (
+
+
+
+
+
+
+
+ );
+}
+
+/*
+ INTERNAL COMPONENTS
+*/
+
+/**
+ * - /settings/admin/emojis
+ * - /settings/admin/emojis/local
+ * - /settings/admin/emojis/local/:emojiId
+ * - /settings/admin/emojis/remote
+ */
+function AdminEmojisRouter() {
+ const parentUrl = useBaseUrl();
+ const thisBase = "/emojis";
+ const absBase = parentUrl + thisBase;
+
+ const permissions = ["admin"];
+ const admin = useHasPermission(permissions);
+ if (!admin) {
+ return null;
+ }
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+}
+
+/**
+ * - /settings/admin/actions
+ * - /settings/admin/actions/media
+ * - /settings/admin/actions/keys
+ */
+function AdminActionsRouter() {
+ const parentUrl = useBaseUrl();
+ const thisBase = "/actions";
+ const absBase = parentUrl + thisBase;
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
+ );
+}
+
+/**
+ * - /settings/instance/settings
+ * - /settings/instance/rules
+ * - /settings/instance/rules/:ruleId
+ */
+function AdminInstanceRouter() {
+ const parentUrl = useBaseUrl();
+ const thisBase = "/instance";
+ const absBase = parentUrl + thisBase;
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+}
diff --git a/web/source/settings/views/admin/routes.tsx b/web/source/settings/views/admin/routes.tsx
deleted file mode 100644
index 29889046c..000000000
--- a/web/source/settings/views/admin/routes.tsx
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- GoToSocial
- Copyright (C) GoToSocial Authors admin@gotosocial.org
- SPDX-License-Identifier: AGPL-3.0-or-later
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-import { MenuItem } from "../../lib/navigation/menu";
-import React from "react";
-import { BaseUrlContext, useBaseUrl } from "../../lib/navigation/util";
-import { Route, Router, Switch } from "wouter";
-import EmojiDetail from "./emoji/local/detail";
-import { EmojiOverview } from "./emoji/local/overview";
-import RemoteEmoji from "./emoji/remote";
-import InstanceSettings from "./settings";
-import { InstanceRuleDetail, InstanceRules } from "./settings/rules";
-import Media from "./actions/media";
-import Keys from "./actions/keys";
-
-/*
- EXPORTED COMPONENTS
-*/
-
-/**
- * Admininistration menu. Admin actions,
- * emoji import, instance settings.
- */
-export function AdminMenu() {
- return (
-
-
-
-
-
-
- );
-}
-
-/**
- * Admininistration router. Admin actions,
- * emoji import, instance settings.
- */
-export function AdminRouter() {
- const parentUrl = useBaseUrl();
- const thisBase = "/admin";
- const absBase = parentUrl + thisBase;
-
- return (
-
-
-
-
-
-
-
-
-
- );
-}
-
-/*
- INTERNAL COMPONENTS
-*/
-
-/*
- MENUS
-*/
-
-function AdminActionsMenu() {
- return (
-
-
-
-
- );
-}
-
-function AdminEmojisMenu() {
- return (
-
-
-
-
- );
-}
-
-/*
- ROUTERS
-*/
-
-function AdminEmojisRouter() {
- const parentUrl = useBaseUrl();
- const thisBase = "/emojis";
- const absBase = parentUrl + thisBase;
-
- return (
-
-
-
-
-
-
-
-
-
-
- );
-}
-
-function AdminActionsRouter() {
- const parentUrl = useBaseUrl();
- const thisBase = "/actions";
- const absBase = parentUrl + thisBase;
-
- return (
-
-
-
-
-
-
-
-
-
- );
-}
diff --git a/web/source/settings/views/admin/settings/index.tsx b/web/source/settings/views/admin/settings/index.tsx
deleted file mode 100644
index abb34cf66..000000000
--- a/web/source/settings/views/admin/settings/index.tsx
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- GoToSocial
- Copyright (C) GoToSocial Authors admin@gotosocial.org
- SPDX-License-Identifier: AGPL-3.0-or-later
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-import React from "react";
-
-import { useTextInput, useFileInput } from "../../../lib/form";
-
-const useFormSubmit = require("../../../lib/form/submit").default;
-
-import { TextInput, TextArea, FileInput } from "../../../components/form/inputs";
-
-const FormWithData = require("../../../lib/form/form-with-data").default;
-import MutationButton from "../../../components/form/mutation-button";
-
-import { useInstanceV1Query } from "../../../lib/query";
-import { useUpdateInstanceMutation } from "../../../lib/query/admin";
-import { InstanceV1 } from "../../../lib/types/instance";
-
-export default function InstanceSettings() {
- return (
-
- );
-}
-
-interface InstanceSettingsFormProps{
- data: InstanceV1;
-}
-
-function InstanceSettingsForm({ data: instance }: InstanceSettingsFormProps) {
- const titleLimit = 40;
- const shortDescLimit = 500;
- const descLimit = 5000;
- const termsLimit = 5000;
-
- const form = {
- title: useTextInput("title", {
- source: instance,
- validator: (val: string) => val.length <= titleLimit ? "" : `Instance title is ${val.length} characters; must be ${titleLimit} characters or less`
- }),
- thumbnail: useFileInput("thumbnail", { withPreview: true }),
- thumbnailDesc: useTextInput("thumbnail_description", { source: instance }),
- shortDesc: useTextInput("short_description", {
- source: instance,
- // Select "raw" text version of parsed field for editing.
- valueSelector: (s: InstanceV1) => s.short_description_text,
- validator: (val: string) => val.length <= shortDescLimit ? "" : `Instance short description is ${val.length} characters; must be ${shortDescLimit} characters or less`
- }),
- description: useTextInput("description", {
- source: instance,
- // Select "raw" text version of parsed field for editing.
- valueSelector: (s: InstanceV1) => s.description_text,
- validator: (val: string) => val.length <= descLimit ? "" : `Instance description is ${val.length} characters; must be ${descLimit} characters or less`
- }),
- terms: useTextInput("terms", {
- source: instance,
- // Select "raw" text version of parsed field for editing.
- valueSelector: (s: InstanceV1) => s.terms_text,
- validator: (val: string) => val.length <= termsLimit ? "" : `Instance terms and conditions is ${val.length} characters; must be ${termsLimit} characters or less`
- }),
- contactUser: useTextInput("contact_username", { source: instance, valueSelector: (s) => s.contact_account?.username }),
- contactEmail: useTextInput("contact_email", { source: instance, valueSelector: (s) => s.email })
- };
-
- const [submitForm, result] = useFormSubmit(form, useUpdateInstanceMutation());
-
- return (
-
- );
-}
\ No newline at end of file
diff --git a/web/source/settings/views/admin/settings/rules.tsx b/web/source/settings/views/admin/settings/rules.tsx
deleted file mode 100644
index 2b8a51c22..000000000
--- a/web/source/settings/views/admin/settings/rules.tsx
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- GoToSocial
- Copyright (C) GoToSocial Authors admin@gotosocial.org
- SPDX-License-Identifier: AGPL-3.0-or-later
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-import React from "react";
-import { Link, Redirect, useParams } from "wouter";
-import { useInstanceRulesQuery, useAddInstanceRuleMutation, useUpdateInstanceRuleMutation, useDeleteInstanceRuleMutation } from "../../../lib/query";
-import { useBaseUrl } from "../../../lib/navigation/util";
-import { useValue, useTextInput } from "../../../lib/form";
-import useFormSubmit from "../../../lib/form/submit";
-import { TextArea } from "../../../components/form/inputs";
-import MutationButton from "../../../components/form/mutation-button";
-import { Error } from "../../../components/error";
-import BackButton from "../../../components/back-button";
-import { InstanceRule, MappedRules } from "../../../lib/types/rules";
-import Loading from "../../../components/loading";
-import FormWithData from "../../../lib/form/form-with-data";
-
-export function InstanceRules() {
- return (
- <>
-