From c54fcf7aa72c412e6cc39d4cf55c7302178b2183 Mon Sep 17 00:00:00 2001 From: Johnny Date: Sat, 8 Nov 2025 10:32:55 +0800 Subject: [PATCH] refactor(web): redesign Settings components (#5237) Co-authored-by: Claude --- .../Settings/AccessTokenSection.tsx | 128 ++++++------ .../components/Settings/InstanceSection.tsx | 192 +++++++++--------- web/src/components/Settings/MemberSection.tsx | 143 +++++++------ .../Settings/MemoRelatedSettings.tsx | 192 +++++++++--------- .../components/Settings/MyAccountSection.tsx | 68 ++++--- .../Settings/PreferencesSection.tsx | 75 ++++--- web/src/components/Settings/SSOSection.tsx | 95 +++++---- web/src/components/Settings/SettingGroup.tsx | 34 ++++ web/src/components/Settings/SettingRow.tsx | 45 ++++ .../components/Settings/SettingSection.tsx | 35 ++++ web/src/components/Settings/SettingTable.tsx | 69 +++++++ .../components/Settings/StorageSection.tsx | 153 +++++++------- .../Settings/UserSessionsSection.tsx | 178 ++++++++-------- .../components/Settings/WebhookSection.tsx | 102 ++++------ 14 files changed, 829 insertions(+), 680 deletions(-) create mode 100644 web/src/components/Settings/SettingGroup.tsx create mode 100644 web/src/components/Settings/SettingRow.tsx create mode 100644 web/src/components/Settings/SettingSection.tsx create mode 100644 web/src/components/Settings/SettingTable.tsx diff --git a/web/src/components/Settings/AccessTokenSection.tsx b/web/src/components/Settings/AccessTokenSection.tsx index e4cf3f6da..f3191d2a6 100644 --- a/web/src/components/Settings/AccessTokenSection.tsx +++ b/web/src/components/Settings/AccessTokenSection.tsx @@ -1,5 +1,5 @@ import copy from "copy-to-clipboard"; -import { ClipboardIcon, TrashIcon } from "lucide-react"; +import { ClipboardIcon, PlusIcon, TrashIcon } from "lucide-react"; import { useEffect, useState } from "react"; import { toast } from "react-hot-toast"; import ConfirmDialog from "@/components/ConfirmDialog"; @@ -10,6 +10,7 @@ import { useDialog } from "@/hooks/useDialog"; import { UserAccessToken } from "@/types/proto/api/v1/user_service"; import { useTranslate } from "@/utils/i18n"; import CreateAccessTokenDialog from "../CreateAccessTokenDialog"; +import SettingTable from "./SettingTable"; const listAccessTokens = async (parent: string) => { const { accessTokens } = await userServiceClient.listUserAccessTokens({ parent }); @@ -63,79 +64,64 @@ const AccessTokenSection = () => { }; return ( -
-
-
-
-

- {t("setting.access-token-section.title")} -

-

{t("setting.access-token-section.description")}

-
-
- -
-
-
-
-
- - - - - - - - - - - - {userAccessTokens.map((userAccessToken) => ( - - - - - - - - ))} - -
- {t("setting.access-token-section.token")} - - {t("common.description")} - - {t("setting.access-token-section.create-dialog.created-at")} - - {t("setting.access-token-section.create-dialog.expires-at")} - - {t("common.delete")} -
- {getFormatedAccessToken(userAccessToken.accessToken)} - - {userAccessToken.description} - {userAccessToken.issuedAt?.toLocaleString()} - - {userAccessToken.expiresAt?.toLocaleString() ?? t("setting.access-token-section.create-dialog.duration-never")} - - -
-
-
+
+
+
+

{t("setting.access-token-section.title")}

+

{t("setting.access-token-section.description")}

+
+ ( +
+ {getFormatedAccessToken(token.accessToken)} + +
+ ), + }, + { + key: "description", + header: t("common.description"), + render: (_, token: UserAccessToken) => {token.description}, + }, + { + key: "issuedAt", + header: t("setting.access-token-section.create-dialog.created-at"), + render: (_, token: UserAccessToken) => token.issuedAt?.toLocaleString(), + }, + { + key: "expiresAt", + header: t("setting.access-token-section.create-dialog.expires-at"), + render: (_, token: UserAccessToken) => + token.expiresAt?.toLocaleString() ?? t("setting.access-token-section.create-dialog.duration-never"), + }, + { + key: "actions", + header: "", + className: "text-right", + render: (_, token: UserAccessToken) => ( + + ), + }, + ]} + data={userAccessTokens} + emptyMessage="No access tokens found" + getRowKey={(token) => token.name} + /> + {/* Create Access Token Dialog */} { const t = useTranslate(); @@ -67,99 +69,99 @@ const InstanceSection = observer(() => { }; return ( -
-

{t("common.basic")}

-
-
- {t("setting.system-section.server-name")}:{" "} - {instanceGeneralSetting.customProfile?.title || "Memos"} -
- -
- -

{t("setting.system-section.title")}

-
- Theme - updatePartialSetting({ theme: value })} - className="min-w-fit" - /> -
-
- {t("setting.system-section.additional-style")} -
-