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")} -
-