@acmekit/dashboard 2.13.7 → 2.13.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-key-management-create-VWUERPPB.mjs +170 -0
- package/dist/api-key-management-detail-V4ENQHYY.mjs +306 -0
- package/dist/api-key-management-edit-R44OHS7B.mjs +106 -0
- package/dist/api-key-management-list-K2XPKF5E.mjs +400 -0
- package/dist/app.js +16765 -1370
- package/dist/app.mjs +786 -1030
- package/dist/chunk-22YYMH6M.mjs +382 -0
- package/dist/chunk-2U3RK3JG.mjs +474 -0
- package/dist/chunk-535OVBXR.mjs +226 -0
- package/dist/chunk-774WSTCC.mjs +19 -0
- package/dist/chunk-C76H5USB.mjs +16 -0
- package/dist/chunk-DFFLVEZ5.mjs +40 -0
- package/dist/chunk-DN3MIYQH.mjs +140 -0
- package/dist/chunk-DQCEH3X2.mjs +28 -0
- package/dist/chunk-DTY37DDZ.mjs +20 -0
- package/dist/chunk-EFRMWHRX.mjs +84 -0
- package/dist/chunk-FXYH54JP.mjs +16 -0
- package/dist/chunk-G22WWLPG.mjs +44 -0
- package/dist/chunk-G2VJOHHV.mjs +32 -0
- package/dist/chunk-GBFVWROS.mjs +58 -0
- package/dist/chunk-ITNQKZQQ.mjs +142 -0
- package/dist/chunk-IUCDCPJU.mjs +0 -0
- package/dist/chunk-LKWTBYYC.mjs +35 -0
- package/dist/{chunk-4VYJHIB3.mjs → chunk-ND3ODI36.mjs} +0 -72
- package/dist/chunk-OAHCJFG3.mjs +17 -0
- package/dist/chunk-RPAL6FHW.mjs +73 -0
- package/dist/{chunk-JSJZMTQG.mjs → chunk-RREPQMYC.mjs} +14 -41
- package/dist/chunk-S3REQHPQ.mjs +86 -0
- package/dist/chunk-S4DMV3ZT.mjs +35 -0
- package/dist/chunk-ST2YB7JN.mjs +74 -0
- package/dist/chunk-TCNCAWYD.mjs +9 -0
- package/dist/chunk-ULSPL3DR.mjs +126 -0
- package/dist/chunk-WILMJYUB.mjs +35 -0
- package/dist/chunk-XIM7X4FB.mjs +83 -0
- package/dist/chunk-YLPAZ2DP.mjs +1837 -0
- package/dist/chunk-YRWSG3YM.mjs +80 -0
- package/dist/{invite-S5USGDOZ.mjs → invite-XGPZZBUP.mjs} +15 -7
- package/dist/{login-AIMR26AL.mjs → login-GNP3QIPI.mjs} +25 -12
- package/dist/profile-detail-YX27F7N6.mjs +96 -0
- package/dist/profile-edit-2VRDU75O.mjs +173 -0
- package/dist/{reset-password-UQPRHMB3.mjs → reset-password-TWRNZO6Z.mjs} +7 -3
- package/dist/settings-3XWLL5LG.mjs +545 -0
- package/dist/translation-list-CCEQJNED.mjs +581 -0
- package/dist/translations-edit-E57GVUFV.mjs +5376 -0
- package/dist/user-detail-KUSRRVNX.mjs +169 -0
- package/dist/user-edit-HTN3ZGCL.mjs +114 -0
- package/dist/user-invite-E3FAAU3V.mjs +361 -0
- package/dist/user-list-KNJ5S3IM.mjs +1116 -0
- package/dist/user-metadata-5GQK75DT.mjs +425 -0
- package/dist/workflow-execution-detail-LZXCRVNC.mjs +819 -0
- package/dist/workflow-execution-list-HQ3V6TML.mjs +175 -0
- package/package.json +9 -9
- package/src/components/layout/settings-layout/settings-layout.tsx +8 -2
- package/src/dashboard-app/routes/get-route.map.tsx +1 -14
- package/src/hooks/api/api-keys.tsx +0 -49
- package/src/hooks/api/index.ts +0 -1
- package/src/providers/keybind-provider/hooks.tsx +0 -145
- package/src/routes/translations/translation-list/translation-list.tsx +10 -21
- package/src/routes/translations/translations-edit/translations-edit.tsx +14 -11
- package/src/vite-env.d.ts +3 -1
- package/dist/chunk-FBTP4AJM.mjs +0 -221
- package/dist/chunk-QYOO4QR6.mjs +0 -73
- package/src/components/data-table/helpers/sales-channels/index.ts +0 -4
- package/src/components/data-table/helpers/sales-channels/use-sales-channel-table-columns.tsx +0 -61
- package/src/components/data-table/helpers/sales-channels/use-sales-channel-table-empty-state.tsx +0 -22
- package/src/components/data-table/helpers/sales-channels/use-sales-channel-table-filters.tsx +0 -33
- package/src/components/data-table/helpers/sales-channels/use-sales-channel-table-query.tsx +0 -30
- package/src/routes/api-key-management/api-key-management-detail/components/api-key-sales-channel-section/api-key-sales-channel-section.tsx +0 -206
- package/src/routes/api-key-management/api-key-management-detail/components/api-key-sales-channel-section/index.ts +0 -1
- package/src/routes/store/common/hooks/use-currencies-table-columns.tsx +0 -29
- package/src/routes/store/common/hooks/use-currencies-table-query.tsx +0 -21
- package/src/routes/store/common/hooks/use-locales-table-columns.tsx +0 -29
- package/src/routes/store/common/hooks/use-locales-table-query.tsx +0 -21
- package/src/routes/store/store-detail/components/store-general-section/index.ts +0 -1
- package/src/routes/store/store-detail/components/store-general-section/store-general-section.tsx +0 -48
- package/src/routes/store/store-detail/index.ts +0 -2
- package/src/routes/store/store-detail/loader.ts +0 -18
- package/src/routes/store/store-detail/store-detail.tsx +0 -42
- package/src/routes/store/store-edit/components/edit-store-form/edit-store-form.tsx +0 -83
- package/src/routes/store/store-edit/index.ts +0 -1
- package/src/routes/store/store-edit/store-edit.tsx +0 -25
- package/src/routes/store/store-metadata/index.ts +0 -1
- package/src/routes/store/store-metadata/store-metadata.tsx +0 -24
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getApiKeyTypeFromPathname
|
|
3
|
+
} from "./chunk-G22WWLPG.mjs";
|
|
4
|
+
import {
|
|
5
|
+
useCreateApiKey
|
|
6
|
+
} from "./chunk-EFRMWHRX.mjs";
|
|
7
|
+
import "./chunk-IUCDCPJU.mjs";
|
|
8
|
+
import {
|
|
9
|
+
KeyboundForm,
|
|
10
|
+
RouteFocusModal,
|
|
11
|
+
useRouteModal
|
|
12
|
+
} from "./chunk-2U3RK3JG.mjs";
|
|
13
|
+
import {
|
|
14
|
+
Form
|
|
15
|
+
} from "./chunk-ND3ODI36.mjs";
|
|
16
|
+
import "./chunk-FXYH54JP.mjs";
|
|
17
|
+
import "./chunk-774WSTCC.mjs";
|
|
18
|
+
import "./chunk-DTY37DDZ.mjs";
|
|
19
|
+
import "./chunk-QZ7TP4HQ.mjs";
|
|
20
|
+
|
|
21
|
+
// src/routes/api-key-management/api-key-management-create/api-key-management-create.tsx
|
|
22
|
+
import { useLocation } from "react-router-dom";
|
|
23
|
+
|
|
24
|
+
// src/routes/api-key-management/api-key-management-create/components/api-key-create-form/api-key-create-form.tsx
|
|
25
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
26
|
+
import { Button, Heading, Input, Prompt, Text, toast } from "@acmekit/ui";
|
|
27
|
+
import { useForm } from "react-hook-form";
|
|
28
|
+
import { useTranslation } from "react-i18next";
|
|
29
|
+
import * as zod from "zod";
|
|
30
|
+
import { Eye, EyeSlash } from "@acmekit/icons";
|
|
31
|
+
import { Fragment, useState } from "react";
|
|
32
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
33
|
+
var ApiKeyCreateSchema = zod.object({
|
|
34
|
+
title: zod.string().min(1)
|
|
35
|
+
});
|
|
36
|
+
function getRedactedKey(key) {
|
|
37
|
+
if (!key) {
|
|
38
|
+
return "";
|
|
39
|
+
}
|
|
40
|
+
const firstThree = key.slice(0, 4);
|
|
41
|
+
const lastTwo = key.slice(-2);
|
|
42
|
+
return `${firstThree}${"\u2022".repeat(key.length - 6)}${lastTwo}`;
|
|
43
|
+
}
|
|
44
|
+
var ApiKeyCreateForm = ({ keyType }) => {
|
|
45
|
+
const [createdKey, setCreatedKey] = useState(null);
|
|
46
|
+
const [showRedactedKey, setShowRedactedKey] = useState(true);
|
|
47
|
+
const { t } = useTranslation();
|
|
48
|
+
const { handleSuccess } = useRouteModal();
|
|
49
|
+
const form = useForm({
|
|
50
|
+
defaultValues: {
|
|
51
|
+
title: ""
|
|
52
|
+
},
|
|
53
|
+
resolver: zodResolver(ApiKeyCreateSchema)
|
|
54
|
+
});
|
|
55
|
+
const { mutateAsync, isPending } = useCreateApiKey();
|
|
56
|
+
const handleSubmit = form.handleSubmit(async (values) => {
|
|
57
|
+
await mutateAsync(
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
{ title: values.title, type: keyType },
|
|
60
|
+
{
|
|
61
|
+
onSuccess: ({ api_key }) => {
|
|
62
|
+
toast.success(t("apiKeyManagement.create.successToast"));
|
|
63
|
+
switch (keyType) {
|
|
64
|
+
case "publishable" /* PUBLISHABLE */:
|
|
65
|
+
handleSuccess(`/settings/publishable-api-keys/${api_key.id}`);
|
|
66
|
+
break;
|
|
67
|
+
case "secret" /* SECRET */:
|
|
68
|
+
setCreatedKey(api_key);
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
onError: (err) => {
|
|
73
|
+
toast.error(err.message);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
const handleCopyToken = () => {
|
|
79
|
+
if (!createdKey) {
|
|
80
|
+
toast.error(t("apiKeyManagement.create.copySecretTokenFailure"));
|
|
81
|
+
}
|
|
82
|
+
navigator.clipboard.writeText(createdKey?.token ?? "");
|
|
83
|
+
toast.success(t("apiKeyManagement.create.copySecretTokenSuccess"));
|
|
84
|
+
};
|
|
85
|
+
const handleGoToSecretKey = () => {
|
|
86
|
+
if (!createdKey) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
handleSuccess(`/settings/secret-api-keys/${createdKey.id}`);
|
|
90
|
+
};
|
|
91
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
92
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
93
|
+
KeyboundForm,
|
|
94
|
+
{
|
|
95
|
+
className: "flex h-full flex-col overflow-hidden",
|
|
96
|
+
onSubmit: handleSubmit,
|
|
97
|
+
children: [
|
|
98
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
|
|
99
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-8 px-2 py-16", children: [
|
|
100
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
101
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: keyType === "publishable" /* PUBLISHABLE */ ? t("apiKeyManagement.create.createPublishableHeader") : t("apiKeyManagement.create.createSecretHeader") }) }),
|
|
102
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: keyType === "publishable" /* PUBLISHABLE */ ? t("apiKeyManagement.create.createPublishableHint") : t("apiKeyManagement.create.createSecretHint") }) })
|
|
103
|
+
] }),
|
|
104
|
+
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-4", children: /* @__PURE__ */ jsx(
|
|
105
|
+
Form.Field,
|
|
106
|
+
{
|
|
107
|
+
control: form.control,
|
|
108
|
+
name: "title",
|
|
109
|
+
render: ({ field }) => {
|
|
110
|
+
return /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
111
|
+
/* @__PURE__ */ jsx(Form.Label, { children: t("fields.title") }),
|
|
112
|
+
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
113
|
+
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
114
|
+
] });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
) })
|
|
118
|
+
] }) }) }),
|
|
119
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
120
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: t("actions.cancel") }) }),
|
|
121
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: t("actions.save") })
|
|
122
|
+
] }) })
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
) }),
|
|
126
|
+
/* @__PURE__ */ jsx(Prompt, { variant: "confirmation", open: !!createdKey, children: /* @__PURE__ */ jsxs(Prompt.Content, { className: "w-fit max-w-[42.5%]", children: [
|
|
127
|
+
/* @__PURE__ */ jsxs(Prompt.Header, { children: [
|
|
128
|
+
/* @__PURE__ */ jsx(Prompt.Title, { children: t("apiKeyManagement.create.secretKeyCreatedHeader") }),
|
|
129
|
+
/* @__PURE__ */ jsx(Prompt.Description, { children: t("apiKeyManagement.create.secretKeyCreatedHint") })
|
|
130
|
+
] }),
|
|
131
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-3 px-6 py-4", children: [
|
|
132
|
+
/* @__PURE__ */ jsxs("div", { className: "shadow-borders-base bg-ui-bg-component grid h-8 grid-cols-[1fr_32px] items-center overflow-hidden rounded-md", children: [
|
|
133
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center px-2", children: /* @__PURE__ */ jsx(Text, { family: "mono", size: "small", children: showRedactedKey ? getRedactedKey(createdKey?.token) : createdKey?.token }) }),
|
|
134
|
+
/* @__PURE__ */ jsx(
|
|
135
|
+
"button",
|
|
136
|
+
{
|
|
137
|
+
className: "transition-fg hover:bg-ui-bg-base-hover active:bg-ui-bg-base-pressed text-ui-fg-muted active:text-ui-fg-subtle flex size-8 appearance-none items-center justify-center border-l",
|
|
138
|
+
type: "button",
|
|
139
|
+
onClick: () => setShowRedactedKey(!showRedactedKey),
|
|
140
|
+
children: showRedactedKey ? /* @__PURE__ */ jsx(EyeSlash, {}) : /* @__PURE__ */ jsx(Eye, {})
|
|
141
|
+
}
|
|
142
|
+
)
|
|
143
|
+
] }),
|
|
144
|
+
/* @__PURE__ */ jsx(
|
|
145
|
+
Button,
|
|
146
|
+
{
|
|
147
|
+
size: "small",
|
|
148
|
+
variant: "secondary",
|
|
149
|
+
type: "button",
|
|
150
|
+
className: "w-full",
|
|
151
|
+
onClick: handleCopyToken,
|
|
152
|
+
children: t("apiKeyManagement.actions.copy")
|
|
153
|
+
}
|
|
154
|
+
)
|
|
155
|
+
] }),
|
|
156
|
+
/* @__PURE__ */ jsx(Prompt.Footer, { className: "border-t py-4", children: /* @__PURE__ */ jsx(Prompt.Action, { onClick: handleGoToSecretKey, children: t("actions.continue") }) })
|
|
157
|
+
] }) })
|
|
158
|
+
] });
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
// src/routes/api-key-management/api-key-management-create/api-key-management-create.tsx
|
|
162
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
163
|
+
var ApiKeyManagementCreate = () => {
|
|
164
|
+
const { pathname } = useLocation();
|
|
165
|
+
const keyType = getApiKeyTypeFromPathname(pathname);
|
|
166
|
+
return /* @__PURE__ */ jsx2(RouteFocusModal, { children: /* @__PURE__ */ jsx2(ApiKeyCreateForm, { keyType }) });
|
|
167
|
+
};
|
|
168
|
+
export {
|
|
169
|
+
ApiKeyManagementCreate as Component
|
|
170
|
+
};
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getApiKeyStatusProps,
|
|
3
|
+
getApiKeyTypeProps,
|
|
4
|
+
prettifyRedactedToken
|
|
5
|
+
} from "./chunk-G22WWLPG.mjs";
|
|
6
|
+
import {
|
|
7
|
+
useDate
|
|
8
|
+
} from "./chunk-DFFLVEZ5.mjs";
|
|
9
|
+
import "./chunk-535OVBXR.mjs";
|
|
10
|
+
import {
|
|
11
|
+
SingleColumnPage
|
|
12
|
+
} from "./chunk-22YYMH6M.mjs";
|
|
13
|
+
import {
|
|
14
|
+
useExtension
|
|
15
|
+
} from "./chunk-C5P5PL3E.mjs";
|
|
16
|
+
import {
|
|
17
|
+
ActionMenu
|
|
18
|
+
} from "./chunk-S3REQHPQ.mjs";
|
|
19
|
+
import "./chunk-ST2YB7JN.mjs";
|
|
20
|
+
import "./chunk-GBFVWROS.mjs";
|
|
21
|
+
import {
|
|
22
|
+
apiKeysQueryKeys,
|
|
23
|
+
useApiKey,
|
|
24
|
+
useDeleteApiKey,
|
|
25
|
+
useRevokeApiKey
|
|
26
|
+
} from "./chunk-EFRMWHRX.mjs";
|
|
27
|
+
import "./chunk-LKWTBYYC.mjs";
|
|
28
|
+
import "./chunk-ULSPL3DR.mjs";
|
|
29
|
+
import "./chunk-DN3MIYQH.mjs";
|
|
30
|
+
import "./chunk-XIM7X4FB.mjs";
|
|
31
|
+
import {
|
|
32
|
+
SingleColumnPageSkeleton,
|
|
33
|
+
Skeleton
|
|
34
|
+
} from "./chunk-ITNQKZQQ.mjs";
|
|
35
|
+
import "./chunk-OAHCJFG3.mjs";
|
|
36
|
+
import "./chunk-S4DMV3ZT.mjs";
|
|
37
|
+
import {
|
|
38
|
+
useUser
|
|
39
|
+
} from "./chunk-YRWSG3YM.mjs";
|
|
40
|
+
import {
|
|
41
|
+
queryClient
|
|
42
|
+
} from "./chunk-FXYH54JP.mjs";
|
|
43
|
+
import "./chunk-774WSTCC.mjs";
|
|
44
|
+
import {
|
|
45
|
+
sdk
|
|
46
|
+
} from "./chunk-DTY37DDZ.mjs";
|
|
47
|
+
import "./chunk-QZ7TP4HQ.mjs";
|
|
48
|
+
|
|
49
|
+
// src/routes/api-key-management/api-key-management-detail/api-key-management-detail.tsx
|
|
50
|
+
import { useLoaderData, useParams } from "react-router-dom";
|
|
51
|
+
|
|
52
|
+
// src/routes/api-key-management/api-key-management-detail/components/api-key-general-section/api-key-general-section.tsx
|
|
53
|
+
import { PencilSquare, Trash, XCircle } from "@acmekit/icons";
|
|
54
|
+
import {
|
|
55
|
+
Badge,
|
|
56
|
+
Container,
|
|
57
|
+
Copy,
|
|
58
|
+
Heading,
|
|
59
|
+
StatusBadge,
|
|
60
|
+
Text as Text2,
|
|
61
|
+
toast,
|
|
62
|
+
usePrompt
|
|
63
|
+
} from "@acmekit/ui";
|
|
64
|
+
import { useTranslation } from "react-i18next";
|
|
65
|
+
import { useNavigate } from "react-router-dom";
|
|
66
|
+
|
|
67
|
+
// src/components/common/user-link/user-link.tsx
|
|
68
|
+
import { Avatar, Text } from "@acmekit/ui";
|
|
69
|
+
import { Link } from "react-router-dom";
|
|
70
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
71
|
+
var UserLink = ({
|
|
72
|
+
id,
|
|
73
|
+
first_name,
|
|
74
|
+
last_name,
|
|
75
|
+
email,
|
|
76
|
+
type = "user"
|
|
77
|
+
}) => {
|
|
78
|
+
const name = [first_name, last_name].filter(Boolean).join(" ");
|
|
79
|
+
const fallback = name ? name.slice(0, 1) : email.slice(0, 1);
|
|
80
|
+
const link = type === "user" ? `/settings/users/${id}` : `/customers/${id}`;
|
|
81
|
+
return /* @__PURE__ */ jsxs(
|
|
82
|
+
Link,
|
|
83
|
+
{
|
|
84
|
+
to: link,
|
|
85
|
+
className: "flex items-center gap-x-2 w-fit transition-fg hover:text-ui-fg-subtle outline-none focus-visible:shadow-borders-focus rounded-md",
|
|
86
|
+
children: [
|
|
87
|
+
/* @__PURE__ */ jsx(Avatar, { size: "2xsmall", fallback: fallback.toUpperCase() }),
|
|
88
|
+
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", weight: "regular", children: name || email })
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// src/routes/api-key-management/api-key-management-detail/components/api-key-general-section/api-key-general-section.tsx
|
|
95
|
+
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
96
|
+
var ApiKeyGeneralSection = ({ apiKey }) => {
|
|
97
|
+
const { t } = useTranslation();
|
|
98
|
+
const navigate = useNavigate();
|
|
99
|
+
const prompt = usePrompt();
|
|
100
|
+
const { getFullDate } = useDate();
|
|
101
|
+
const { mutateAsync: revokeAsync } = useRevokeApiKey(apiKey.id);
|
|
102
|
+
const { mutateAsync: deleteAsync } = useDeleteApiKey(apiKey.id);
|
|
103
|
+
const handleDelete = async () => {
|
|
104
|
+
const res = await prompt({
|
|
105
|
+
title: t("general.areYouSure"),
|
|
106
|
+
description: t("apiKeyManagement.delete.warning", {
|
|
107
|
+
title: apiKey.title
|
|
108
|
+
}),
|
|
109
|
+
confirmText: t("actions.delete"),
|
|
110
|
+
cancelText: t("actions.cancel")
|
|
111
|
+
});
|
|
112
|
+
if (!res) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
await deleteAsync(void 0, {
|
|
116
|
+
onSuccess: () => {
|
|
117
|
+
toast.success(
|
|
118
|
+
t("apiKeyManagement.delete.successToast", {
|
|
119
|
+
title: apiKey.title
|
|
120
|
+
})
|
|
121
|
+
);
|
|
122
|
+
navigate("..", { replace: true });
|
|
123
|
+
},
|
|
124
|
+
onError: (err) => {
|
|
125
|
+
toast.error(err.message);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
const handleRevoke = async () => {
|
|
130
|
+
const res = await prompt({
|
|
131
|
+
title: t("general.areYouSure"),
|
|
132
|
+
description: t("apiKeyManagement.revoke.warning", {
|
|
133
|
+
title: apiKey.title
|
|
134
|
+
}),
|
|
135
|
+
confirmText: t("apiKeyManagement.actions.revoke"),
|
|
136
|
+
cancelText: t("actions.cancel")
|
|
137
|
+
});
|
|
138
|
+
if (!res) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
await revokeAsync(void 0, {
|
|
142
|
+
onSuccess: () => {
|
|
143
|
+
toast.success(
|
|
144
|
+
t("apiKeyManagement.revoke.successToast", {
|
|
145
|
+
title: apiKey.title
|
|
146
|
+
})
|
|
147
|
+
);
|
|
148
|
+
},
|
|
149
|
+
onError: (err) => {
|
|
150
|
+
toast.error(err.message);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
const dangerousActions = [
|
|
155
|
+
{
|
|
156
|
+
icon: /* @__PURE__ */ jsx2(Trash, {}),
|
|
157
|
+
label: t("actions.delete"),
|
|
158
|
+
onClick: handleDelete,
|
|
159
|
+
disabled: !apiKey.revoked_at
|
|
160
|
+
}
|
|
161
|
+
];
|
|
162
|
+
if (!apiKey.revoked_at) {
|
|
163
|
+
dangerousActions.unshift({
|
|
164
|
+
icon: /* @__PURE__ */ jsx2(XCircle, {}),
|
|
165
|
+
label: t("apiKeyManagement.actions.revoke"),
|
|
166
|
+
onClick: handleRevoke,
|
|
167
|
+
disabled: !!apiKey.revoked_at
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
const apiKeyStatus = getApiKeyStatusProps(apiKey.revoked_at, t);
|
|
171
|
+
const apiKeyType = getApiKeyTypeProps(apiKey.type, t);
|
|
172
|
+
return /* @__PURE__ */ jsxs2(Container, { className: "divide-y p-0", children: [
|
|
173
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-between px-6 py-4", children: [
|
|
174
|
+
/* @__PURE__ */ jsx2(Heading, { children: apiKey.title }),
|
|
175
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-x-4", children: [
|
|
176
|
+
/* @__PURE__ */ jsx2("div", { className: "flex items-center gap-x-2", children: /* @__PURE__ */ jsx2(StatusBadge, { color: apiKeyStatus.color, children: apiKeyStatus.label }) }),
|
|
177
|
+
/* @__PURE__ */ jsx2(
|
|
178
|
+
ActionMenu,
|
|
179
|
+
{
|
|
180
|
+
groups: [
|
|
181
|
+
{
|
|
182
|
+
actions: [
|
|
183
|
+
{
|
|
184
|
+
label: t("actions.edit"),
|
|
185
|
+
icon: /* @__PURE__ */ jsx2(PencilSquare, {}),
|
|
186
|
+
to: "edit"
|
|
187
|
+
}
|
|
188
|
+
]
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
actions: dangerousActions
|
|
192
|
+
}
|
|
193
|
+
]
|
|
194
|
+
}
|
|
195
|
+
)
|
|
196
|
+
] })
|
|
197
|
+
] }),
|
|
198
|
+
/* @__PURE__ */ jsxs2("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4", children: [
|
|
199
|
+
/* @__PURE__ */ jsx2(Text2, { size: "small", leading: "compact", weight: "plus", children: t("fields.key") }),
|
|
200
|
+
apiKey.type === "secret" ? /* @__PURE__ */ jsx2(Badge, { size: "2xsmall", className: "inline-block w-fit", children: prettifyRedactedToken(apiKey.redacted) }) : /* @__PURE__ */ jsx2(Copy, { asChild: true, content: apiKey.token, className: "cursor-pointer", children: /* @__PURE__ */ jsx2(Badge, { size: "2xsmall", className: "text-ui-tag-neutral-text", children: prettifyRedactedToken(apiKey.redacted) }) })
|
|
201
|
+
] }),
|
|
202
|
+
/* @__PURE__ */ jsxs2("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4", children: [
|
|
203
|
+
/* @__PURE__ */ jsx2(Text2, { size: "small", leading: "compact", weight: "plus", children: t("fields.type") }),
|
|
204
|
+
/* @__PURE__ */ jsx2(Text2, { size: "small", leading: "compact", children: apiKeyType.label })
|
|
205
|
+
] }),
|
|
206
|
+
/* @__PURE__ */ jsxs2("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4", children: [
|
|
207
|
+
/* @__PURE__ */ jsx2(Text2, { size: "small", leading: "compact", weight: "plus", children: t("apiKeyManagement.fields.lastUsedAtLabel") }),
|
|
208
|
+
/* @__PURE__ */ jsx2(Text2, { size: "small", leading: "compact", children: apiKey.last_used_at ? getFullDate({ date: apiKey.last_used_at, includeTime: true }) : "-" })
|
|
209
|
+
] }),
|
|
210
|
+
/* @__PURE__ */ jsxs2("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4", children: [
|
|
211
|
+
/* @__PURE__ */ jsx2(Text2, { size: "small", leading: "compact", weight: "plus", children: t("apiKeyManagement.fields.createdByLabel") }),
|
|
212
|
+
/* @__PURE__ */ jsx2(ActionBy, { userId: apiKey.created_by })
|
|
213
|
+
] }),
|
|
214
|
+
apiKey.revoked_at && /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
215
|
+
/* @__PURE__ */ jsxs2("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4", children: [
|
|
216
|
+
/* @__PURE__ */ jsx2(Text2, { size: "small", leading: "compact", weight: "plus", children: t("apiKeyManagement.fields.revokedAtLabel") }),
|
|
217
|
+
/* @__PURE__ */ jsx2(Text2, { size: "small", leading: "compact", children: getFullDate({ date: apiKey.revoked_at, includeTime: true }) })
|
|
218
|
+
] }),
|
|
219
|
+
/* @__PURE__ */ jsxs2("div", { className: "text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4", children: [
|
|
220
|
+
/* @__PURE__ */ jsx2(Text2, { size: "small", leading: "compact", weight: "plus", children: t("apiKeyManagement.fields.revokedByLabel") }),
|
|
221
|
+
/* @__PURE__ */ jsx2(ActionBy, { userId: apiKey.revoked_by })
|
|
222
|
+
] })
|
|
223
|
+
] })
|
|
224
|
+
] });
|
|
225
|
+
};
|
|
226
|
+
var ActionBy = ({ userId }) => {
|
|
227
|
+
const { user, isLoading, isError, error } = useUser(userId, void 0, {
|
|
228
|
+
enabled: !!userId
|
|
229
|
+
});
|
|
230
|
+
if (!userId) {
|
|
231
|
+
return /* @__PURE__ */ jsx2(Text2, { size: "small", className: "text-ui-fg-subtle", children: "-" });
|
|
232
|
+
}
|
|
233
|
+
if (isError) {
|
|
234
|
+
throw error;
|
|
235
|
+
}
|
|
236
|
+
if (isLoading) {
|
|
237
|
+
return /* @__PURE__ */ jsxs2("div", { className: "grid grid-cols-[20px_1fr]", children: [
|
|
238
|
+
/* @__PURE__ */ jsx2(Skeleton, { className: "h-5 w-5 rounded-full" }),
|
|
239
|
+
/* @__PURE__ */ jsx2(Skeleton, { className: "w-full max-w-[220px]" })
|
|
240
|
+
] });
|
|
241
|
+
}
|
|
242
|
+
if (!user) {
|
|
243
|
+
return /* @__PURE__ */ jsx2(Text2, { size: "small", className: "text-ui-fg-subtle", children: "-" });
|
|
244
|
+
}
|
|
245
|
+
return /* @__PURE__ */ jsx2(UserLink, { ...user });
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
// src/routes/api-key-management/api-key-management-detail/api-key-management-detail.tsx
|
|
249
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
250
|
+
var ApiKeyManagementDetail = () => {
|
|
251
|
+
const initialData = useLoaderData();
|
|
252
|
+
const { id } = useParams();
|
|
253
|
+
const { getWidgets } = useExtension();
|
|
254
|
+
const { api_key, isLoading, isError, error } = useApiKey(id, {
|
|
255
|
+
initialData
|
|
256
|
+
});
|
|
257
|
+
if (isLoading || !api_key) {
|
|
258
|
+
return /* @__PURE__ */ jsx3(SingleColumnPageSkeleton, { showJSON: true, sections: 1 });
|
|
259
|
+
}
|
|
260
|
+
if (isError) {
|
|
261
|
+
throw error;
|
|
262
|
+
}
|
|
263
|
+
return /* @__PURE__ */ jsx3(
|
|
264
|
+
SingleColumnPage,
|
|
265
|
+
{
|
|
266
|
+
hasOutlet: true,
|
|
267
|
+
showJSON: true,
|
|
268
|
+
widgets: {
|
|
269
|
+
before: getWidgets("api_key.details.before"),
|
|
270
|
+
after: getWidgets("api_key.details.after")
|
|
271
|
+
},
|
|
272
|
+
data: api_key,
|
|
273
|
+
children: /* @__PURE__ */ jsx3(ApiKeyGeneralSection, { apiKey: api_key })
|
|
274
|
+
}
|
|
275
|
+
);
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
// src/routes/api-key-management/api-key-management-detail/breadcrumb.tsx
|
|
279
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
280
|
+
var ApiKeyManagementDetailBreadcrumb = (props) => {
|
|
281
|
+
const { id } = props.params || {};
|
|
282
|
+
const { api_key } = useApiKey(id, {
|
|
283
|
+
initialData: props.data,
|
|
284
|
+
enabled: Boolean(id)
|
|
285
|
+
});
|
|
286
|
+
if (!api_key) {
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
return /* @__PURE__ */ jsx4("span", { children: api_key.title });
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
// src/routes/api-key-management/api-key-management-detail/loader.ts
|
|
293
|
+
var apiKeyDetailQuery = (id) => ({
|
|
294
|
+
queryKey: apiKeysQueryKeys.detail(id),
|
|
295
|
+
queryFn: async () => sdk.admin.apiKey.retrieve(id)
|
|
296
|
+
});
|
|
297
|
+
var apiKeyLoader = async ({ params }) => {
|
|
298
|
+
const id = params.id;
|
|
299
|
+
const query = apiKeyDetailQuery(id);
|
|
300
|
+
return queryClient.ensureQueryData(query);
|
|
301
|
+
};
|
|
302
|
+
export {
|
|
303
|
+
ApiKeyManagementDetailBreadcrumb as Breadcrumb,
|
|
304
|
+
ApiKeyManagementDetail as Component,
|
|
305
|
+
apiKeyLoader as loader
|
|
306
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useApiKey,
|
|
3
|
+
useUpdateApiKey
|
|
4
|
+
} from "./chunk-EFRMWHRX.mjs";
|
|
5
|
+
import "./chunk-IUCDCPJU.mjs";
|
|
6
|
+
import {
|
|
7
|
+
KeyboundForm,
|
|
8
|
+
RouteDrawer,
|
|
9
|
+
useRouteModal
|
|
10
|
+
} from "./chunk-2U3RK3JG.mjs";
|
|
11
|
+
import {
|
|
12
|
+
Form
|
|
13
|
+
} from "./chunk-ND3ODI36.mjs";
|
|
14
|
+
import "./chunk-FXYH54JP.mjs";
|
|
15
|
+
import "./chunk-774WSTCC.mjs";
|
|
16
|
+
import "./chunk-DTY37DDZ.mjs";
|
|
17
|
+
import "./chunk-QZ7TP4HQ.mjs";
|
|
18
|
+
|
|
19
|
+
// src/routes/api-key-management/api-key-management-edit/api-key-management-edit.tsx
|
|
20
|
+
import { Heading } from "@acmekit/ui";
|
|
21
|
+
import { useTranslation as useTranslation2 } from "react-i18next";
|
|
22
|
+
import { useParams } from "react-router-dom";
|
|
23
|
+
|
|
24
|
+
// src/components/utilities/visually-hidden/visually-hidden.tsx
|
|
25
|
+
import { jsx } from "react/jsx-runtime";
|
|
26
|
+
var VisuallyHidden = ({ children }) => {
|
|
27
|
+
return /* @__PURE__ */ jsx("span", { className: "sr-only", children });
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// src/routes/api-key-management/api-key-management-edit/components/edit-api-key-form/edit-api-key-form.tsx
|
|
31
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
32
|
+
import { Button, Input, toast } from "@acmekit/ui";
|
|
33
|
+
import { useForm } from "react-hook-form";
|
|
34
|
+
import { useTranslation } from "react-i18next";
|
|
35
|
+
import * as zod from "zod";
|
|
36
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
37
|
+
var EditApiKeySchema = zod.object({
|
|
38
|
+
title: zod.string().min(1)
|
|
39
|
+
});
|
|
40
|
+
var EditApiKeyForm = ({ apiKey }) => {
|
|
41
|
+
const { t } = useTranslation();
|
|
42
|
+
const { handleSuccess } = useRouteModal();
|
|
43
|
+
const form = useForm({
|
|
44
|
+
defaultValues: {
|
|
45
|
+
title: apiKey.title
|
|
46
|
+
},
|
|
47
|
+
resolver: zodResolver(EditApiKeySchema)
|
|
48
|
+
});
|
|
49
|
+
const { mutateAsync, isPending } = useUpdateApiKey(apiKey.id);
|
|
50
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
51
|
+
await mutateAsync(data, {
|
|
52
|
+
onSuccess: ({ api_key }) => {
|
|
53
|
+
toast.success(
|
|
54
|
+
t("apiKeyManagement.edit.successToast", {
|
|
55
|
+
title: api_key.title
|
|
56
|
+
})
|
|
57
|
+
);
|
|
58
|
+
handleSuccess();
|
|
59
|
+
},
|
|
60
|
+
onError: (err) => {
|
|
61
|
+
toast.error(err.message);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
return /* @__PURE__ */ jsx2(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { onSubmit: handleSubmit, className: "flex flex-1 flex-col", children: [
|
|
66
|
+
/* @__PURE__ */ jsx2(RouteDrawer.Body, { children: /* @__PURE__ */ jsx2("div", { className: "flex flex-col gap-y-4", children: /* @__PURE__ */ jsx2(
|
|
67
|
+
Form.Field,
|
|
68
|
+
{
|
|
69
|
+
control: form.control,
|
|
70
|
+
name: "title",
|
|
71
|
+
render: ({ field }) => {
|
|
72
|
+
return /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
73
|
+
/* @__PURE__ */ jsx2(Form.Label, { children: t("fields.title") }),
|
|
74
|
+
/* @__PURE__ */ jsx2(Form.Control, { children: /* @__PURE__ */ jsx2(Input, { ...field }) }),
|
|
75
|
+
/* @__PURE__ */ jsx2(Form.ErrorMessage, {})
|
|
76
|
+
] });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
) }) }),
|
|
80
|
+
/* @__PURE__ */ jsx2(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2", children: [
|
|
81
|
+
/* @__PURE__ */ jsx2(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx2(Button, { size: "small", variant: "secondary", children: t("actions.cancel") }) }),
|
|
82
|
+
/* @__PURE__ */ jsx2(Button, { size: "small", type: "submit", isLoading: isPending, children: t("actions.save") })
|
|
83
|
+
] }) })
|
|
84
|
+
] }) });
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// src/routes/api-key-management/api-key-management-edit/api-key-management-edit.tsx
|
|
88
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
89
|
+
var ApiKeyManagementEdit = () => {
|
|
90
|
+
const { id } = useParams();
|
|
91
|
+
const { t } = useTranslation2();
|
|
92
|
+
const { api_key, isLoading, isError, error } = useApiKey(id);
|
|
93
|
+
if (isError) {
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
return /* @__PURE__ */ jsxs2(RouteDrawer, { children: [
|
|
97
|
+
/* @__PURE__ */ jsxs2(RouteDrawer.Header, { children: [
|
|
98
|
+
/* @__PURE__ */ jsx3(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx3(Heading, { children: t("apiKeyManagement.edit.header") }) }),
|
|
99
|
+
/* @__PURE__ */ jsx3(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx3(VisuallyHidden, { children: t("apiKeyManagement.edit.description") }) })
|
|
100
|
+
] }),
|
|
101
|
+
!isLoading && !!api_key && /* @__PURE__ */ jsx3(EditApiKeyForm, { apiKey: api_key })
|
|
102
|
+
] });
|
|
103
|
+
};
|
|
104
|
+
export {
|
|
105
|
+
ApiKeyManagementEdit as Component
|
|
106
|
+
};
|