From 7a1e6394831fb07e303c5ed0900dfe1ea4820de5 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Wed, 24 Apr 2024 12:12:47 +0200 Subject: [chore] Refactor settings panel routing (and other fixes) (#2864) --- web/source/index.js | 2 +- web/source/package.json | 8 +- .../settings/admin/accounts/detail/actions.tsx | 89 ----- .../admin/accounts/detail/handlesignup.tsx | 118 ------ .../settings/admin/accounts/detail/index.tsx | 179 --------- web/source/settings/admin/accounts/index.tsx | 49 --- .../settings/admin/accounts/pending/index.tsx | 40 -- .../settings/admin/accounts/search/index.tsx | 125 ------- .../settings/admin/actions/keys/expireremote.tsx | 63 ---- web/source/settings/admin/actions/keys/index.tsx | 30 -- .../settings/admin/actions/media/cleanup.tsx | 61 ---- web/source/settings/admin/actions/media/index.tsx | 30 -- .../settings/admin/domain-permissions/detail.tsx | 254 ------------- .../domain-permissions/export-format-table.jsx | 65 ---- .../settings/admin/domain-permissions/form.tsx | 153 -------- .../admin/domain-permissions/import-export.tsx | 90 ----- .../settings/admin/domain-permissions/index.tsx | 49 --- .../settings/admin/domain-permissions/overview.tsx | 198 ---------- .../settings/admin/domain-permissions/process.tsx | 402 --------------------- .../settings/admin/emoji/category-select.jsx | 96 ----- web/source/settings/admin/emoji/local/detail.js | 146 -------- web/source/settings/admin/emoji/local/index.tsx | 35 -- .../settings/admin/emoji/local/new-emoji.tsx | 116 ------ web/source/settings/admin/emoji/local/overview.js | 153 -------- .../settings/admin/emoji/local/use-shortcode.js | 56 --- web/source/settings/admin/emoji/remote/index.tsx | 54 --- .../admin/emoji/remote/parse-from-toot.tsx | 235 ------------ web/source/settings/admin/reports/detail.tsx | 252 ------------- web/source/settings/admin/reports/index.tsx | 103 ------ web/source/settings/admin/reports/username.tsx | 54 --- web/source/settings/admin/settings/index.tsx | 190 ---------- web/source/settings/admin/settings/rules.tsx | 174 --------- web/source/settings/components/account-list.tsx | 6 +- web/source/settings/components/back-button.jsx | 12 +- web/source/settings/index.js | 124 ------- web/source/settings/index.tsx | 84 +++++ web/source/settings/lib/navigation/components.jsx | 201 ----------- web/source/settings/lib/navigation/error.tsx | 98 +++++ web/source/settings/lib/navigation/index.js | 136 ------- web/source/settings/lib/navigation/menu.tsx | 175 +++++++++ web/source/settings/lib/navigation/util.ts | 45 ++- web/source/settings/lib/query/admin/index.ts | 13 +- web/source/settings/lib/types/custom-emoji.ts | 8 + web/source/settings/lib/types/rules.ts | 29 ++ web/source/settings/style.css | 23 +- web/source/settings/user/migration.tsx | 212 ----------- web/source/settings/user/profile.tsx | 279 -------------- web/source/settings/user/settings.tsx | 153 -------- .../views/admin/actions/keys/expireremote.tsx | 60 +++ .../settings/views/admin/actions/keys/index.tsx | 30 ++ .../settings/views/admin/actions/media/cleanup.tsx | 59 +++ .../settings/views/admin/actions/media/index.tsx | 30 ++ .../settings/views/admin/emoji/category-select.tsx | 134 +++++++ .../settings/views/admin/emoji/local/detail.tsx | 142 ++++++++ .../settings/views/admin/emoji/local/new-emoji.tsx | 112 ++++++ .../settings/views/admin/emoji/local/overview.tsx | 173 +++++++++ .../views/admin/emoji/local/use-shortcode.ts | 56 +++ .../settings/views/admin/emoji/remote/index.tsx | 46 +++ .../views/admin/emoji/remote/steal-this-look.tsx | 235 ++++++++++++ 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 | 89 +++++ .../moderation/accounts/detail/handlesignup.tsx | 118 ++++++ .../views/moderation/accounts/detail/index.tsx | 167 +++++++++ .../settings/views/moderation/accounts/index.tsx | 35 ++ .../views/moderation/accounts/pending/index.tsx | 40 ++ .../views/moderation/accounts/search/index.tsx | 131 +++++++ .../views/moderation/domain-permissions/detail.tsx | 262 ++++++++++++++ .../domain-permissions/export-format-table.tsx | 65 ++++ .../views/moderation/domain-permissions/form.tsx | 153 ++++++++ .../domain-permissions/import-export.tsx | 88 +++++ .../moderation/domain-permissions/overview.tsx | 197 ++++++++++ .../moderation/domain-permissions/process.tsx | 400 ++++++++++++++++++++ .../settings/views/moderation/reports/detail.tsx | 243 +++++++++++++ .../settings/views/moderation/reports/overview.tsx | 99 +++++ .../settings/views/moderation/reports/username.tsx | 54 +++ web/source/settings/views/moderation/routes.tsx | 201 +++++++++++ web/source/settings/views/user/migration.tsx | 208 +++++++++++ web/source/settings/views/user/profile.tsx | 279 ++++++++++++++ web/source/settings/views/user/routes.tsx | 80 ++++ web/source/settings/views/user/settings.tsx | 169 +++++++++ web/source/yarn.lock | 78 ++-- 83 files changed, 5176 insertions(+), 4842 deletions(-) delete mode 100644 web/source/settings/admin/accounts/detail/actions.tsx delete mode 100644 web/source/settings/admin/accounts/detail/handlesignup.tsx delete mode 100644 web/source/settings/admin/accounts/detail/index.tsx delete mode 100644 web/source/settings/admin/accounts/index.tsx delete mode 100644 web/source/settings/admin/accounts/pending/index.tsx delete mode 100644 web/source/settings/admin/accounts/search/index.tsx delete mode 100644 web/source/settings/admin/actions/keys/expireremote.tsx delete mode 100644 web/source/settings/admin/actions/keys/index.tsx delete mode 100644 web/source/settings/admin/actions/media/cleanup.tsx delete mode 100644 web/source/settings/admin/actions/media/index.tsx delete mode 100644 web/source/settings/admin/domain-permissions/detail.tsx delete mode 100644 web/source/settings/admin/domain-permissions/export-format-table.jsx delete mode 100644 web/source/settings/admin/domain-permissions/form.tsx delete mode 100644 web/source/settings/admin/domain-permissions/import-export.tsx delete mode 100644 web/source/settings/admin/domain-permissions/index.tsx delete mode 100644 web/source/settings/admin/domain-permissions/overview.tsx delete mode 100644 web/source/settings/admin/domain-permissions/process.tsx delete mode 100644 web/source/settings/admin/emoji/category-select.jsx delete mode 100644 web/source/settings/admin/emoji/local/detail.js delete mode 100644 web/source/settings/admin/emoji/local/index.tsx delete mode 100644 web/source/settings/admin/emoji/local/new-emoji.tsx delete mode 100644 web/source/settings/admin/emoji/local/overview.js delete mode 100644 web/source/settings/admin/emoji/local/use-shortcode.js delete mode 100644 web/source/settings/admin/emoji/remote/index.tsx delete mode 100644 web/source/settings/admin/emoji/remote/parse-from-toot.tsx delete mode 100644 web/source/settings/admin/reports/detail.tsx delete mode 100644 web/source/settings/admin/reports/index.tsx delete mode 100644 web/source/settings/admin/reports/username.tsx delete mode 100644 web/source/settings/admin/settings/index.tsx delete mode 100644 web/source/settings/admin/settings/rules.tsx delete mode 100644 web/source/settings/index.js create mode 100644 web/source/settings/index.tsx delete mode 100644 web/source/settings/lib/navigation/components.jsx create mode 100644 web/source/settings/lib/navigation/error.tsx delete mode 100644 web/source/settings/lib/navigation/index.js create mode 100644 web/source/settings/lib/navigation/menu.tsx create mode 100644 web/source/settings/lib/types/rules.ts delete mode 100644 web/source/settings/user/migration.tsx delete mode 100644 web/source/settings/user/profile.tsx delete mode 100644 web/source/settings/user/settings.tsx create mode 100644 web/source/settings/views/admin/actions/keys/expireremote.tsx create mode 100644 web/source/settings/views/admin/actions/keys/index.tsx create mode 100644 web/source/settings/views/admin/actions/media/cleanup.tsx create mode 100644 web/source/settings/views/admin/actions/media/index.tsx create mode 100644 web/source/settings/views/admin/emoji/category-select.tsx create mode 100644 web/source/settings/views/admin/emoji/local/detail.tsx create mode 100644 web/source/settings/views/admin/emoji/local/new-emoji.tsx create mode 100644 web/source/settings/views/admin/emoji/local/overview.tsx create mode 100644 web/source/settings/views/admin/emoji/local/use-shortcode.ts create mode 100644 web/source/settings/views/admin/emoji/remote/index.tsx create mode 100644 web/source/settings/views/admin/emoji/remote/steal-this-look.tsx create mode 100644 web/source/settings/views/admin/routes.tsx create mode 100644 web/source/settings/views/admin/settings/index.tsx create mode 100644 web/source/settings/views/admin/settings/rules.tsx create mode 100644 web/source/settings/views/moderation/accounts/detail/actions.tsx create mode 100644 web/source/settings/views/moderation/accounts/detail/handlesignup.tsx create mode 100644 web/source/settings/views/moderation/accounts/detail/index.tsx create mode 100644 web/source/settings/views/moderation/accounts/index.tsx create mode 100644 web/source/settings/views/moderation/accounts/pending/index.tsx create mode 100644 web/source/settings/views/moderation/accounts/search/index.tsx create mode 100644 web/source/settings/views/moderation/domain-permissions/detail.tsx create mode 100644 web/source/settings/views/moderation/domain-permissions/export-format-table.tsx create mode 100644 web/source/settings/views/moderation/domain-permissions/form.tsx create mode 100644 web/source/settings/views/moderation/domain-permissions/import-export.tsx create mode 100644 web/source/settings/views/moderation/domain-permissions/overview.tsx create mode 100644 web/source/settings/views/moderation/domain-permissions/process.tsx create mode 100644 web/source/settings/views/moderation/reports/detail.tsx create mode 100644 web/source/settings/views/moderation/reports/overview.tsx create mode 100644 web/source/settings/views/moderation/reports/username.tsx create mode 100644 web/source/settings/views/moderation/routes.tsx create mode 100644 web/source/settings/views/user/migration.tsx create mode 100644 web/source/settings/views/user/profile.tsx create mode 100644 web/source/settings/views/user/routes.tsx create mode 100644 web/source/settings/views/user/settings.tsx (limited to 'web/source') diff --git a/web/source/index.js b/web/source/index.js index dcdb701ee..d9ef70ff9 100644 --- a/web/source/index.js +++ b/web/source/index.js @@ -78,7 +78,7 @@ skulk({ // commonjs here, no need for the typescript preset. ["babelify", { global: true, - ignore: [/node_modules\/(?!nanoid)/], + ignore: [/node_modules\/(?!(nanoid)|(wouter))/], }] ], presets: [ diff --git a/web/source/package.json b/web/source/package.json index 20f525228..d72cf7764 100644 --- a/web/source/package.json +++ b/web/source/package.json @@ -13,7 +13,6 @@ "dependencies": { "@reduxjs/toolkit": "^1.8.6", "ariakit": "^2.0.0-next.41", - "bluebird": "^3.7.2", "get-by-dot": "^1.0.2", "is-valid-domain": "^0.1.6", "js-file-download": "^0.4.12", @@ -33,9 +32,7 @@ "redux": "^4.2.0", "redux-persist": "^6.0.0", "skulk": "^0.0.8-fix", - "split-filter-n": "^1.1.3", - "syncpipe": "^1.0.0", - "wouter": "^2.8.0-alpha.2" + "wouter": "^3.1.0" }, "devDependencies": { "@babel/core": "^7.23.0", @@ -45,14 +42,13 @@ "@browserify/envify": "^6.0.0", "@browserify/uglifyify": "^6.0.0", "@joepie91/eslint-config": "^1.1.1", - "@types/bluebird": "^3.5.39", "@types/is-valid-domain": "^0.0.2", "@types/papaparse": "^5.3.9", "@types/psl": "^1.1.1", "@types/react-dom": "^18.2.8", "@typescript-eslint/eslint-plugin": "^6.7.4", "@typescript-eslint/parser": "^6.7.4", - "autoprefixer": "^10.4.13", + "autoprefixer": "^10.4.19", "babelify": "^10.0.0", "css-extract": "^2.0.0", "eslint": "^8.26.0", diff --git a/web/source/settings/admin/accounts/detail/actions.tsx b/web/source/settings/admin/accounts/detail/actions.tsx deleted file mode 100644 index 75ab8db6e..000000000 --- a/web/source/settings/admin/accounts/detail/actions.tsx +++ /dev/null @@ -1,89 +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 { useActionAccountMutation } from "../../../lib/query"; - -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"; - -export interface AccountActionsProps { - account: AdminAccount, -} - -export function AccountActions({ account }: AccountActionsProps) { - const form = { - id: useValue("id", account.id), - reason: useTextInput("text") - }; - - const reallySuspend = useBoolInput("reallySuspend"); - const [accountAction, result] = useFormSubmit(form, useActionAccountMutation()); - - return ( -
-

Account Moderation Actions

-
- Currently only the "suspend" action is implemented.
- Suspending an account will delete it from your server, and remove all of its media, posts, relationships, etc.
- If the suspended account is local, suspending will also send out a "delete" message to other servers, requesting them to remove its data from their instance as well.
- Account suspension cannot be reversed. -
- -
- {/* - */} - - -
- - ); -} diff --git a/web/source/settings/admin/accounts/detail/handlesignup.tsx b/web/source/settings/admin/accounts/detail/handlesignup.tsx deleted file mode 100644 index a61145a22..000000000 --- a/web/source/settings/admin/accounts/detail/handlesignup.tsx +++ /dev/null @@ -1,118 +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 { useLocation } from "wouter"; - -import { useHandleSignupMutation } from "../../../lib/query"; - -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"; - -export interface HandleSignupProps { - account: AdminAccount, - accountsBaseUrl: string, -} - -export function HandleSignup({account, accountsBaseUrl}: HandleSignupProps) { - const form = { - id: useValue("id", account.id), - approveOrReject: useTextInput("approve_or_reject", { defaultValue: "approve" }), - privateComment: useTextInput("private_comment"), - message: useTextInput("message"), - sendEmail: useBoolInput("send_email"), - }; - - const [_location, setLocation] = useLocation(); - - const [handleSignup, result] = useFormSubmit(form, useHandleSignupMutation(), { - changedOnly: false, - // After submitting the form, redirect back to - // /settings/admin/accounts if rejecting, since - // account will no longer be available at - // /settings/admin/accounts/:accountID endpoint. - onFinish: (res) => { - if (form.approveOrReject.value === "approve") { - // An approve request: - // stay on this page and - // serve updated details. - return; - } - - if (res.data) { - // "reject" successful, - // redirect to accounts page. - setLocation(accountsBaseUrl); - } - } - }); - - return ( -
-

Handle Account Sign-Up

- - { form.approveOrReject.value === "reject" && - // Only show form fields relevant - // to "reject" if rejecting. - // On "approve" these fields will - // be ignored anyway. - <> - - - - } - - - ); -} diff --git a/web/source/settings/admin/accounts/detail/index.tsx b/web/source/settings/admin/accounts/detail/index.tsx deleted file mode 100644 index 79eb493de..000000000 --- a/web/source/settings/admin/accounts/detail/index.tsx +++ /dev/null @@ -1,179 +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 { useRoute, Redirect } from "wouter"; - -import { useGetAccountQuery } from "../../../lib/query"; - -import FormWithData from "../../../lib/form/form-with-data"; - -import { useBaseUrl } from "../../../lib/navigation/util"; -import FakeProfile from "../../../components/fake-profile"; - -import { AdminAccount } from "../../../lib/types/account"; -import { HandleSignup } from "./handlesignup"; -import { AccountActions } from "./actions"; -import BackButton from "../../../components/back-button"; - -export default function AccountDetail() { - // /settings/admin/accounts - const accountsBaseUrl = useBaseUrl(); - - let [_match, params] = useRoute(`${accountsBaseUrl}/:accountId`); - - if (params?.accountId == undefined) { - return ; - } else { - return ( -
-

- Account Details -

- -
- ); - } -} - -interface AccountDetailFormProps { - accountsBaseUrl: string, - data: AdminAccount, -} - -function AccountDetailForm({ data: adminAcct, accountsBaseUrl }: AccountDetailFormProps) { - let yesOrNo = (b: boolean) => { - return b ? "yes" : "no"; - }; - - let created = new Date(adminAcct.created_at).toDateString(); - let lastPosted = "never"; - if (adminAcct.account.last_status_at) { - lastPosted = new Date(adminAcct.account.last_status_at).toDateString(); - } - const local = !adminAcct.domain; - - return ( - <> - -

General Account Details

- { adminAcct.suspended && -
- - Account is suspended. -
- } -
- { !local && -
-
Domain
-
{adminAcct.domain}
-
} -
-
Created
-
-
-
-
Last posted
-
{lastPosted}
-
-
-
Suspended
-
{yesOrNo(adminAcct.suspended)}
-
-
-
Silenced
-
{yesOrNo(adminAcct.silenced)}
-
-
-
Statuses
-
{adminAcct.account.statuses_count}
-
-
-
Followers
-
{adminAcct.account.followers_count}
-
-
-
Following
-
{adminAcct.account.following_count}
-
-
- { local && - // Only show local account details - // if this is a local account! - <> -

Local Account Details

- { !adminAcct.approved && -
- - Account is pending. -
- } - { !adminAcct.confirmed && -
- - Account email not yet confirmed. -
- } -
-
-
Email
-
{adminAcct.email} {{adminAcct.confirmed ? "(confirmed)" : "(not confirmed)"} }
-
-
-
Disabled
-
{yesOrNo(adminAcct.disabled)}
-
-
-
Approved
-
{yesOrNo(adminAcct.approved)}
-
-
-
Sign-Up Reason
-
{adminAcct.invite_request ?? none provided}
-
- { (adminAcct.ip && adminAcct.ip !== "0.0.0.0") && -
-
Sign-Up IP
-
{adminAcct.ip}
-
} - { adminAcct.locale && -
-
Locale
-
{adminAcct.locale}
-
} -
- } - { local && !adminAcct.approved - ? - - : - - } - - ); -} diff --git a/web/source/settings/admin/accounts/index.tsx b/web/source/settings/admin/accounts/index.tsx deleted file mode 100644 index 3c69f7406..000000000 --- a/web/source/settings/admin/accounts/index.tsx +++ /dev/null @@ -1,49 +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 { Switch, Route } from "wouter"; - -import AccountDetail from "./detail"; -import { AccountSearchForm } from "./search"; - -export default function Accounts({ baseUrl }) { - return ( - - - - - - - ); -} - -function AccountOverview({ }) { - return ( -
-

Accounts Overview

- - You can perform actions on an account by clicking - its name in a report, or by searching for the account - using the form below and clicking on its name. - - -
- ); -} diff --git a/web/source/settings/admin/accounts/pending/index.tsx b/web/source/settings/admin/accounts/pending/index.tsx deleted file mode 100644 index 459472147..000000000 --- a/web/source/settings/admin/accounts/pending/index.tsx +++ /dev/null @@ -1,40 +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 { useSearchAccountsQuery } from "../../../lib/query"; -import { AccountList } from "../../../components/account-list"; - -export default function AccountsPending() { - const searchRes = useSearchAccountsQuery({status: "pending"}); - - return ( -
-

Pending Accounts

- -
- ); -} diff --git a/web/source/settings/admin/accounts/search/index.tsx b/web/source/settings/admin/accounts/search/index.tsx deleted file mode 100644 index 560bbb76a..000000000 --- a/web/source/settings/admin/accounts/search/index.tsx +++ /dev/null @@ -1,125 +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 { useLazySearchAccountsQuery } from "../../../lib/query"; -import { useTextInput } from "../../../lib/form"; - -import { AccountList } from "../../../components/account-list"; -import { SearchAccountParams } from "../../../lib/types/account"; -import { Select, TextInput } from "../../../components/form/inputs"; -import MutationButton from "../../../components/form/mutation-button"; - -export function AccountSearchForm() { - const [searchAcct, searchRes] = useLazySearchAccountsQuery(); - - const form = { - origin: useTextInput("origin"), - status: useTextInput("status"), - permissions: useTextInput("permissions"), - username: useTextInput("username"), - display_name: useTextInput("display_name"), - by_domain: useTextInput("by_domain"), - email: useTextInput("email"), - ip: useTextInput("ip"), - }; - - function submitSearch(e) { - e.preventDefault(); - - // Parse query parameters. - const entries = Object.entries(form).map(([k, v]) => { - // Take only defined form fields. - if (v.value === undefined || v.value.length === 0) { - return null; - } - return [[k, v.value]]; - }).flatMap(kv => { - // Remove any nulls. - return kv || []; - }); - - const params: SearchAccountParams = Object.fromEntries(entries); - searchAcct(params); - } - - return ( - <> -
- - - - - - - - - - - ); -} diff --git a/web/source/settings/admin/actions/keys/expireremote.tsx b/web/source/settings/admin/actions/keys/expireremote.tsx deleted file mode 100644 index 3b5da2836..000000000 --- a/web/source/settings/admin/actions/keys/expireremote.tsx +++ /dev/null @@ -1,63 +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 { useInstanceKeysExpireMutation } from "../../../lib/query"; - -import { useTextInput } from "../../../lib/form"; -import { TextInput } from "../../../components/form/inputs"; - -import MutationButton from "../../../components/form/mutation-button"; - -export default function ExpireRemote({}) { - const domainField = useTextInput("domain"); - - const [expire, expireResult] = useInstanceKeysExpireMutation(); - - function submitExpire(e) { - e.preventDefault(); - expire(domainField.value); - } - - return ( -
-

Expire remote instance keys

-

- Mark all public keys from the given remote instance as expired.

- This is useful in cases where the remote domain has had to rotate their keys for whatever - reason (security issue, data leak, routine safety procedure, etc), and your instance can no - longer communicate with theirs properly using cached keys. A key marked as expired in this way - will be lazily refetched next time a request is made to your instance signed by the owner of that - key. -

- - - - ); -} diff --git a/web/source/settings/admin/actions/keys/index.tsx b/web/source/settings/admin/actions/keys/index.tsx deleted file mode 100644 index 74bfd36ee..000000000 --- a/web/source/settings/admin/actions/keys/index.tsx +++ /dev/null @@ -1,30 +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 ExpireRemote from "./expireremote"; - -export default function Keys() { - return ( - <> -

Key Actions

- - - ); -} diff --git a/web/source/settings/admin/actions/media/cleanup.tsx b/web/source/settings/admin/actions/media/cleanup.tsx deleted file mode 100644 index fd3ca1f41..000000000 --- a/web/source/settings/admin/actions/media/cleanup.tsx +++ /dev/null @@ -1,61 +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 { useMediaCleanupMutation } from "../../../lib/query"; - -import { useTextInput } from "../../../lib/form"; -import { TextInput } from "../../../components/form/inputs"; - -import MutationButton from "../../../components/form/mutation-button"; - -export default function Cleanup({}) { - const daysField = useTextInput("days", { defaultValue: "30" }); - - const [mediaCleanup, mediaCleanupResult] = useMediaCleanupMutation(); - - function submitCleanup(e) { - e.preventDefault(); - mediaCleanup(daysField.value); - } - - return ( -
-

Cleanup

-

- Clean up remote media older than the specified number of days. - If the remote instance is still online they will be refetched when needed. - Also cleans up unused headers and avatars from the media cache. -

- - - - ); -} diff --git a/web/source/settings/admin/actions/media/index.tsx b/web/source/settings/admin/actions/media/index.tsx deleted file mode 100644 index b3b805986..000000000 --- a/web/source/settings/admin/actions/media/index.tsx +++ /dev/null @@ -1,30 +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 Cleanup from "./cleanup"; - -export default function Media() { - return ( - <> -

Media Actions

- - - ); -} diff --git a/web/source/settings/admin/domain-permissions/detail.tsx b/web/source/settings/admin/domain-permissions/detail.tsx deleted file mode 100644 index f74802666..000000000 --- a/web/source/settings/admin/domain-permissions/detail.tsx +++ /dev/null @@ -1,254 +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 { useMemo } from "react"; -import { useLocation } from "wouter"; - -import { useTextInput, useBoolInput } from "../../lib/form"; - -import useFormSubmit from "../../lib/form/submit"; - -import { TextInput, Checkbox, TextArea } from "../../components/form/inputs"; - -import Loading from "../../components/loading"; -import BackButton from "../../components/back-button"; -import MutationButton from "../../components/form/mutation-button"; - -import { useDomainAllowsQuery, useDomainBlocksQuery } from "../../lib/query/admin/domain-permissions/get"; -import { useAddDomainAllowMutation, useAddDomainBlockMutation, useRemoveDomainAllowMutation, useRemoveDomainBlockMutation } from "../../lib/query/admin/domain-permissions/update"; -import { DomainPerm, PermType } from "../../lib/types/domain-permission"; -import { NoArg } from "../../lib/types/query"; -import { Error } from "../../components/error"; - -export interface DomainPermDetailProps { - baseUrl: string; - permType: PermType; - domain: string; -} - -export default function DomainPermDetail({ baseUrl, permType, domain }: DomainPermDetailProps) { - const { data: domainBlocks = {}, isLoading: isLoadingDomainBlocks } = useDomainBlocksQuery(NoArg, { skip: permType !== "block" }); - const { data: domainAllows = {}, isLoading: isLoadingDomainAllows } = useDomainAllowsQuery(NoArg, { skip: permType !== "allow" }); - - let isLoading; - switch (permType) { - case "block": - isLoading = isLoadingDomainBlocks; - break; - case "allow": - isLoading = isLoadingDomainAllows; - break; - default: - throw "perm type unknown"; - } - - if (domain == "view") { - // Retrieve domain from form field submission. - domain = (new URL(document.location.toString())).searchParams.get("domain")?? "unknown"; - } - - if (domain == "unknown") { - throw "unknown domain"; - } - - // Normalize / decode domain (it may be URL-encoded). - domain = decodeURIComponent(domain); - - // Check if we already have a perm of the desired type for this domain. - const existingPerm: DomainPerm | undefined = useMemo(() => { - if (permType == "block") { - return domainBlocks[domain]; - } else { - return domainAllows[domain]; - } - }, [domainBlocks, domainAllows, domain, permType]); - - let infoContent: React.JSX.Element; - - if (isLoading) { - infoContent = ; - } else if (existingPerm == undefined) { - infoContent = No stored {permType} yet, you can add one below:; - } else { - infoContent = ( -
- - Editing domain permissions isn't implemented yet, check here for progress -
- ); - } - - return ( -
-

Domain {permType} for: {domain}

- {infoContent} - -
- ); -} - -interface DomainPermFormProps { - defaultDomain: string; - perm?: DomainPerm; - permType: PermType; - baseUrl: string; -} - -function DomainPermForm({ defaultDomain, perm, permType, baseUrl }: DomainPermFormProps) { - const isExistingPerm = perm !== undefined; - const disabledForm = isExistingPerm - ? { - disabled: true, - title: "Domain permissions currently cannot be edited." - } - : { - disabled: false, - title: "", - }; - - const form = { - domain: useTextInput("domain", { source: perm, defaultValue: defaultDomain }), - obfuscate: useBoolInput("obfuscate", { source: perm }), - commentPrivate: useTextInput("private_comment", { source: perm }), - commentPublic: useTextInput("public_comment", { source: perm }) - }; - - // Check which perm type we're meant to be handling - // here, and use appropriate mutations and results. - // We can't call these hooks conditionally because - // react is like "weh" (mood), but we can decide - // which ones to use conditionally. - const [ addBlock, addBlockResult ] = useAddDomainBlockMutation(); - const [ removeBlock, removeBlockResult] = useRemoveDomainBlockMutation({ fixedCacheKey: perm?.id }); - const [ addAllow, addAllowResult ] = useAddDomainAllowMutation(); - const [ removeAllow, removeAllowResult ] = useRemoveDomainAllowMutation({ fixedCacheKey: perm?.id }); - - const [ - addTrigger, - addResult, - removeTrigger, - removeResult, - ] = useMemo(() => { - return permType == "block" - ? [ - addBlock, - addBlockResult, - removeBlock, - removeBlockResult, - ] - : [ - addAllow, - addAllowResult, - removeAllow, - removeAllowResult, - ]; - }, [permType, - addBlock, addBlockResult, removeBlock, removeBlockResult, - addAllow, addAllowResult, removeAllow, removeAllowResult, - ]); - - // Use appropriate submission params for this permType. - const [submitForm, submitFormResult] = useFormSubmit(form, [addTrigger, addResult], { changedOnly: false }); - - // Uppercase first letter of given permType. - const permTypeUpper = useMemo(() => { - return permType.charAt(0).toUpperCase() + permType.slice(1); - }, [permType]); - - const [location, setLocation] = useLocation(); - - function verifyUrlThenSubmit(e) { - // Adding a new domain permissions happens on a url like - // "/settings/admin/domain-permissions/:permType/domain.com", - // but if domain input changes, that doesn't match anymore - // and causes issues later on so, before submitting the form, - // silently change url, and THEN submit. - let correctUrl = `${baseUrl}/${form.domain.value}`; - if (location != correctUrl) { - setLocation(correctUrl); - } - return submitForm(e); - } - - return ( -
- - - - -