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 ( -
- - - {items.map(([key, value]) => ( - - {value} - - ))} - -
- ); -}; \ 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 ( +
+ + + {items.map(([key, value]) => ( + + {value} + + ))} + +
+ ); +} \ 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 ( -
-

- {"An error occured, please report this on the "} - GoToSocial issue tracker - {" or "} - Matrix support room. -
Include the details below: -

-
-
-					{error.name}: {error.message}
-				
-
-					{error.stack}
-				
-
-

- or refresh the page -

-
- ); -} - -function Error({ error }) { - /* eslint-disable-next-line no-console */ - console.error("Rendering error:", error); - let message; - - if (error.data != undefined) { // RTK Query error with data - if (error.status) { - message = (<> - {error.status}: {error.data.error} - {error.data.error_description && -

- {error.data.error_description} -

- } - ); - } else { - message = error.data.error; - } - } else if (error.name != undefined || error.type != undefined) { // JS error - message = (<> - {error.type && error.name}: {error.message} - ); - } else if (error.status && typeof error.error == "string") { - message = (<> - {error.status}: {error.error} - ); - } else { - message = error.message ?? error; - } - - return ( -
- {message} -
- ); -} - -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 ( +
+

+ {"An error occured, please report this on the "} + GoToSocial issue tracker + {" or "} + Matrix support room. +
Include the details below: +

+
+
+					{error.name}: {error.message}
+				
+
+					{error.stack}
+				
+
+

+ or refresh the page +

+
+ ); +} + +function Error({ error }) { + /* eslint-disable-next-line no-console */ + console.error("Rendering error:", error); + let message; + + if (error.data != undefined) { // RTK Query error with data + if (error.status) { + message = (<> + {error.status}: {error.data.error} + {error.data.error_description && +

+ {error.data.error_description} +

+ } + ); + } else { + message = error.data.error; + } + } else if (error.name != undefined || error.type != undefined) { // JS error + message = (<> + {error.type && error.name}: {error.message} + ); + } else if (error.status && typeof error.error == "string") { + message = (<> + {error.status}: {error.error} + ); + } else { + message = error.message ?? error; + } + + return ( +
+ {message} +
+ ); +} + +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 -
-
-
- {header -
- -
-
- ); -}; \ 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 +
+
+
+ {header +
+ +
+
+ ); +} 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 ( -
- -

{profile.display_name?.length > 0 ? profile.display_name : profile.acct}

- @{profile.username}@{instance?.account_domain} - -