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
---
web/source/index.js | 2 +-
web/source/package.json | 8 +-
web/source/settings/components/back-button.jsx | 27 -
web/source/settings/components/back-button.tsx | 27 +
web/source/settings/components/combo-box.jsx | 51 -
web/source/settings/components/combo-box.tsx | 47 +
web/source/settings/components/error.jsx | 84 --
web/source/settings/components/error.tsx | 84 ++
web/source/settings/components/fake-profile.jsx | 52 -
web/source/settings/components/fake-profile.tsx | 52 +
web/source/settings/components/fake-toot.jsx | 57 -
web/source/settings/components/fake-toot.tsx | 56 +
web/source/settings/components/languages.jsx | 34 -
web/source/settings/components/languages.tsx | 34 +
web/source/settings/components/loading.jsx | 26 -
web/source/settings/components/loading.tsx | 26 +
.../settings/components/user-logout-card.jsx | 47 -
.../settings/components/user-logout-card.tsx | 44 +
web/source/settings/index.tsx | 35 +-
web/source/settings/lib/query/index.js | 25 -
web/source/settings/style.css | 20 +-
.../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 ---
.../views/moderation/accounts/detail/actions.tsx | 5 +-
.../moderation/accounts/detail/handlesignup.tsx | 6 +-
.../views/moderation/accounts/detail/index.tsx | 5 +-
.../views/moderation/accounts/pending/index.tsx | 2 +-
.../views/moderation/accounts/search/index.tsx | 3 +-
.../views/moderation/domain-permissions/form.tsx | 4 -
.../moderation/domain-permissions/overview.tsx | 3 -
.../moderation/domain-permissions/process.tsx | 2 -
web/source/settings/views/moderation/menu.tsx | 121 +++
.../settings/views/moderation/reports/detail.tsx | 10 +-
.../settings/views/moderation/reports/overview.tsx | 4 +-
.../settings/views/moderation/reports/username.tsx | 36 +-
web/source/settings/views/moderation/router.tsx | 149 +++
web/source/settings/views/moderation/routes.tsx | 201 ----
web/source/settings/views/user/menu.tsx | 52 +
web/source/settings/views/user/profile.tsx | 3 +-
web/source/settings/views/user/router.tsx | 52 +
web/source/settings/views/user/routes.tsx | 80 --
web/source/settings/views/user/settings.tsx | 9 +-
web/source/tsconfig.json | 6 +-
web/source/yarn.lock | 1099 ++++++++++++--------
54 files changed, 2131 insertions(+), 1729 deletions(-)
delete mode 100644 web/source/settings/components/back-button.jsx
create mode 100644 web/source/settings/components/back-button.tsx
delete mode 100644 web/source/settings/components/combo-box.jsx
create mode 100644 web/source/settings/components/combo-box.tsx
delete mode 100644 web/source/settings/components/error.jsx
create mode 100644 web/source/settings/components/error.tsx
delete mode 100644 web/source/settings/components/fake-profile.jsx
create mode 100644 web/source/settings/components/fake-profile.tsx
delete mode 100644 web/source/settings/components/fake-toot.jsx
create mode 100644 web/source/settings/components/fake-toot.tsx
delete mode 100644 web/source/settings/components/languages.jsx
create mode 100644 web/source/settings/components/languages.tsx
delete mode 100644 web/source/settings/components/loading.jsx
create mode 100644 web/source/settings/components/loading.tsx
delete mode 100644 web/source/settings/components/user-logout-card.jsx
create mode 100644 web/source/settings/components/user-logout-card.tsx
delete mode 100644 web/source/settings/lib/query/index.js
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
create mode 100644 web/source/settings/views/moderation/menu.tsx
create mode 100644 web/source/settings/views/moderation/router.tsx
delete mode 100644 web/source/settings/views/moderation/routes.tsx
create mode 100644 web/source/settings/views/user/menu.tsx
create mode 100644 web/source/settings/views/user/router.tsx
delete mode 100644 web/source/settings/views/user/routes.tsx
diff --git a/web/source/index.js b/web/source/index.js
index d9ef70ff9..5cee28046 100644
--- a/web/source/index.js
+++ b/web/source/index.js
@@ -96,4 +96,4 @@ skulk({
}]]
}
}
-});
\ No newline at end of file
+});
diff --git a/web/source/package.json b/web/source/package.json
index d72cf7764..919bf3c83 100644
--- a/web/source/package.json
+++ b/web/source/package.json
@@ -35,10 +35,10 @@
"wouter": "^3.1.0"
},
"devDependencies": {
- "@babel/core": "^7.23.0",
- "@babel/preset-env": "^7.22.20",
- "@babel/preset-react": "^7.22.15",
- "@babel/preset-typescript": "^7.23.0",
+ "@babel/core": "^7.24.4",
+ "@babel/preset-env": "^7.24.4",
+ "@babel/preset-react": "^7.24.1",
+ "@babel/preset-typescript": "^7.24.1",
"@browserify/envify": "^6.0.0",
"@browserify/uglifyify": "^6.0.0",
"@joepie91/eslint-config": "^1.1.1",
diff --git a/web/source/settings/components/back-button.jsx b/web/source/settings/components/back-button.jsx
deleted file mode 100644
index bf9038b2b..000000000
--- a/web/source/settings/components/back-button.jsx
+++ /dev/null
@@ -1,27 +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 } from "wouter";
-
-export default function BackButton({ to }) {
- return (
- < back
- );
-}
diff --git a/web/source/settings/components/back-button.tsx b/web/source/settings/components/back-button.tsx
new file mode 100644
index 000000000..bf9038b2b
--- /dev/null
+++ b/web/source/settings/components/back-button.tsx
@@ -0,0 +1,27 @@
+/*
+ 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";
+
+export default function BackButton({ to }) {
+ return (
+ < back
+ );
+}
diff --git a/web/source/settings/components/combo-box.jsx b/web/source/settings/components/combo-box.jsx
deleted file mode 100644
index fc0133583..000000000
--- a/web/source/settings/components/combo-box.jsx
+++ /dev/null
@@ -1,51 +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 .
-*/
-
-const React = require("react");
-
-const {
- Combobox,
- ComboboxItem,
- ComboboxPopover,
-} = require("ariakit/combobox");
-
-module.exports = function ComboBox({ field, items, label, children, ...inputProps }) {
- return (
-
- );
-};
\ No newline at end of file
diff --git a/web/source/settings/components/combo-box.tsx b/web/source/settings/components/combo-box.tsx
new file mode 100644
index 000000000..113e6179d
--- /dev/null
+++ b/web/source/settings/components/combo-box.tsx
@@ -0,0 +1,47 @@
+/*
+ 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 { Combobox, ComboboxItem, ComboboxPopover } from "ariakit/combobox";
+
+export default function ComboBox({ field, items, label, children, ...inputProps }) {
+ return (
+
+ );
+}
\ No newline at end of file
diff --git a/web/source/settings/components/error.jsx b/web/source/settings/components/error.jsx
deleted file mode 100644
index 3205cd5e3..000000000
--- a/web/source/settings/components/error.jsx
+++ /dev/null
@@ -1,84 +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 .
-*/
-
-const React = require("react");
-
-function ErrorFallback({ error, resetErrorBoundary }) {
- return (
-
- );
-}
-
-module.exports = { ErrorFallback, Error };
\ No newline at end of file
diff --git a/web/source/settings/components/error.tsx b/web/source/settings/components/error.tsx
new file mode 100644
index 000000000..15c3bccd4
--- /dev/null
+++ b/web/source/settings/components/error.tsx
@@ -0,0 +1,84 @@
+/*
+ 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";
+
+function ErrorFallback({ error, resetErrorBoundary }) {
+ return (
+
+ );
+}
+
+export { ErrorFallback, Error };
diff --git a/web/source/settings/components/fake-profile.jsx b/web/source/settings/components/fake-profile.jsx
deleted file mode 100644
index 6cb8d0187..000000000
--- a/web/source/settings/components/fake-profile.jsx
+++ /dev/null
@@ -1,52 +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 .
-*/
-
-const React = require("react");
-
-module.exports = function FakeProfile({ avatar, header, display_name, username, role }) {
- return ( // Keep in sync with web/template/profile.tmpl
-
- );
-};
\ No newline at end of file
diff --git a/web/source/settings/components/fake-profile.tsx b/web/source/settings/components/fake-profile.tsx
new file mode 100644
index 000000000..4a5157378
--- /dev/null
+++ b/web/source/settings/components/fake-profile.tsx
@@ -0,0 +1,52 @@
+/*
+ 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";
+
+export default function FakeProfile({ avatar, header, display_name, username, role }) {
+ return ( // Keep in sync with web/template/profile.tmpl
+
+ );
+}
diff --git a/web/source/settings/components/fake-toot.jsx b/web/source/settings/components/fake-toot.jsx
deleted file mode 100644
index 08f806008..000000000
--- a/web/source/settings/components/fake-toot.jsx
+++ /dev/null
@@ -1,57 +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 .
-*/
-
-const React = require("react");
-
-const query = require("../lib/query");
-
-module.exports = function FakeToot({ children }) {
- const { data: account = {
- avatar: "/assets/default_avatars/GoToSocial_icon1.png",
- display_name: "",
- username: ""
- } } = query.useVerifyCredentialsQuery();
-
- return (
-
-
-
-
-
-
-
-
- );
-};
\ No newline at end of file
diff --git a/web/source/settings/components/fake-toot.tsx b/web/source/settings/components/fake-toot.tsx
new file mode 100644
index 000000000..ad0c387a4
--- /dev/null
+++ b/web/source/settings/components/fake-toot.tsx
@@ -0,0 +1,56 @@
+/*
+ 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 { useVerifyCredentialsQuery } from "../lib/query/oauth";
+
+export default function FakeToot({ children }) {
+ const { data: account = {
+ avatar: "/assets/default_avatars/GoToSocial_icon1.png",
+ display_name: "",
+ username: ""
+ } } = useVerifyCredentialsQuery();
+
+ return (
+
+
+
+
+
+
+
+
+ );
+}
diff --git a/web/source/settings/components/languages.jsx b/web/source/settings/components/languages.jsx
deleted file mode 100644
index 61c76e03a..000000000
--- a/web/source/settings/components/languages.jsx
+++ /dev/null
@@ -1,34 +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 .
-*/
-
-const React = require("react");
-const langs = require("langs");
-
-const asElements = langs.all().map((l) => {
- let code = l["1"].toUpperCase();
- let name = l.name;
- if (l.name != l.local) {
- name = `${name} - ${l.local}`;
- }
- return ;
-});
-
-module.exports = function Languages() {
- return asElements;
-};
\ No newline at end of file
diff --git a/web/source/settings/components/languages.tsx b/web/source/settings/components/languages.tsx
new file mode 100644
index 000000000..7c2986438
--- /dev/null
+++ b/web/source/settings/components/languages.tsx
@@ -0,0 +1,34 @@
+/*
+ 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 { all } from "langs";
+
+const asElements = all().map((l) => {
+ let code = l["1"].toUpperCase();
+ let name = l.name;
+ if (l.name != l.local) {
+ name = `${name} - ${l.local}`;
+ }
+ return ;
+});
+
+export default function Languages() {
+ return asElements;
+}
\ No newline at end of file
diff --git a/web/source/settings/components/loading.jsx b/web/source/settings/components/loading.jsx
deleted file mode 100644
index c62c72a0a..000000000
--- a/web/source/settings/components/loading.jsx
+++ /dev/null
@@ -1,26 +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 .
-*/
-
-const React = require("react");
-
-module.exports = function Loading() {
- return (
-
- );
-};
\ No newline at end of file
diff --git a/web/source/settings/components/loading.tsx b/web/source/settings/components/loading.tsx
new file mode 100644
index 000000000..f7635534f
--- /dev/null
+++ b/web/source/settings/components/loading.tsx
@@ -0,0 +1,26 @@
+/*
+ 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";
+
+export default function Loading() {
+ return (
+
+ );
+}
diff --git a/web/source/settings/components/user-logout-card.jsx b/web/source/settings/components/user-logout-card.jsx
deleted file mode 100644
index 9d88642a5..000000000
--- a/web/source/settings/components/user-logout-card.jsx
+++ /dev/null
@@ -1,47 +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 .
-*/
-
-const React = require("react");
-const Loading = require("./loading");
-const {
- useVerifyCredentialsQuery,
- useLogoutMutation,
-} = require("../lib/query/oauth");
-const { useInstanceV1Query } = require("../lib/query");
-
-module.exports = function UserLogoutCard() {
- const { data: profile, isLoading } = useVerifyCredentialsQuery();
- const { data: instance } = useInstanceV1Query();
- const [logoutQuery] = useLogoutMutation();
-
- if (isLoading) {
- return ;
- } else {
- return (
-
- );
- }
-};
\ No newline at end of file
diff --git a/web/source/settings/components/user-logout-card.tsx b/web/source/settings/components/user-logout-card.tsx
new file mode 100644
index 000000000..f8eeaf63c
--- /dev/null
+++ b/web/source/settings/components/user-logout-card.tsx
@@ -0,0 +1,44 @@
+/*
+ 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 Loading from "./loading";
+import { useVerifyCredentialsQuery, useLogoutMutation } from "../lib/query/oauth";
+import { useInstanceV1Query } from "../lib/query/gts-api";
+
+export default function UserLogoutCard() {
+ const { data: profile, isLoading } = useVerifyCredentialsQuery();
+ const { data: instance } = useInstanceV1Query();
+ const [logoutQuery] = useLogoutMutation();
+
+ if (isLoading) {
+ return ;
+ } else {
+ return (
+
+ );
+ }
+}
\ No newline at end of file
diff --git a/web/source/settings/index.tsx b/web/source/settings/index.tsx
index d0af8524d..977a94150 100644
--- a/web/source/settings/index.tsx
+++ b/web/source/settings/index.tsx
@@ -17,7 +17,7 @@
along with this program. If not, see .
*/
-import React, { StrictMode } from "react";
+import React, { StrictMode, useMemo } from "react";
import "./style.css";
import { createRoot } from "react-dom/client";
@@ -29,18 +29,21 @@ import Loading from "./components/loading";
import { Account } from "./lib/types/account";
import { BaseUrlContext, RoleContext } from "./lib/navigation/util";
import { SidebarMenu } from "./lib/navigation/menu";
-import { UserMenu, UserRouter } from "./views/user/routes";
-import { ModerationMenu, ModerationRouter } from "./views/moderation/routes";
-import { AdminMenu, AdminRouter } from "./views/admin/routes";
import { Redirect, Route, Router } from "wouter";
+import AdminMenu from "./views/admin/menu";
+import ModerationMenu from "./views/moderation/menu";
+import UserMenu from "./views/user/menu";
+import UserRouter from "./views/user/router";
+import { ErrorBoundary } from "./lib/navigation/error";
+import ModerationRouter from "./views/moderation/router";
+import AdminRouter from "./views/admin/router";
interface AppProps {
account: Account;
}
export function App({ account }: AppProps) {
- const roles: string[] = [ account.role.name ];
-
+ const roles: string[] = useMemo(() => [ account.role.name ], [account]);
return (
@@ -51,15 +54,17 @@ export function App({ account }: AppProps) {
-
-
-
- {/*
- Redirect to first part of UserRouter if
- just the bare settings page is open, so
- user isn't greeted with a blank page.
- */}
-
+
+
+
+
+ {/*
+ Redirect to first part of UserRouter if
+ just the bare settings page is open, so
+ user isn't greeted with a blank page.
+ */}
+
+
diff --git a/web/source/settings/lib/query/index.js b/web/source/settings/lib/query/index.js
deleted file mode 100644
index aeaa4a1d7..000000000
--- a/web/source/settings/lib/query/index.js
+++ /dev/null
@@ -1,25 +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 .
-*/
-
-module.exports = {
- ...require("./gts-api"),
- ...require("./oauth"),
- ...require("./user"),
- ...require("./admin")
-};
diff --git a/web/source/settings/style.css b/web/source/settings/style.css
index 57f8bf4cf..5af9dbc67 100644
--- a/web/source/settings/style.css
+++ b/web/source/settings/style.css
@@ -601,29 +601,31 @@ span.form-info {
@media screen and (max-width: 60rem) {
/* vertical layout */
#root {
- padding: 1rem;
+ padding: 0.5rem;
+ margin: 0;
grid-template-columns: 100%;
grid-template-rows: auto auto;
- .sidebar {
+ div.sidebar {
justify-self: auto;
- margin-bottom: 2rem;
+ margin-bottom: 0;
}
- .sidebar, section.with-sidebar {
+ div.sidebar, section.with-sidebar {
border-top-left-radius: $br;
border-top-right-radius: $br;
border-bottom-left-radius: $br;
border-bottom-right-radius: $br;
}
- .sidebar a:first-child h2 {
- border-top-right-radius: $br;
+ section.with-sidebar {
+ grid-column: 1;
+ padding: 1rem;
}
- }
- section {
- grid-column: 1;
+ div.sidebar a:first-child h2 {
+ border-top-right-radius: $br;
+ }
}
.user-profile .overview {
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 (
- <>
-
- );
-}
diff --git a/web/source/settings/views/moderation/accounts/detail/actions.tsx b/web/source/settings/views/moderation/accounts/detail/actions.tsx
index 74c5371f1..212bb4089 100644
--- a/web/source/settings/views/moderation/accounts/detail/actions.tsx
+++ b/web/source/settings/views/moderation/accounts/detail/actions.tsx
@@ -19,17 +19,14 @@
import React from "react";
-import { useActionAccountMutation } from "../../../../lib/query";
-
+import { useActionAccountMutation } from "../../../../lib/query/admin";
import MutationButton from "../../../../components/form/mutation-button";
-
import useFormSubmit from "../../../../lib/form/submit";
import {
useValue,
useTextInput,
useBoolInput,
} from "../../../../lib/form";
-
import { Checkbox, TextInput } from "../../../../components/form/inputs";
import { AdminAccount } from "../../../../lib/types/account";
diff --git a/web/source/settings/views/moderation/accounts/detail/handlesignup.tsx b/web/source/settings/views/moderation/accounts/detail/handlesignup.tsx
index 5655421ea..59fa8bc65 100644
--- a/web/source/settings/views/moderation/accounts/detail/handlesignup.tsx
+++ b/web/source/settings/views/moderation/accounts/detail/handlesignup.tsx
@@ -19,18 +19,14 @@
import React from "react";
import { useLocation } from "wouter";
-
-import { useHandleSignupMutation } from "../../../../lib/query";
-
+import { useHandleSignupMutation } from "../../../../lib/query/admin";
import MutationButton from "../../../../components/form/mutation-button";
-
import useFormSubmit from "../../../../lib/form/submit";
import {
useValue,
useTextInput,
useBoolInput,
} from "../../../../lib/form";
-
import { Checkbox, Select, TextInput } from "../../../../components/form/inputs";
import { AdminAccount } from "../../../../lib/types/account";
diff --git a/web/source/settings/views/moderation/accounts/detail/index.tsx b/web/source/settings/views/moderation/accounts/detail/index.tsx
index f507391d3..f34bc7481 100644
--- a/web/source/settings/views/moderation/accounts/detail/index.tsx
+++ b/web/source/settings/views/moderation/accounts/detail/index.tsx
@@ -19,12 +19,9 @@
import React from "react";
-import { useGetAccountQuery } from "../../../../lib/query";
-
+import { useGetAccountQuery } from "../../../../lib/query/admin";
import FormWithData from "../../../../lib/form/form-with-data";
-
import FakeProfile from "../../../../components/fake-profile";
-
import { AdminAccount } from "../../../../lib/types/account";
import { HandleSignup } from "./handlesignup";
import { AccountActions } from "./actions";
diff --git a/web/source/settings/views/moderation/accounts/pending/index.tsx b/web/source/settings/views/moderation/accounts/pending/index.tsx
index 96b7796e5..d5a32f09b 100644
--- a/web/source/settings/views/moderation/accounts/pending/index.tsx
+++ b/web/source/settings/views/moderation/accounts/pending/index.tsx
@@ -18,7 +18,7 @@
*/
import React from "react";
-import { useSearchAccountsQuery } from "../../../../lib/query";
+import { useSearchAccountsQuery } from "../../../../lib/query/admin";
import { AccountList } from "../../../../components/account-list";
export default function AccountsPending() {
diff --git a/web/source/settings/views/moderation/accounts/search/index.tsx b/web/source/settings/views/moderation/accounts/search/index.tsx
index 7d5515a43..8ee579e16 100644
--- a/web/source/settings/views/moderation/accounts/search/index.tsx
+++ b/web/source/settings/views/moderation/accounts/search/index.tsx
@@ -19,9 +19,8 @@
import React from "react";
-import { useLazySearchAccountsQuery } from "../../../../lib/query";
+import { useLazySearchAccountsQuery } from "../../../../lib/query/admin";
import { useTextInput } from "../../../../lib/form";
-
import { AccountList } from "../../../../components/account-list";
import { SearchAccountParams } from "../../../../lib/types/account";
import { Select, TextInput } from "../../../../components/form/inputs";
diff --git a/web/source/settings/views/moderation/domain-permissions/form.tsx b/web/source/settings/views/moderation/domain-permissions/form.tsx
index ba0808873..ea7fdbc23 100644
--- a/web/source/settings/views/moderation/domain-permissions/form.tsx
+++ b/web/source/settings/views/moderation/domain-permissions/form.tsx
@@ -20,18 +20,14 @@
import React from "react";
import { useEffect } from "react";
-
import { useExportDomainListMutation } from "../../../lib/query/admin/domain-permissions/export";
import useFormSubmit from "../../../lib/form/submit";
-
import {
RadioGroup,
TextArea,
Select,
} from "../../../components/form/inputs";
-
import MutationButton from "../../../components/form/mutation-button";
-
import { Error } from "../../../components/error";
import ExportFormatTable from "./export-format-table";
diff --git a/web/source/settings/views/moderation/domain-permissions/overview.tsx b/web/source/settings/views/moderation/domain-permissions/overview.tsx
index d2bb77087..fca8e348e 100644
--- a/web/source/settings/views/moderation/domain-permissions/overview.tsx
+++ b/web/source/settings/views/moderation/domain-permissions/overview.tsx
@@ -22,11 +22,8 @@ import React from "react";
import { useMemo } from "react";
import { Link, useLocation, useParams } from "wouter";
import { matchSorter } from "match-sorter";
-
import { useTextInput } from "../../../lib/form";
-
import { TextInput } from "../../../components/form/inputs";
-
import Loading from "../../../components/loading";
import { useDomainAllowsQuery, useDomainBlocksQuery } from "../../../lib/query/admin/domain-permissions/get";
import type { MappedDomainPerms, PermType } from "../../../lib/types/domain-permission";
diff --git a/web/source/settings/views/moderation/domain-permissions/process.tsx b/web/source/settings/views/moderation/domain-permissions/process.tsx
index 6c7cb218e..d54d7399c 100644
--- a/web/source/settings/views/moderation/domain-permissions/process.tsx
+++ b/web/source/settings/views/moderation/domain-permissions/process.tsx
@@ -18,9 +18,7 @@
*/
import React from "react";
-
import { memo, useMemo, useCallback, useEffect } from "react";
-
import { isValidDomainPermission, hasBetterScope } from "../../../lib/util/domain-permission";
import {
diff --git a/web/source/settings/views/moderation/menu.tsx b/web/source/settings/views/moderation/menu.tsx
new file mode 100644
index 000000000..4f01e0798
--- /dev/null
+++ b/web/source/settings/views/moderation/menu.tsx
@@ -0,0 +1,121 @@
+/*
+ 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/moderation/reports/overview
+ * - /settings/moderation/reports/:reportId
+ * - /settings/moderation/accounts/overview
+ * - /settings/moderation/accounts/pending
+ * - /settings/moderation/accounts/:accountID
+ * - /settings/moderation/domain-permissions/:permType
+ * - /settings/moderation/domain-permissions/:permType/:domain
+ * - /settings/moderation/domain-permissions/import-export
+ * - /settings/moderation/domain-permissions/process
+ */
+export default function ModerationMenu() {
+ const permissions = ["moderator"];
+ const moderator = useHasPermission(permissions);
+ if (!moderator) {
+ return null;
+ }
+
+ return (
+
+
+
+
+
+ );
+}
+
+/*
+ INTERNAL COMPONENTS
+*/
+
+function ModerationReportsMenu() {
+ return (
+
+ );
+}
+
+function ModerationAccountsMenu() {
+ return (
+
+
+
+
+ );
+}
+
+function ModerationDomainPermsMenu() {
+ return (
+
+
+
+
+
+ );
+}
diff --git a/web/source/settings/views/moderation/reports/detail.tsx b/web/source/settings/views/moderation/reports/detail.tsx
index 9bb2de6b2..bc356edce 100644
--- a/web/source/settings/views/moderation/reports/detail.tsx
+++ b/web/source/settings/views/moderation/reports/detail.tsx
@@ -52,7 +52,15 @@ function ReportDetailForm({ data: report }) {
return (
- reported
+
+ <> reported >
+
{report.action_taken &&
diff --git a/web/source/settings/views/moderation/reports/overview.tsx b/web/source/settings/views/moderation/reports/overview.tsx
index ca8fc185c..03ce1a382 100644
--- a/web/source/settings/views/moderation/reports/overview.tsx
+++ b/web/source/settings/views/moderation/reports/overview.tsx
@@ -19,9 +19,7 @@
import React from "react";
import { Link } from "wouter";
-
import FormWithData from "../../../lib/form/form-with-data";
-
import Username from "./username";
import { useListReportsQuery } from "../../../lib/query/admin/reports";
@@ -77,7 +75,7 @@ function ReportEntry({ report }) {
- reported
+ reported
{report.action_taken ? "Resolved" : "Open"}
diff --git a/web/source/settings/views/moderation/reports/username.tsx b/web/source/settings/views/moderation/reports/username.tsx
index 6fba0b804..294d97e8b 100644
--- a/web/source/settings/views/moderation/reports/username.tsx
+++ b/web/source/settings/views/moderation/reports/username.tsx
@@ -19,8 +19,14 @@
import React from "react";
import { Link } from "wouter";
+import { AdminAccount } from "../../../lib/types/account";
-export default function Username({ user, link = true }) {
+interface UsernameProps {
+ user: AdminAccount;
+ link?: string;
+}
+
+export default function Username({ user, link }: UsernameProps) {
let className = "user";
let isLocal = user.domain == null;
@@ -36,19 +42,25 @@ export default function Username({ user, link = true }) {
? { fa: "fa-home", info: "Local user" }
: { fa: "fa-external-link-square", info: "Remote user" };
- let Element: any = "div";
- let href: any = null;
-
- if (link) {
- Element = Link;
- href = `/settings/admin/accounts/${user.id}`;
- }
-
- return (
-
+ const content = (
+ <>
@{user.account.acct}{icon.info}
-
+ >
);
+
+ if (link) {
+ return (
+
+ {content}
+
+ );
+ } else {
+ return (
+
+ {content}
+
+ );
+ }
}
diff --git a/web/source/settings/views/moderation/router.tsx b/web/source/settings/views/moderation/router.tsx
new file mode 100644
index 000000000..37344462b
--- /dev/null
+++ b/web/source/settings/views/moderation/router.tsx
@@ -0,0 +1,149 @@
+/*
+ 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 { ReportOverview } from "./reports/overview";
+import ReportDetail from "./reports/detail";
+import { ErrorBoundary } from "../../lib/navigation/error";
+import ImportExport from "./domain-permissions/import-export";
+import DomainPermissionsOverview from "./domain-permissions/overview";
+import DomainPermDetail from "./domain-permissions/detail";
+import AccountsOverview from "./accounts";
+import AccountsPending from "./accounts/pending";
+import AccountDetail from "./accounts/detail";
+
+/*
+ EXPORTED COMPONENTS
+*/
+
+/**
+ * - /settings/moderation/reports/overview
+ * - /settings/moderation/reports/:reportId
+ * - /settings/moderation/accounts/overview
+ * - /settings/moderation/accounts/pending
+ * - /settings/moderation/accounts/:accountID
+ * - /settings/moderation/domain-permissions/:permType
+ * - /settings/moderation/domain-permissions/:permType/:domain
+ * - /settings/moderation/domain-permissions/import-export
+ * - /settings/moderation/domain-permissions/process
+ */
+export default function ModerationRouter() {
+ const parentUrl = useBaseUrl();
+ const thisBase = "/moderation";
+ const absBase = parentUrl + thisBase;
+
+ const permissions = ["moderator"];
+ const moderator = useHasPermission(permissions);
+ if (!moderator) {
+ return null;
+ }
+
+ return (
+
+
+
+
+
+
+
+ );
+}
+
+/*
+ INTERNAL COMPONENTS
+*/
+
+/**
+ * - /settings/moderation/reports/overview
+ * - /settings/moderation/reports/:reportId
+ */
+function ModerationReportsRouter() {
+ const parentUrl = useBaseUrl();
+ const thisBase = "/reports";
+ const absBase = parentUrl + thisBase;
+
+ return (
+
+
+
+
+
+
+
+
+
+
+ );
+}
+
+/**
+ * - /settings/moderation/accounts/overview
+ * - /settings/moderation/accounts/pending
+ * - /settings/moderation/accounts/:accountID
+ */
+function ModerationAccountsRouter() {
+ const parentUrl = useBaseUrl();
+ const thisBase = "/accounts";
+ const absBase = parentUrl + thisBase;
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+}
+
+/**
+ * - /settings/moderation/domain-permissions/:permType
+ * - /settings/moderation/domain-permissions/:permType/:domain
+ * - /settings/moderation/domain-permissions/import-export
+ * - /settings/moderation/domain-permissions/process
+ */
+function ModerationDomainPermsRouter() {
+ const parentUrl = useBaseUrl();
+ const thisBase = "/domain-permissions";
+ const absBase = parentUrl + thisBase;
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+}
diff --git a/web/source/settings/views/moderation/routes.tsx b/web/source/settings/views/moderation/routes.tsx
deleted file mode 100644
index 238abaff6..000000000
--- a/web/source/settings/views/moderation/routes.tsx
+++ /dev/null
@@ -1,201 +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 { Redirect, Route, Router, Switch } from "wouter";
-import AccountsOverview from "./accounts";
-import AccountsPending from "./accounts/pending";
-import AccountDetail from "./accounts/detail";
-import { ReportOverview } from "./reports/overview";
-import DomainPermissionsOverview from "./domain-permissions/overview";
-import DomainPermDetail from "./domain-permissions/detail";
-import ImportExport from "./domain-permissions/import-export";
-import ReportDetail from "./reports/detail";
-
-/*
- EXPORTED COMPONENTS
-*/
-
-/**
- * Moderation menu. Reports, accounts,
- * domain permissions import + export.
- */
-export function ModerationMenu() {
- return (
-
-
-
-
-
- );
-}
-
-/**
- * Moderation router. Reports, accounts,
- * domain permissions import + export.
- */
-export function ModerationRouter() {
- const parentUrl = useBaseUrl();
- const thisBase = "/moderation";
- const absBase = parentUrl + thisBase;
-
- return (
-
-
-
-
-
-
-
- );
-}
-
-/*
- INTERNAL COMPONENTS
-*/
-
-/*
- MENUS
-*/
-
-function ModerationReportsMenu() {
- return (
-
- );
-}
-
-function ModerationAccountsMenu() {
- return (
-
-
-
-
- );
-}
-
-function ModerationDomainPermsMenu() {
- return (
-
-
-
-
-
- );
-}
-
-/*
- ROUTERS
-*/
-
-function ModerationReportsRouter() {
- const parentUrl = useBaseUrl();
- const thisBase = "/reports";
- const absBase = parentUrl + thisBase;
-
- return (
-
-
-
-
-
-
-
-
- );
-}
-
-function ModerationAccountsRouter() {
- const parentUrl = useBaseUrl();
- const thisBase = "/accounts";
- const absBase = parentUrl + thisBase;
-
- return (
-
-
-
-
-
-
-
-
-
-
- );
-}
-
-function ModerationDomainPermsRouter() {
- const parentUrl = useBaseUrl();
- const thisBase = "/domain-permissions";
- const absBase = parentUrl + thisBase;
-
- return (
-
-
-
-
-
-
-
-
-
-
-
- );
-}
diff --git a/web/source/settings/views/user/menu.tsx b/web/source/settings/views/user/menu.tsx
new file mode 100644
index 000000000..578bd8ae0
--- /dev/null
+++ b/web/source/settings/views/user/menu.tsx
@@ -0,0 +1,52 @@
+/*
+ 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";
+
+/**
+ * - /settings/user/profile
+ * - /settings/user/settings
+ * - /settings/user/migration
+ */
+export default function UserMenu() {
+ return (
+
+
+
+
+
+ );
+}
diff --git a/web/source/settings/views/user/profile.tsx b/web/source/settings/views/user/profile.tsx
index 08cd74bda..c1735259e 100644
--- a/web/source/settings/views/user/profile.tsx
+++ b/web/source/settings/views/user/profile.tsx
@@ -42,9 +42,10 @@ import FormWithData from "../../lib/form/form-with-data";
import FakeProfile from "../../components/fake-profile";
import MutationButton from "../../components/form/mutation-button";
-import { useAccountThemesQuery, useInstanceV1Query } from "../../lib/query";
+import { useAccountThemesQuery } from "../../lib/query/user";
import { useUpdateCredentialsMutation } from "../../lib/query/user";
import { useVerifyCredentialsQuery } from "../../lib/query/oauth";
+import { useInstanceV1Query } from "../../lib/query/gts-api";
export default function UserProfile() {
return (
diff --git a/web/source/settings/views/user/router.tsx b/web/source/settings/views/user/router.tsx
new file mode 100644
index 000000000..e763c0c2b
--- /dev/null
+++ b/web/source/settings/views/user/router.tsx
@@ -0,0 +1,52 @@
+/*
+ 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 } from "../../lib/navigation/util";
+import { Redirect, Route, Router, Switch } from "wouter";
+import { ErrorBoundary } from "../../lib/navigation/error";
+import UserProfile from "./profile";
+import UserMigration from "./migration";
+import UserSettings from "./settings";
+
+/**
+ * - /settings/user/profile
+ * - /settings/user/settings
+ * - /settings/user/migration
+ */
+export default function UserRouter() {
+ const baseUrl = useBaseUrl();
+ const thisBase = "/user";
+ const absBase = baseUrl + thisBase;
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+}
diff --git a/web/source/settings/views/user/routes.tsx b/web/source/settings/views/user/routes.tsx
deleted file mode 100644
index 76ac50bc2..000000000
--- a/web/source/settings/views/user/routes.tsx
+++ /dev/null
@@ -1,80 +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 UserProfile from "./profile";
-import UserSettings from "./settings";
-import UserMigration from "./migration";
-import { Redirect, Route, Router, Switch } from "wouter";
-
-/**
- *
- * Basic user menu. Profile + accounts
- * settings, post settings, migration.
- */
-export function UserMenu() {
- return (
-
- {/* Profile */}
-
- {/* Settings */}
-
- {/* Migration */}
-
-
- );
-}
-
-export function UserRouter() {
- const baseUrl = useBaseUrl();
- const thisBase = "/user";
- const absBase = baseUrl + thisBase;
-
- return (
-
-
-
-
-
-
- {/* Fallback component */}
-
-
-
-
- );
-}
diff --git a/web/source/settings/views/user/settings.tsx b/web/source/settings/views/user/settings.tsx
index 2827cc53f..cbd973706 100644
--- a/web/source/settings/views/user/settings.tsx
+++ b/web/source/settings/views/user/settings.tsx
@@ -18,18 +18,19 @@
*/
import React from "react";
-import query from "../../lib/query";
import { useTextInput, useBoolInput } from "../../lib/form";
import useFormSubmit from "../../lib/form/submit";
import { Select, TextInput, Checkbox } from "../../components/form/inputs";
import FormWithData from "../../lib/form/form-with-data";
import Languages from "../../components/languages";
import MutationButton from "../../components/form/mutation-button";
+import { useVerifyCredentialsQuery } from "../../lib/query/oauth";
+import { usePasswordChangeMutation, useUpdateCredentialsMutation } from "../../lib/query/user";
export default function UserSettings() {
return (
);
@@ -50,7 +51,7 @@ function UserSettingsForm({ data }) {
statusContentType: useTextInput("source[status_content_type]", { source: data, defaultValue: "text/plain" }),
};
- const [submitForm, result] = useFormSubmit(form, query.useUpdateCredentialsMutation());
+ const [submitForm, result] = useFormSubmit(form, useUpdateCredentialsMutation());
return (
<>
@@ -123,7 +124,7 @@ function PasswordChange() {
}
});
- const [submitForm, result] = useFormSubmit(form, query.usePasswordChangeMutation());
+ const [submitForm, result] = useFormSubmit(form, usePasswordChangeMutation());
return (