@workos-inc/widgets 1.11.0 → 1.12.0-next.1778098442416
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/CHANGELOG.md +6 -6
- package/dist/cjs/api/api-provider.cjs.map +1 -1
- package/dist/cjs/api/api-provider.d.cts +1 -1
- package/dist/cjs/api/endpoint.cjs.map +1 -1
- package/dist/cjs/api/endpoint.d.cts +1 -1
- package/dist/cjs/api-keys.client.cjs +72 -4
- package/dist/cjs/api-keys.client.cjs.map +1 -1
- package/dist/cjs/api-keys.client.d.cts +1 -0
- package/dist/cjs/experimental/api/fetch.cjs.map +1 -1
- package/dist/cjs/experimental/api/fetch.d.cts +1 -1
- package/dist/cjs/experimental/api/react-query.cjs.map +1 -1
- package/dist/cjs/experimental/api/react-query.d.cts +1 -1
- package/dist/cjs/experimental/api/swr.cjs.map +1 -1
- package/dist/cjs/experimental/api/swr.d.cts +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/lib/api/user-api-key.cjs +72 -0
- package/dist/cjs/lib/api/user-api-key.cjs.map +1 -0
- package/dist/cjs/lib/api/user-api-key.d.cts +16 -0
- package/dist/cjs/lib/api-keys/api-key-details-dialog.cjs +13 -6
- package/dist/cjs/lib/api-keys/api-key-details-dialog.cjs.map +1 -1
- package/dist/cjs/lib/api-keys/api-keys-state.cjs +6 -0
- package/dist/cjs/lib/api-keys/api-keys-state.cjs.map +1 -1
- package/dist/cjs/lib/api-keys/api-keys-state.d.cts +2 -0
- package/dist/cjs/lib/api-keys/create-api-key.cjs +13 -1
- package/dist/cjs/lib/api-keys/create-api-key.cjs.map +1 -1
- package/dist/cjs/lib/api-keys/revoke-api-key-dialog.cjs +3 -0
- package/dist/cjs/lib/api-keys/revoke-api-key-dialog.cjs.map +1 -1
- package/dist/cjs/lib/use-permissions.cjs +3 -2
- package/dist/cjs/lib/use-permissions.cjs.map +1 -1
- package/dist/cjs/lib/use-permissions.d.cts +2 -2
- package/dist/cjs/lib/user-api-keys/create-user-api-key.cjs +593 -0
- package/dist/cjs/lib/user-api-keys/create-user-api-key.cjs.map +1 -0
- package/dist/cjs/lib/user-api-keys/create-user-api-key.d.cts +10 -0
- package/dist/cjs/lib/user-api-keys/revoke-user-api-key-dialog.cjs +130 -0
- package/dist/cjs/lib/user-api-keys/revoke-user-api-key-dialog.cjs.map +1 -0
- package/dist/cjs/lib/user-api-keys/revoke-user-api-key-dialog.d.cts +12 -0
- package/dist/cjs/lib/user-api-keys/user-api-key-details-card.cjs +94 -0
- package/dist/cjs/lib/user-api-keys/user-api-key-details-card.cjs.map +1 -0
- package/dist/cjs/lib/user-api-keys/user-api-key-details-card.d.cts +11 -0
- package/dist/cjs/lib/user-api-keys/user-api-key-details-dialog.cjs +108 -0
- package/dist/cjs/lib/user-api-keys/user-api-key-details-dialog.cjs.map +1 -0
- package/dist/cjs/lib/user-api-keys/user-api-key-details-dialog.d.cts +13 -0
- package/dist/cjs/lib/user-api-keys/user-api-keys-context.cjs +83 -0
- package/dist/cjs/lib/user-api-keys/user-api-keys-context.cjs.map +1 -0
- package/dist/cjs/lib/user-api-keys/user-api-keys-context.d.cts +16 -0
- package/dist/cjs/lib/user-api-keys/user-api-keys-search-provider.cjs +95 -0
- package/dist/cjs/lib/user-api-keys/user-api-keys-search-provider.cjs.map +1 -0
- package/dist/cjs/lib/user-api-keys/user-api-keys-search-provider.d.cts +12 -0
- package/dist/cjs/lib/user-api-keys/user-api-keys-search.cjs +104 -0
- package/dist/cjs/lib/user-api-keys/user-api-keys-search.cjs.map +1 -0
- package/dist/cjs/lib/user-api-keys/user-api-keys-search.d.cts +6 -0
- package/dist/cjs/lib/user-api-keys/user-api-keys-state.cjs +165 -0
- package/dist/cjs/lib/user-api-keys/user-api-keys-state.cjs.map +1 -0
- package/dist/cjs/lib/user-api-keys/user-api-keys-state.d.cts +33 -0
- package/dist/cjs/lib/user-api-keys/user-api-keys-table.cjs +300 -0
- package/dist/cjs/lib/user-api-keys/user-api-keys-table.cjs.map +1 -0
- package/dist/cjs/lib/user-api-keys/user-api-keys-table.d.cts +12 -0
- package/dist/cjs/lib/user-api-keys/user-api-keys.cjs +165 -0
- package/dist/cjs/lib/user-api-keys/user-api-keys.cjs.map +1 -0
- package/dist/cjs/lib/user-api-keys/user-api-keys.d.cts +34 -0
- package/dist/esm/api/api-provider.d.ts +1 -1
- package/dist/esm/api/api-provider.js.map +1 -1
- package/dist/esm/api/endpoint.d.ts +1 -1
- package/dist/esm/api/endpoint.js.map +1 -1
- package/dist/esm/api-keys.client.d.ts +1 -0
- package/dist/esm/api-keys.client.js +87 -5
- package/dist/esm/api-keys.client.js.map +1 -1
- package/dist/esm/experimental/api/fetch.d.ts +1 -1
- package/dist/esm/experimental/api/fetch.js.map +1 -1
- package/dist/esm/experimental/api/react-query.d.ts +1 -1
- package/dist/esm/experimental/api/react-query.js.map +1 -1
- package/dist/esm/experimental/api/swr.d.ts +1 -1
- package/dist/esm/experimental/api/swr.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/api/user-api-key.d.ts +16 -0
- package/dist/esm/lib/api/user-api-key.js +52 -0
- package/dist/esm/lib/api/user-api-key.js.map +1 -0
- package/dist/esm/lib/api-keys/api-key-details-dialog.js +13 -6
- package/dist/esm/lib/api-keys/api-key-details-dialog.js.map +1 -1
- package/dist/esm/lib/api-keys/api-keys-state.d.ts +2 -0
- package/dist/esm/lib/api-keys/api-keys-state.js +6 -0
- package/dist/esm/lib/api-keys/api-keys-state.js.map +1 -1
- package/dist/esm/lib/api-keys/create-api-key.js +13 -1
- package/dist/esm/lib/api-keys/create-api-key.js.map +1 -1
- package/dist/esm/lib/api-keys/revoke-api-key-dialog.js +3 -0
- package/dist/esm/lib/api-keys/revoke-api-key-dialog.js.map +1 -1
- package/dist/esm/lib/use-permissions.d.ts +2 -2
- package/dist/esm/lib/use-permissions.js +3 -2
- package/dist/esm/lib/use-permissions.js.map +1 -1
- package/dist/esm/lib/user-api-keys/create-user-api-key.d.ts +10 -0
- package/dist/esm/lib/user-api-keys/create-user-api-key.js +578 -0
- package/dist/esm/lib/user-api-keys/create-user-api-key.js.map +1 -0
- package/dist/esm/lib/user-api-keys/revoke-user-api-key-dialog.d.ts +12 -0
- package/dist/esm/lib/user-api-keys/revoke-user-api-key-dialog.js +109 -0
- package/dist/esm/lib/user-api-keys/revoke-user-api-key-dialog.js.map +1 -0
- package/dist/esm/lib/user-api-keys/user-api-key-details-card.d.ts +11 -0
- package/dist/esm/lib/user-api-keys/user-api-key-details-card.js +60 -0
- package/dist/esm/lib/user-api-keys/user-api-key-details-card.js.map +1 -0
- package/dist/esm/lib/user-api-keys/user-api-key-details-dialog.d.ts +13 -0
- package/dist/esm/lib/user-api-keys/user-api-key-details-dialog.js +86 -0
- package/dist/esm/lib/user-api-keys/user-api-key-details-dialog.js.map +1 -0
- package/dist/esm/lib/user-api-keys/user-api-keys-context.d.ts +16 -0
- package/dist/esm/lib/user-api-keys/user-api-keys-context.js +50 -0
- package/dist/esm/lib/user-api-keys/user-api-keys-context.js.map +1 -0
- package/dist/esm/lib/user-api-keys/user-api-keys-search-provider.d.ts +12 -0
- package/dist/esm/lib/user-api-keys/user-api-keys-search-provider.js +60 -0
- package/dist/esm/lib/user-api-keys/user-api-keys-search-provider.js.map +1 -0
- package/dist/esm/lib/user-api-keys/user-api-keys-search.d.ts +6 -0
- package/dist/esm/lib/user-api-keys/user-api-keys-search.js +70 -0
- package/dist/esm/lib/user-api-keys/user-api-keys-search.js.map +1 -0
- package/dist/esm/lib/user-api-keys/user-api-keys-state.d.ts +33 -0
- package/dist/esm/lib/user-api-keys/user-api-keys-state.js +131 -0
- package/dist/esm/lib/user-api-keys/user-api-keys-state.js.map +1 -0
- package/dist/esm/lib/user-api-keys/user-api-keys-table.d.ts +12 -0
- package/dist/esm/lib/user-api-keys/user-api-keys-table.js +276 -0
- package/dist/esm/lib/user-api-keys/user-api-keys-table.js.map +1 -0
- package/dist/esm/lib/user-api-keys/user-api-keys.d.ts +34 -0
- package/dist/esm/lib/user-api-keys/user-api-keys.js +141 -0
- package/dist/esm/lib/user-api-keys/user-api-keys.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Flex, Callout } from "@radix-ui/themes";
|
|
3
|
+
import { UserApiKeyDetailsCard } from "./user-api-key-details-card.js";
|
|
4
|
+
import {
|
|
5
|
+
getListUserApiKeysQueryKey,
|
|
6
|
+
useDeleteUserApiKey
|
|
7
|
+
} from "../api/user-api-key.js";
|
|
8
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
9
|
+
import { ExclamationTriangleIcon } from "@radix-ui/react-icons";
|
|
10
|
+
import { AlertDialog, Button } from "../elements.js";
|
|
11
|
+
import { Translation } from "../i18n/translation.js";
|
|
12
|
+
import { useUserApiKeysContext } from "./user-api-keys-context.js";
|
|
13
|
+
function RevokeUserApiKeyDialog({
|
|
14
|
+
apiKey,
|
|
15
|
+
open,
|
|
16
|
+
onOpenChange
|
|
17
|
+
}) {
|
|
18
|
+
const queryClient = useQueryClient();
|
|
19
|
+
const { dispatch } = useUserApiKeysContext();
|
|
20
|
+
const {
|
|
21
|
+
mutate: deleteUserApiKey,
|
|
22
|
+
isPending,
|
|
23
|
+
error,
|
|
24
|
+
isSuccess
|
|
25
|
+
} = useDeleteUserApiKey({
|
|
26
|
+
mutation: {
|
|
27
|
+
onSuccess: () => {
|
|
28
|
+
dispatch({ type: "RESET_PAGINATION" });
|
|
29
|
+
queryClient.invalidateQueries({
|
|
30
|
+
queryKey: getListUserApiKeysQueryKey()
|
|
31
|
+
});
|
|
32
|
+
onOpenChange(false);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return /* @__PURE__ */ jsx(AlertDialog.Root, { open, onOpenChange, children: /* @__PURE__ */ jsxs(AlertDialog.Content, { maxWidth: "529px", children: [
|
|
37
|
+
/* @__PURE__ */ jsx(AlertDialog.Title, { mb: "2", children: /* @__PURE__ */ jsx(
|
|
38
|
+
Translation,
|
|
39
|
+
{
|
|
40
|
+
defaultMessage: "Revoke API key?",
|
|
41
|
+
id: "e18ZsK",
|
|
42
|
+
description: "Dialog title for confirming API key revocation"
|
|
43
|
+
}
|
|
44
|
+
) }),
|
|
45
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "5", children: [
|
|
46
|
+
/* @__PURE__ */ jsxs(AlertDialog.Description, { children: [
|
|
47
|
+
/* @__PURE__ */ jsx(
|
|
48
|
+
Translation,
|
|
49
|
+
{
|
|
50
|
+
defaultMessage: "This API key will be immediately disabled. API request made using this key will be rejected, which could cause any systems still depending on it to break.",
|
|
51
|
+
id: "GLPUiU",
|
|
52
|
+
description: "Warning about revoking API key"
|
|
53
|
+
}
|
|
54
|
+
),
|
|
55
|
+
/* @__PURE__ */ jsx("strong", { children: /* @__PURE__ */ jsx(
|
|
56
|
+
Translation,
|
|
57
|
+
{
|
|
58
|
+
defaultMessage: "This action cannot be undone.",
|
|
59
|
+
id: "PTbRJT",
|
|
60
|
+
description: "Warning that API key revocation is permanent"
|
|
61
|
+
}
|
|
62
|
+
) })
|
|
63
|
+
] }),
|
|
64
|
+
error ? /* @__PURE__ */ jsxs(Callout.Root, { color: "red", role: "alert", children: [
|
|
65
|
+
/* @__PURE__ */ jsx(Callout.Icon, { children: /* @__PURE__ */ jsx(ExclamationTriangleIcon, {}) }),
|
|
66
|
+
/* @__PURE__ */ jsx(Callout.Text, { children: /* @__PURE__ */ jsx(
|
|
67
|
+
Translation,
|
|
68
|
+
{
|
|
69
|
+
defaultMessage: "An error occurred while revoking the API key.",
|
|
70
|
+
id: "edrdLd",
|
|
71
|
+
description: "Error message when API key revocation fails"
|
|
72
|
+
}
|
|
73
|
+
) })
|
|
74
|
+
] }) : null,
|
|
75
|
+
/* @__PURE__ */ jsx(UserApiKeyDetailsCard, { apiKey }),
|
|
76
|
+
/* @__PURE__ */ jsxs(Flex, { justify: "end", gap: "2", children: [
|
|
77
|
+
/* @__PURE__ */ jsx(AlertDialog.Cancel, { children: /* @__PURE__ */ jsx(Button, { variant: "secondary", children: /* @__PURE__ */ jsx(
|
|
78
|
+
Translation,
|
|
79
|
+
{
|
|
80
|
+
defaultMessage: "Cancel",
|
|
81
|
+
id: "EKf0ES",
|
|
82
|
+
description: "Button to cancel API key revocation"
|
|
83
|
+
}
|
|
84
|
+
) }) }),
|
|
85
|
+
/* @__PURE__ */ jsx(
|
|
86
|
+
Button,
|
|
87
|
+
{
|
|
88
|
+
variant: "destructive",
|
|
89
|
+
disabled: isPending || isSuccess,
|
|
90
|
+
loading: isPending || isSuccess,
|
|
91
|
+
onClick: () => deleteUserApiKey({ apiKeyId: apiKey.id }),
|
|
92
|
+
children: /* @__PURE__ */ jsx(
|
|
93
|
+
Translation,
|
|
94
|
+
{
|
|
95
|
+
defaultMessage: "Revoke key",
|
|
96
|
+
id: "KSosDD",
|
|
97
|
+
description: "Button to confirm API key revocation"
|
|
98
|
+
}
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
)
|
|
102
|
+
] })
|
|
103
|
+
] })
|
|
104
|
+
] }) });
|
|
105
|
+
}
|
|
106
|
+
export {
|
|
107
|
+
RevokeUserApiKeyDialog
|
|
108
|
+
};
|
|
109
|
+
//# sourceMappingURL=revoke-user-api-key-dialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/user-api-keys/revoke-user-api-key-dialog.tsx"],"sourcesContent":["import { Flex, Callout } from \"@radix-ui/themes\";\nimport { UserApiKeyDetailsCard } from \"./user-api-key-details-card.js\";\nimport {\n getListUserApiKeysQueryKey,\n type ListUserApiKeysResponseData,\n useDeleteUserApiKey,\n} from \"../api/user-api-key.js\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport { ExclamationTriangleIcon } from \"@radix-ui/react-icons\";\nimport { AlertDialog, Button } from \"../elements.js\";\nimport { Translation } from \"../i18n/translation.js\";\nimport { useUserApiKeysContext } from \"./user-api-keys-context.js\";\n\nexport function RevokeUserApiKeyDialog({\n apiKey,\n open,\n onOpenChange,\n}: {\n apiKey: ListUserApiKeysResponseData;\n open: boolean;\n onOpenChange: (open: boolean) => void;\n}) {\n const queryClient = useQueryClient();\n const { dispatch } = useUserApiKeysContext();\n const {\n mutate: deleteUserApiKey,\n isPending,\n error,\n isSuccess,\n } = useDeleteUserApiKey({\n mutation: {\n onSuccess: () => {\n dispatch({ type: \"RESET_PAGINATION\" });\n queryClient.invalidateQueries({\n queryKey: getListUserApiKeysQueryKey(),\n });\n onOpenChange(false);\n },\n },\n });\n\n return (\n <AlertDialog.Root open={open} onOpenChange={onOpenChange}>\n <AlertDialog.Content maxWidth=\"529px\">\n <AlertDialog.Title mb=\"2\">\n <Translation\n defaultMessage=\"Revoke API key?\"\n id=\"e18ZsK\"\n description=\"Dialog title for confirming API key revocation\"\n />\n </AlertDialog.Title>\n <Flex direction=\"column\" gap=\"5\">\n <AlertDialog.Description>\n <Translation\n defaultMessage=\"This API key will be immediately disabled. API request made using this key will be rejected, which could cause any systems still depending on it to break.\"\n id=\"GLPUiU\"\n description=\"Warning about revoking API key\"\n />\n <strong>\n <Translation\n defaultMessage=\"This action cannot be undone.\"\n id=\"PTbRJT\"\n description=\"Warning that API key revocation is permanent\"\n />\n </strong>\n </AlertDialog.Description>\n {error ? (\n <Callout.Root color=\"red\" role=\"alert\">\n <Callout.Icon>\n <ExclamationTriangleIcon />\n </Callout.Icon>\n <Callout.Text>\n <Translation\n defaultMessage=\"An error occurred while revoking the API key.\"\n id=\"edrdLd\"\n description=\"Error message when API key revocation fails\"\n />\n </Callout.Text>\n </Callout.Root>\n ) : null}\n <UserApiKeyDetailsCard apiKey={apiKey} />\n <Flex justify=\"end\" gap=\"2\">\n <AlertDialog.Cancel>\n <Button variant=\"secondary\">\n <Translation\n defaultMessage=\"Cancel\"\n id=\"EKf0ES\"\n description=\"Button to cancel API key revocation\"\n />\n </Button>\n </AlertDialog.Cancel>\n <Button\n variant=\"destructive\"\n disabled={isPending || isSuccess}\n loading={isPending || isSuccess}\n onClick={() => deleteUserApiKey({ apiKeyId: apiKey.id })}\n >\n <Translation\n defaultMessage=\"Revoke key\"\n id=\"KSosDD\"\n description=\"Button to confirm API key revocation\"\n />\n </Button>\n </Flex>\n </Flex>\n </AlertDialog.Content>\n </AlertDialog.Root>\n );\n}\n"],"mappings":"AA6CU,cAOA,YAPA;AA7CV,SAAS,MAAM,eAAe;AAC9B,SAAS,6BAA6B;AACtC;AAAA,EACE;AAAA,EAEA;AAAA,OACK;AACP,SAAS,sBAAsB;AAC/B,SAAS,+BAA+B;AACxC,SAAS,aAAa,cAAc;AACpC,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AAE/B,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,QAAM,cAAc,eAAe;AACnC,QAAM,EAAE,SAAS,IAAI,sBAAsB;AAC3C,QAAM;AAAA,IACJ,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,oBAAoB;AAAA,IACtB,UAAU;AAAA,MACR,WAAW,MAAM;AACf,iBAAS,EAAE,MAAM,mBAAmB,CAAC;AACrC,oBAAY,kBAAkB;AAAA,UAC5B,UAAU,2BAA2B;AAAA,QACvC,CAAC;AACD,qBAAa,KAAK;AAAA,MACpB;AAAA,IACF;AAAA,EACF,CAAC;AAED,SACE,oBAAC,YAAY,MAAZ,EAAiB,MAAY,cAC5B,+BAAC,YAAY,SAAZ,EAAoB,UAAS,SAC5B;AAAA,wBAAC,YAAY,OAAZ,EAAkB,IAAG,KACpB;AAAA,MAAC;AAAA;AAAA,QACC,gBAAe;AAAA,QACf,IAAG;AAAA,QACH,aAAY;AAAA;AAAA,IACd,GACF;AAAA,IACA,qBAAC,QAAK,WAAU,UAAS,KAAI,KAC3B;AAAA,2BAAC,YAAY,aAAZ,EACC;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,gBAAe;AAAA,YACf,IAAG;AAAA,YACH,aAAY;AAAA;AAAA,QACd;AAAA,QACA,oBAAC,YACC;AAAA,UAAC;AAAA;AAAA,YACC,gBAAe;AAAA,YACf,IAAG;AAAA,YACH,aAAY;AAAA;AAAA,QACd,GACF;AAAA,SACF;AAAA,MACC,QACC,qBAAC,QAAQ,MAAR,EAAa,OAAM,OAAM,MAAK,SAC7B;AAAA,4BAAC,QAAQ,MAAR,EACC,8BAAC,2BAAwB,GAC3B;AAAA,QACA,oBAAC,QAAQ,MAAR,EACC;AAAA,UAAC;AAAA;AAAA,YACC,gBAAe;AAAA,YACf,IAAG;AAAA,YACH,aAAY;AAAA;AAAA,QACd,GACF;AAAA,SACF,IACE;AAAA,MACJ,oBAAC,yBAAsB,QAAgB;AAAA,MACvC,qBAAC,QAAK,SAAQ,OAAM,KAAI,KACtB;AAAA,4BAAC,YAAY,QAAZ,EACC,8BAAC,UAAO,SAAQ,aACd;AAAA,UAAC;AAAA;AAAA,YACC,gBAAe;AAAA,YACf,IAAG;AAAA,YACH,aAAY;AAAA;AAAA,QACd,GACF,GACF;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,SAAQ;AAAA,YACR,UAAU,aAAa;AAAA,YACvB,SAAS,aAAa;AAAA,YACtB,SAAS,MAAM,iBAAiB,EAAE,UAAU,OAAO,GAAG,CAAC;AAAA,YAEvD;AAAA,cAAC;AAAA;AAAA,gBACC,gBAAe;AAAA,gBACf,IAAG;AAAA,gBACH,aAAY;AAAA;AAAA,YACd;AAAA;AAAA,QACF;AAAA,SACF;AAAA,OACF;AAAA,KACF,GACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { CardProps } from '@radix-ui/themes';
|
|
3
|
+
import { ListUserApiKeysResponseData } from '../../api/endpoint.js';
|
|
4
|
+
import '@tanstack/react-query';
|
|
5
|
+
import '../../api/widgets-api-client.js';
|
|
6
|
+
|
|
7
|
+
declare function UserApiKeyDetailsCard({ apiKey, ...cardProps }: {
|
|
8
|
+
apiKey: ListUserApiKeysResponseData;
|
|
9
|
+
} & CardProps): react_jsx_runtime.JSX.Element;
|
|
10
|
+
|
|
11
|
+
export { UserApiKeyDetailsCard };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Card, Code } from "@radix-ui/themes";
|
|
3
|
+
import * as DataList from "../data-list.js";
|
|
4
|
+
import { RelativeTime } from "../api-keys/relative-time.js";
|
|
5
|
+
import { Translation } from "../i18n/translation.js";
|
|
6
|
+
function UserApiKeyDetailsCard({
|
|
7
|
+
apiKey,
|
|
8
|
+
...cardProps
|
|
9
|
+
}) {
|
|
10
|
+
return /* @__PURE__ */ jsx(Card, { size: "2", ...cardProps, children: /* @__PURE__ */ jsxs(DataList.Root, { children: [
|
|
11
|
+
/* @__PURE__ */ jsxs(DataList.Item, { children: [
|
|
12
|
+
/* @__PURE__ */ jsx(DataList.Label, { children: /* @__PURE__ */ jsx(
|
|
13
|
+
Translation,
|
|
14
|
+
{
|
|
15
|
+
defaultMessage: "Name",
|
|
16
|
+
id: "tuCHkH",
|
|
17
|
+
description: "Label for API key name field"
|
|
18
|
+
}
|
|
19
|
+
) }),
|
|
20
|
+
/* @__PURE__ */ jsx(DataList.Value, { children: apiKey.name })
|
|
21
|
+
] }),
|
|
22
|
+
/* @__PURE__ */ jsxs(DataList.Item, { children: [
|
|
23
|
+
/* @__PURE__ */ jsx(DataList.Label, { children: /* @__PURE__ */ jsx(
|
|
24
|
+
Translation,
|
|
25
|
+
{
|
|
26
|
+
defaultMessage: "Value",
|
|
27
|
+
id: "HnuClZ",
|
|
28
|
+
description: "Label for API key value field"
|
|
29
|
+
}
|
|
30
|
+
) }),
|
|
31
|
+
/* @__PURE__ */ jsx(DataList.Value, { children: /* @__PURE__ */ jsx(Code, { color: "gray", children: apiKey.obfuscatedValue }) })
|
|
32
|
+
] }),
|
|
33
|
+
/* @__PURE__ */ jsxs(DataList.Item, { children: [
|
|
34
|
+
/* @__PURE__ */ jsx(DataList.Label, { children: /* @__PURE__ */ jsx(
|
|
35
|
+
Translation,
|
|
36
|
+
{
|
|
37
|
+
defaultMessage: "Last used",
|
|
38
|
+
id: "elg/zm",
|
|
39
|
+
description: "Label for API key last used timestamp"
|
|
40
|
+
}
|
|
41
|
+
) }),
|
|
42
|
+
/* @__PURE__ */ jsx(
|
|
43
|
+
DataList.Value,
|
|
44
|
+
{
|
|
45
|
+
style: apiKey.lastUsedAt ? void 0 : { color: "var(--gray-10)" },
|
|
46
|
+
children: /* @__PURE__ */ jsx(
|
|
47
|
+
RelativeTime,
|
|
48
|
+
{
|
|
49
|
+
date: apiKey.lastUsedAt ? new Date(apiKey.lastUsedAt) : void 0
|
|
50
|
+
}
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
)
|
|
54
|
+
] })
|
|
55
|
+
] }) });
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
UserApiKeyDetailsCard
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=user-api-key-details-card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/user-api-keys/user-api-key-details-card.tsx"],"sourcesContent":["import { Card, Code, type CardProps } from \"@radix-ui/themes\";\nimport * as DataList from \"../data-list.js\";\nimport { RelativeTime } from \"../api-keys/relative-time.js\";\nimport type { ListUserApiKeysResponseData } from \"../api/user-api-key.js\";\nimport { Translation } from \"../i18n/translation.js\";\n\nexport function UserApiKeyDetailsCard({\n apiKey,\n ...cardProps\n}: { apiKey: ListUserApiKeysResponseData } & CardProps) {\n return (\n <Card size=\"2\" {...cardProps}>\n <DataList.Root>\n <DataList.Item>\n <DataList.Label>\n <Translation\n defaultMessage=\"Name\"\n id=\"tuCHkH\"\n description=\"Label for API key name field\"\n />\n </DataList.Label>\n <DataList.Value>{apiKey.name}</DataList.Value>\n </DataList.Item>\n <DataList.Item>\n <DataList.Label>\n <Translation\n defaultMessage=\"Value\"\n id=\"HnuClZ\"\n description=\"Label for API key value field\"\n />\n </DataList.Label>\n <DataList.Value>\n <Code color=\"gray\">{apiKey.obfuscatedValue}</Code>\n </DataList.Value>\n </DataList.Item>\n <DataList.Item>\n <DataList.Label>\n <Translation\n defaultMessage=\"Last used\"\n id=\"elg/zm\"\n description=\"Label for API key last used timestamp\"\n />\n </DataList.Label>\n <DataList.Value\n style={apiKey.lastUsedAt ? undefined : { color: \"var(--gray-10)\" }}\n >\n <RelativeTime\n date={apiKey.lastUsedAt ? new Date(apiKey.lastUsedAt) : undefined}\n />\n </DataList.Value>\n </DataList.Item>\n </DataList.Root>\n </Card>\n );\n}\n"],"mappings":"AAaQ,SAEI,KAFJ;AAbR,SAAS,MAAM,YAA4B;AAC3C,YAAY,cAAc;AAC1B,SAAS,oBAAoB;AAE7B,SAAS,mBAAmB;AAErB,SAAS,sBAAsB;AAAA,EACpC;AAAA,EACA,GAAG;AACL,GAAwD;AACtD,SACE,oBAAC,QAAK,MAAK,KAAK,GAAG,WACjB,+BAAC,SAAS,MAAT,EACC;AAAA,yBAAC,SAAS,MAAT,EACC;AAAA,0BAAC,SAAS,OAAT,EACC;AAAA,QAAC;AAAA;AAAA,UACC,gBAAe;AAAA,UACf,IAAG;AAAA,UACH,aAAY;AAAA;AAAA,MACd,GACF;AAAA,MACA,oBAAC,SAAS,OAAT,EAAgB,iBAAO,MAAK;AAAA,OAC/B;AAAA,IACA,qBAAC,SAAS,MAAT,EACC;AAAA,0BAAC,SAAS,OAAT,EACC;AAAA,QAAC;AAAA;AAAA,UACC,gBAAe;AAAA,UACf,IAAG;AAAA,UACH,aAAY;AAAA;AAAA,MACd,GACF;AAAA,MACA,oBAAC,SAAS,OAAT,EACC,8BAAC,QAAK,OAAM,QAAQ,iBAAO,iBAAgB,GAC7C;AAAA,OACF;AAAA,IACA,qBAAC,SAAS,MAAT,EACC;AAAA,0BAAC,SAAS,OAAT,EACC;AAAA,QAAC;AAAA;AAAA,UACC,gBAAe;AAAA,UACf,IAAG;AAAA,UACH,aAAY;AAAA;AAAA,MACd,GACF;AAAA,MACA;AAAA,QAAC,SAAS;AAAA,QAAT;AAAA,UACC,OAAO,OAAO,aAAa,SAAY,EAAE,OAAO,iBAAiB;AAAA,UAEjE;AAAA,YAAC;AAAA;AAAA,cACC,MAAM,OAAO,aAAa,IAAI,KAAK,OAAO,UAAU,IAAI;AAAA;AAAA,UAC1D;AAAA;AAAA,MACF;AAAA,OACF;AAAA,KACF,GACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ListUserApiKeysResponseData } from '../../api/endpoint.js';
|
|
3
|
+
import '@tanstack/react-query';
|
|
4
|
+
import '../../api/widgets-api-client.js';
|
|
5
|
+
|
|
6
|
+
declare function UserApiKeyDetailsDialog({ open, onOpenChange, apiKey, permissions, }: {
|
|
7
|
+
open: boolean;
|
|
8
|
+
onOpenChange: (open: boolean) => void;
|
|
9
|
+
apiKey: ListUserApiKeysResponseData;
|
|
10
|
+
permissions: string[];
|
|
11
|
+
}): react_jsx_runtime.JSX.Element;
|
|
12
|
+
|
|
13
|
+
export { UserApiKeyDetailsDialog };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Flex, Box, Text, ScrollArea } from "@radix-ui/themes";
|
|
3
|
+
import { Button, Dialog, Label } from "../elements.js";
|
|
4
|
+
import { UserApiKeyDetailsCard } from "./user-api-key-details-card.js";
|
|
5
|
+
import {
|
|
6
|
+
useListUserApiKeyPermissions
|
|
7
|
+
} from "../api/user-api-key.js";
|
|
8
|
+
import { Translation } from "../i18n/translation.js";
|
|
9
|
+
function Permission({
|
|
10
|
+
...permission
|
|
11
|
+
}) {
|
|
12
|
+
return /* @__PURE__ */ jsx(Box, { className: "woswidgets-api-key-details-permission", px: "4", py: "3", children: /* @__PURE__ */ jsxs(Flex, { direction: "column", children: [
|
|
13
|
+
/* @__PURE__ */ jsx(Text, { size: "2", weight: "bold", children: permission.name }),
|
|
14
|
+
permission.description ? /* @__PURE__ */ jsx(Text, { size: "2", color: "gray", children: permission.description }) : null
|
|
15
|
+
] }) });
|
|
16
|
+
}
|
|
17
|
+
function UserApiKeyDetailsDialog({
|
|
18
|
+
open,
|
|
19
|
+
onOpenChange,
|
|
20
|
+
apiKey,
|
|
21
|
+
permissions
|
|
22
|
+
}) {
|
|
23
|
+
const permissionsQuery = useListUserApiKeyPermissions({ limit: 100 });
|
|
24
|
+
const permissionBySlug = new Map(
|
|
25
|
+
permissionsQuery.data?.data.map((permission) => [
|
|
26
|
+
permission.slug,
|
|
27
|
+
permission
|
|
28
|
+
]) ?? []
|
|
29
|
+
);
|
|
30
|
+
const displayedPermissions = permissions.map(
|
|
31
|
+
(slug) => permissionBySlug.get(slug) ?? {
|
|
32
|
+
slug,
|
|
33
|
+
name: slug,
|
|
34
|
+
description: null
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
return /* @__PURE__ */ jsx(Dialog.Root, { open, onOpenChange, children: /* @__PURE__ */ jsxs(Dialog.Content, { maxWidth: "529px", children: [
|
|
38
|
+
/* @__PURE__ */ jsx(Dialog.Title, { children: /* @__PURE__ */ jsx(
|
|
39
|
+
Translation,
|
|
40
|
+
{
|
|
41
|
+
defaultMessage: "API key details",
|
|
42
|
+
id: "dqU4kt",
|
|
43
|
+
description: "Dialog title for viewing API key details"
|
|
44
|
+
}
|
|
45
|
+
) }),
|
|
46
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "5", children: [
|
|
47
|
+
/* @__PURE__ */ jsx(UserApiKeyDetailsCard, { apiKey, mt: "5" }),
|
|
48
|
+
permissions.length ? /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "2", children: [
|
|
49
|
+
/* @__PURE__ */ jsx(Label, { children: /* @__PURE__ */ jsx(
|
|
50
|
+
Translation,
|
|
51
|
+
{
|
|
52
|
+
defaultMessage: "Permissions",
|
|
53
|
+
id: "i0XUeg",
|
|
54
|
+
description: "Label for API key permissions section"
|
|
55
|
+
}
|
|
56
|
+
) }),
|
|
57
|
+
/* @__PURE__ */ jsx(
|
|
58
|
+
Flex,
|
|
59
|
+
{
|
|
60
|
+
style: {
|
|
61
|
+
borderRadius: "var(--radius-3)",
|
|
62
|
+
borderColor: "var(--gray-6)",
|
|
63
|
+
borderWidth: "1px",
|
|
64
|
+
borderStyle: "solid"
|
|
65
|
+
},
|
|
66
|
+
direction: "column",
|
|
67
|
+
align: "stretch",
|
|
68
|
+
children: /* @__PURE__ */ jsx(ScrollArea, { style: { maxHeight: "calc(50vh - 150px)" }, children: displayedPermissions.map((permission) => /* @__PURE__ */ jsx(Permission, { ...permission }, permission.slug)) })
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
] }) : null
|
|
72
|
+
] }),
|
|
73
|
+
/* @__PURE__ */ jsx(Flex, { align: "center", gap: "3", justify: "end", mt: "5", children: /* @__PURE__ */ jsx(Dialog.Close, { children: /* @__PURE__ */ jsx(Button, { variant: "secondary", children: /* @__PURE__ */ jsx(
|
|
74
|
+
Translation,
|
|
75
|
+
{
|
|
76
|
+
defaultMessage: "Close",
|
|
77
|
+
id: "/4YwoE",
|
|
78
|
+
description: "Button to close the API key details dialog"
|
|
79
|
+
}
|
|
80
|
+
) }) }) })
|
|
81
|
+
] }) });
|
|
82
|
+
}
|
|
83
|
+
export {
|
|
84
|
+
UserApiKeyDetailsDialog
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=user-api-key-details-dialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/user-api-keys/user-api-key-details-dialog.tsx"],"sourcesContent":["import { Flex, Box, Text, ScrollArea } from \"@radix-ui/themes\";\nimport { Button, Dialog, Label } from \"../elements.js\";\nimport { UserApiKeyDetailsCard } from \"./user-api-key-details-card.js\";\nimport {\n type ListUserApiKeysResponseData,\n useListUserApiKeyPermissions,\n} from \"../api/user-api-key.js\";\nimport { Translation } from \"../i18n/translation.js\";\n\nfunction Permission({\n ...permission\n}: {\n slug: string;\n name: string;\n description?: string | null;\n}) {\n return (\n <Box className=\"woswidgets-api-key-details-permission\" px=\"4\" py=\"3\">\n <Flex direction=\"column\">\n <Text size=\"2\" weight=\"bold\">\n {permission.name}\n </Text>\n {permission.description ? (\n <Text size=\"2\" color=\"gray\">\n {permission.description}\n </Text>\n ) : null}\n </Flex>\n </Box>\n );\n}\n\nexport function UserApiKeyDetailsDialog({\n open,\n onOpenChange,\n apiKey,\n permissions,\n}: {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n apiKey: ListUserApiKeysResponseData;\n permissions: string[];\n}) {\n const permissionsQuery = useListUserApiKeyPermissions({ limit: 100 });\n const permissionBySlug = new Map(\n permissionsQuery.data?.data.map((permission) => [\n permission.slug,\n permission,\n ]) ?? [],\n );\n const displayedPermissions = permissions.map(\n (slug) =>\n permissionBySlug.get(slug) ?? {\n slug,\n name: slug,\n description: null,\n },\n );\n\n return (\n <Dialog.Root open={open} onOpenChange={onOpenChange}>\n <Dialog.Content maxWidth=\"529px\">\n <Dialog.Title>\n <Translation\n defaultMessage=\"API key details\"\n id=\"dqU4kt\"\n description=\"Dialog title for viewing API key details\"\n />\n </Dialog.Title>\n <Flex direction=\"column\" gap=\"5\">\n <UserApiKeyDetailsCard apiKey={apiKey} mt=\"5\" />\n {permissions.length ? (\n <Flex direction=\"column\" gap=\"2\">\n <Label>\n <Translation\n defaultMessage=\"Permissions\"\n id=\"i0XUeg\"\n description=\"Label for API key permissions section\"\n />\n </Label>\n <Flex\n style={{\n borderRadius: \"var(--radius-3)\",\n borderColor: \"var(--gray-6)\",\n borderWidth: \"1px\",\n borderStyle: \"solid\",\n }}\n direction=\"column\"\n align=\"stretch\"\n >\n <ScrollArea style={{ maxHeight: \"calc(50vh - 150px)\" }}>\n {displayedPermissions.map((permission) => (\n <Permission key={permission.slug} {...permission} />\n ))}\n </ScrollArea>\n </Flex>\n </Flex>\n ) : null}\n </Flex>\n <Flex align=\"center\" gap=\"3\" justify=\"end\" mt=\"5\">\n <Dialog.Close>\n <Button variant=\"secondary\">\n <Translation\n defaultMessage=\"Close\"\n id=\"/4YwoE\"\n description=\"Button to close the API key details dialog\"\n />\n </Button>\n </Dialog.Close>\n </Flex>\n </Dialog.Content>\n </Dialog.Root>\n );\n}\n"],"mappings":"AAkBM,SACE,KADF;AAlBN,SAAS,MAAM,KAAK,MAAM,kBAAkB;AAC5C,SAAS,QAAQ,QAAQ,aAAa;AACtC,SAAS,6BAA6B;AACtC;AAAA,EAEE;AAAA,OACK;AACP,SAAS,mBAAmB;AAE5B,SAAS,WAAW;AAAA,EAClB,GAAG;AACL,GAIG;AACD,SACE,oBAAC,OAAI,WAAU,yCAAwC,IAAG,KAAI,IAAG,KAC/D,+BAAC,QAAK,WAAU,UACd;AAAA,wBAAC,QAAK,MAAK,KAAI,QAAO,QACnB,qBAAW,MACd;AAAA,IACC,WAAW,cACV,oBAAC,QAAK,MAAK,KAAI,OAAM,QAClB,qBAAW,aACd,IACE;AAAA,KACN,GACF;AAEJ;AAEO,SAAS,wBAAwB;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAKG;AACD,QAAM,mBAAmB,6BAA6B,EAAE,OAAO,IAAI,CAAC;AACpE,QAAM,mBAAmB,IAAI;AAAA,IAC3B,iBAAiB,MAAM,KAAK,IAAI,CAAC,eAAe;AAAA,MAC9C,WAAW;AAAA,MACX;AAAA,IACF,CAAC,KAAK,CAAC;AAAA,EACT;AACA,QAAM,uBAAuB,YAAY;AAAA,IACvC,CAAC,SACC,iBAAiB,IAAI,IAAI,KAAK;AAAA,MAC5B;AAAA,MACA,MAAM;AAAA,MACN,aAAa;AAAA,IACf;AAAA,EACJ;AAEA,SACE,oBAAC,OAAO,MAAP,EAAY,MAAY,cACvB,+BAAC,OAAO,SAAP,EAAe,UAAS,SACvB;AAAA,wBAAC,OAAO,OAAP,EACC;AAAA,MAAC;AAAA;AAAA,QACC,gBAAe;AAAA,QACf,IAAG;AAAA,QACH,aAAY;AAAA;AAAA,IACd,GACF;AAAA,IACA,qBAAC,QAAK,WAAU,UAAS,KAAI,KAC3B;AAAA,0BAAC,yBAAsB,QAAgB,IAAG,KAAI;AAAA,MAC7C,YAAY,SACX,qBAAC,QAAK,WAAU,UAAS,KAAI,KAC3B;AAAA,4BAAC,SACC;AAAA,UAAC;AAAA;AAAA,YACC,gBAAe;AAAA,YACf,IAAG;AAAA,YACH,aAAY;AAAA;AAAA,QACd,GACF;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,OAAO;AAAA,cACL,cAAc;AAAA,cACd,aAAa;AAAA,cACb,aAAa;AAAA,cACb,aAAa;AAAA,YACf;AAAA,YACA,WAAU;AAAA,YACV,OAAM;AAAA,YAEN,8BAAC,cAAW,OAAO,EAAE,WAAW,qBAAqB,GAClD,+BAAqB,IAAI,CAAC,eACzB,oBAAC,cAAkC,GAAG,cAArB,WAAW,IAAsB,CACnD,GACH;AAAA;AAAA,QACF;AAAA,SACF,IACE;AAAA,OACN;AAAA,IACA,oBAAC,QAAK,OAAM,UAAS,KAAI,KAAI,SAAQ,OAAM,IAAG,KAC5C,8BAAC,OAAO,OAAP,EACC,8BAAC,UAAO,SAAQ,aACd;AAAA,MAAC;AAAA;AAAA,QACC,gBAAe;AAAA,QACf,IAAG;AAAA,QACH,aAAY;AAAA;AAAA,IACd,GACF,GACF,GACF;AAAA,KACF,GACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { UserApiKeysState, UserApiKeysAction } from './user-api-keys-state.js';
|
|
3
|
+
import '../../api/endpoint.js';
|
|
4
|
+
import '@tanstack/react-query';
|
|
5
|
+
import '../../api/widgets-api-client.js';
|
|
6
|
+
|
|
7
|
+
interface UserApiKeysContextType {
|
|
8
|
+
state: UserApiKeysState;
|
|
9
|
+
dispatch: React.Dispatch<UserApiKeysAction>;
|
|
10
|
+
}
|
|
11
|
+
declare const UserApiKeysContextProvider: React.FC<{
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
}>;
|
|
14
|
+
declare function useUserApiKeysContext(initialContext?: UserApiKeysContextType | null): UserApiKeysContextType;
|
|
15
|
+
|
|
16
|
+
export { UserApiKeysContextProvider, type UserApiKeysContextType, useUserApiKeysContext };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import {
|
|
5
|
+
useUserApiKeysState
|
|
6
|
+
} from "./user-api-keys-state.js";
|
|
7
|
+
const UserApiKeysContext = React.createContext(void 0);
|
|
8
|
+
UserApiKeysContext.displayName = "UserApiKeysContext";
|
|
9
|
+
const initialState = {
|
|
10
|
+
pagination: null,
|
|
11
|
+
searchQuery: null,
|
|
12
|
+
createDialogOpen: false,
|
|
13
|
+
createdApiKey: null
|
|
14
|
+
};
|
|
15
|
+
const UserApiKeysContextProvider = ({ children }) => {
|
|
16
|
+
const [state, dispatch] = useUserApiKeysState(initialState);
|
|
17
|
+
const context = React.useMemo(
|
|
18
|
+
() => ({
|
|
19
|
+
state,
|
|
20
|
+
dispatch
|
|
21
|
+
}),
|
|
22
|
+
[state, dispatch]
|
|
23
|
+
);
|
|
24
|
+
return /* @__PURE__ */ jsx(UserApiKeysContext.Provider, { value: context, children });
|
|
25
|
+
};
|
|
26
|
+
const NOOP = () => void 0;
|
|
27
|
+
const EMPTY_PAGINATION = { before: null, after: null };
|
|
28
|
+
function useUserApiKeysContext(initialContext) {
|
|
29
|
+
const context = React.useContext(UserApiKeysContext);
|
|
30
|
+
if (context) {
|
|
31
|
+
return context;
|
|
32
|
+
}
|
|
33
|
+
if (initialContext) {
|
|
34
|
+
return initialContext;
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
dispatch: NOOP,
|
|
38
|
+
state: {
|
|
39
|
+
pagination: EMPTY_PAGINATION,
|
|
40
|
+
searchQuery: null,
|
|
41
|
+
createDialogOpen: false,
|
|
42
|
+
createdApiKey: null
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
UserApiKeysContextProvider,
|
|
48
|
+
useUserApiKeysContext
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=user-api-keys-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/user-api-keys/user-api-keys-context.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport {\n type UserApiKeysAction,\n type UserApiKeysState,\n useUserApiKeysState,\n} from \"./user-api-keys-state.js\";\nimport type { ListMetadata } from \"../../api/endpoint.js\";\n\nexport interface UserApiKeysContextType {\n state: UserApiKeysState;\n dispatch: React.Dispatch<UserApiKeysAction>;\n}\n\nconst UserApiKeysContext = React.createContext<\n UserApiKeysContextType | undefined\n>(undefined);\nUserApiKeysContext.displayName = \"UserApiKeysContext\";\n\nconst initialState: UserApiKeysState = {\n pagination: null,\n searchQuery: null,\n createDialogOpen: false,\n createdApiKey: null,\n};\n\nexport const UserApiKeysContextProvider: React.FC<{\n children?: React.ReactNode;\n}> = ({ children }) => {\n const [state, dispatch] = useUserApiKeysState(initialState);\n\n const context = React.useMemo<UserApiKeysContextType>(\n () => ({\n state,\n dispatch,\n }),\n [state, dispatch],\n );\n\n return (\n <UserApiKeysContext.Provider value={context}>\n {children}\n </UserApiKeysContext.Provider>\n );\n};\n\nconst NOOP = () => void 0;\nconst EMPTY_PAGINATION: ListMetadata = { before: null, after: null };\n\nexport function useUserApiKeysContext(\n initialContext?: UserApiKeysContextType | null,\n): UserApiKeysContextType {\n const context = React.useContext(UserApiKeysContext);\n\n if (context) {\n return context;\n }\n\n if (initialContext) {\n return initialContext;\n }\n\n return {\n dispatch: NOOP,\n state: {\n pagination: EMPTY_PAGINATION,\n searchQuery: null,\n createDialogOpen: false,\n createdApiKey: null,\n },\n };\n}\n"],"mappings":";AAyCI;AAvCJ,YAAY,WAAW;AACvB;AAAA,EAGE;AAAA,OACK;AAQP,MAAM,qBAAqB,MAAM,cAE/B,MAAS;AACX,mBAAmB,cAAc;AAEjC,MAAM,eAAiC;AAAA,EACrC,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,eAAe;AACjB;AAEO,MAAM,6BAER,CAAC,EAAE,SAAS,MAAM;AACrB,QAAM,CAAC,OAAO,QAAQ,IAAI,oBAAoB,YAAY;AAE1D,QAAM,UAAU,MAAM;AAAA,IACpB,OAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,IACA,CAAC,OAAO,QAAQ;AAAA,EAClB;AAEA,SACE,oBAAC,mBAAmB,UAAnB,EAA4B,OAAO,SACjC,UACH;AAEJ;AAEA,MAAM,OAAO,MAAM;AACnB,MAAM,mBAAiC,EAAE,QAAQ,MAAM,OAAO,KAAK;AAE5D,SAAS,sBACd,gBACwB;AACxB,QAAM,UAAU,MAAM,WAAW,kBAAkB;AAEnD,MAAI,SAAS;AACX,WAAO;AAAA,EACT;AAEA,MAAI,gBAAgB;AAClB,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,UAAU;AAAA,IACV,OAAO;AAAA,MACL,YAAY;AAAA,MACZ,aAAa;AAAA,MACb,kBAAkB;AAAA,MAClB,eAAe;AAAA,IACjB;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface UserApiKeysSearchContextType {
|
|
4
|
+
inputRef: React.RefObject<HTMLInputElement | null>;
|
|
5
|
+
clearSearch: () => void;
|
|
6
|
+
searchValue: string;
|
|
7
|
+
setSearchValue: React.Dispatch<React.SetStateAction<string>>;
|
|
8
|
+
}
|
|
9
|
+
declare const UserApiKeysSearchProvider: React.FC<React.PropsWithChildren>;
|
|
10
|
+
declare const useUserApiKeysSearchContext: () => UserApiKeysSearchContextType;
|
|
11
|
+
|
|
12
|
+
export { UserApiKeysSearchProvider, useUserApiKeysSearchContext };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { flushSync } from "react-dom";
|
|
4
|
+
import { useUserApiKeysContext } from "./user-api-keys-context.js";
|
|
5
|
+
const UserApiKeysSearchContext = React.createContext(void 0);
|
|
6
|
+
UserApiKeysSearchContext.displayName = "UserApiKeysSearchContext";
|
|
7
|
+
const UserApiKeysSearchProvider = ({
|
|
8
|
+
children
|
|
9
|
+
}) => {
|
|
10
|
+
const inputRef = React.useRef(null);
|
|
11
|
+
const {
|
|
12
|
+
state: { searchQuery },
|
|
13
|
+
dispatch
|
|
14
|
+
} = useUserApiKeysContext();
|
|
15
|
+
const [searchState, setSearchState] = React.useState({
|
|
16
|
+
searchQuery,
|
|
17
|
+
value: searchQuery || ""
|
|
18
|
+
});
|
|
19
|
+
const searchValue = searchState.searchQuery === searchQuery ? searchState.value : searchQuery || "";
|
|
20
|
+
const setSearchValue = React.useCallback(
|
|
21
|
+
(nextValue) => {
|
|
22
|
+
setSearchState((prev) => {
|
|
23
|
+
const currentValue = prev.searchQuery === searchQuery ? prev.value : searchQuery || "";
|
|
24
|
+
return {
|
|
25
|
+
searchQuery,
|
|
26
|
+
value: typeof nextValue === "function" ? nextValue(currentValue) : nextValue
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
[searchQuery]
|
|
31
|
+
);
|
|
32
|
+
const clearSearch = React.useCallback(() => {
|
|
33
|
+
flushSync(() => {
|
|
34
|
+
setSearchValue("");
|
|
35
|
+
dispatch({ type: "FILTER_BY_SEARCH", searchQuery: "" });
|
|
36
|
+
});
|
|
37
|
+
inputRef.current?.focus();
|
|
38
|
+
}, [dispatch, setSearchValue]);
|
|
39
|
+
return /* @__PURE__ */ jsx(
|
|
40
|
+
UserApiKeysSearchContext.Provider,
|
|
41
|
+
{
|
|
42
|
+
value: { inputRef, clearSearch, searchValue, setSearchValue },
|
|
43
|
+
children
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
const useUserApiKeysSearchContext = () => {
|
|
48
|
+
const context = React.useContext(UserApiKeysSearchContext);
|
|
49
|
+
if (!context) {
|
|
50
|
+
throw new Error(
|
|
51
|
+
"useUserApiKeysSearchContext must be used within a UserApiKeysSearchProvider"
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
return context;
|
|
55
|
+
};
|
|
56
|
+
export {
|
|
57
|
+
UserApiKeysSearchProvider,
|
|
58
|
+
useUserApiKeysSearchContext
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=user-api-keys-search-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/user-api-keys/user-api-keys-search-provider.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { useUserApiKeysContext } from \"./user-api-keys-context.js\";\n\ninterface UserApiKeysSearchContextType {\n inputRef: React.RefObject<HTMLInputElement | null>;\n clearSearch: () => void;\n searchValue: string;\n setSearchValue: React.Dispatch<React.SetStateAction<string>>;\n}\n\nconst UserApiKeysSearchContext = React.createContext<\n UserApiKeysSearchContextType | undefined\n>(undefined);\nUserApiKeysSearchContext.displayName = \"UserApiKeysSearchContext\";\n\nexport const UserApiKeysSearchProvider: React.FC<React.PropsWithChildren> = ({\n children,\n}) => {\n const inputRef = React.useRef<HTMLInputElement | null>(null);\n const {\n state: { searchQuery },\n dispatch,\n } = useUserApiKeysContext();\n\n const [searchState, setSearchState] = React.useState({\n searchQuery,\n value: searchQuery || \"\",\n });\n const searchValue =\n searchState.searchQuery === searchQuery\n ? searchState.value\n : searchQuery || \"\";\n const setSearchValue = React.useCallback<\n React.Dispatch<React.SetStateAction<string>>\n >(\n (nextValue) => {\n setSearchState((prev) => {\n const currentValue =\n prev.searchQuery === searchQuery ? prev.value : searchQuery || \"\";\n return {\n searchQuery,\n value:\n typeof nextValue === \"function\"\n ? nextValue(currentValue)\n : nextValue,\n };\n });\n },\n [searchQuery],\n );\n\n const clearSearch = React.useCallback(() => {\n flushSync(() => {\n setSearchValue(\"\");\n dispatch({ type: \"FILTER_BY_SEARCH\", searchQuery: \"\" });\n });\n inputRef.current?.focus();\n }, [dispatch, setSearchValue]);\n\n return (\n <UserApiKeysSearchContext.Provider\n value={{ inputRef, clearSearch, searchValue, setSearchValue }}\n >\n {children}\n </UserApiKeysSearchContext.Provider>\n );\n};\n\nexport const useUserApiKeysSearchContext = () => {\n const context = React.useContext(UserApiKeysSearchContext);\n if (!context) {\n throw new Error(\n \"useUserApiKeysSearchContext must be used within a UserApiKeysSearchProvider\",\n );\n }\n return context;\n};\n"],"mappings":"AA6DI;AA7DJ,YAAY,WAAW;AACvB,SAAS,iBAAiB;AAC1B,SAAS,6BAA6B;AAStC,MAAM,2BAA2B,MAAM,cAErC,MAAS;AACX,yBAAyB,cAAc;AAEhC,MAAM,4BAA+D,CAAC;AAAA,EAC3E;AACF,MAAM;AACJ,QAAM,WAAW,MAAM,OAAgC,IAAI;AAC3D,QAAM;AAAA,IACJ,OAAO,EAAE,YAAY;AAAA,IACrB;AAAA,EACF,IAAI,sBAAsB;AAE1B,QAAM,CAAC,aAAa,cAAc,IAAI,MAAM,SAAS;AAAA,IACnD;AAAA,IACA,OAAO,eAAe;AAAA,EACxB,CAAC;AACD,QAAM,cACJ,YAAY,gBAAgB,cACxB,YAAY,QACZ,eAAe;AACrB,QAAM,iBAAiB,MAAM;AAAA,IAG3B,CAAC,cAAc;AACb,qBAAe,CAAC,SAAS;AACvB,cAAM,eACJ,KAAK,gBAAgB,cAAc,KAAK,QAAQ,eAAe;AACjE,eAAO;AAAA,UACL;AAAA,UACA,OACE,OAAO,cAAc,aACjB,UAAU,YAAY,IACtB;AAAA,QACR;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,CAAC,WAAW;AAAA,EACd;AAEA,QAAM,cAAc,MAAM,YAAY,MAAM;AAC1C,cAAU,MAAM;AACd,qBAAe,EAAE;AACjB,eAAS,EAAE,MAAM,oBAAoB,aAAa,GAAG,CAAC;AAAA,IACxD,CAAC;AACD,aAAS,SAAS,MAAM;AAAA,EAC1B,GAAG,CAAC,UAAU,cAAc,CAAC;AAE7B,SACE;AAAA,IAAC,yBAAyB;AAAA,IAAzB;AAAA,MACC,OAAO,EAAE,UAAU,aAAa,aAAa,eAAe;AAAA,MAE3D;AAAA;AAAA,EACH;AAEJ;AAEO,MAAM,8BAA8B,MAAM;AAC/C,QAAM,UAAU,MAAM,WAAW,wBAAwB;AACzD,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as _radix_ui_themes_components_text_field from '@radix-ui/themes/components/text-field';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
declare const UserApiKeysSearch: React.ForwardRefExoticComponent<Omit<_radix_ui_themes_components_text_field.RootProps & React.RefAttributes<HTMLInputElement>, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
5
|
+
|
|
6
|
+
export { UserApiKeysSearch };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useComposedRefs } from "radix-ui/internal";
|
|
4
|
+
import { Cross2Icon, MagnifyingGlassIcon } from "@radix-ui/react-icons";
|
|
5
|
+
import cx from "clsx";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import { useDebouncedCallback } from "use-debounce";
|
|
8
|
+
import { IconButton, TextField, TextFieldSlot } from "../elements.js";
|
|
9
|
+
import { useUserApiKeysSearchContext } from "./user-api-keys-search-provider.js";
|
|
10
|
+
import { useUserApiKeysContext } from "./user-api-keys-context.js";
|
|
11
|
+
import { namespaceClassNames } from "../utils.js";
|
|
12
|
+
import { useTranslation } from "../i18n/use-translation.js";
|
|
13
|
+
const UserApiKeysSearch = React.forwardRef(({ className, ...props }, ref) => {
|
|
14
|
+
const { inputRef, clearSearch, searchValue, setSearchValue } = useUserApiKeysSearchContext();
|
|
15
|
+
const { dispatch } = useUserApiKeysContext();
|
|
16
|
+
const translate = useTranslation();
|
|
17
|
+
const filter = useDebouncedCallback((value) => {
|
|
18
|
+
dispatch({ type: "FILTER_BY_SEARCH", searchQuery: value });
|
|
19
|
+
}, 200);
|
|
20
|
+
const resetSearch = () => {
|
|
21
|
+
clearSearch();
|
|
22
|
+
filter.cancel();
|
|
23
|
+
};
|
|
24
|
+
return /* @__PURE__ */ jsxs(
|
|
25
|
+
TextField,
|
|
26
|
+
{
|
|
27
|
+
ref: useComposedRefs(inputRef, ref),
|
|
28
|
+
className: cx(namespaceClassNames("api-keys-search"), className),
|
|
29
|
+
autoComplete: "off",
|
|
30
|
+
placeholder: translate({
|
|
31
|
+
defaultMessage: "Search by name",
|
|
32
|
+
id: "GC8aGI",
|
|
33
|
+
description: "Placeholder for API key search input"
|
|
34
|
+
}),
|
|
35
|
+
value: searchValue,
|
|
36
|
+
onChange: (event) => {
|
|
37
|
+
const value = event.target.value;
|
|
38
|
+
setSearchValue(value);
|
|
39
|
+
filter(value);
|
|
40
|
+
},
|
|
41
|
+
onKeyDown: (event) => {
|
|
42
|
+
if (event.key === "Escape") {
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
resetSearch();
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
...props,
|
|
48
|
+
children: [
|
|
49
|
+
/* @__PURE__ */ jsx(TextFieldSlot, { side: "left", children: /* @__PURE__ */ jsx(MagnifyingGlassIcon, { "aria-hidden": "true", height: "16", width: "16" }) }),
|
|
50
|
+
/* @__PURE__ */ jsx(TextFieldSlot, { side: "right", children: !!searchValue && /* @__PURE__ */ jsx(
|
|
51
|
+
IconButton,
|
|
52
|
+
{
|
|
53
|
+
size: "1",
|
|
54
|
+
onClick: resetSearch,
|
|
55
|
+
title: translate({
|
|
56
|
+
defaultMessage: "Clear search",
|
|
57
|
+
id: "7enwzK",
|
|
58
|
+
description: "Title tooltip for clear search button"
|
|
59
|
+
}),
|
|
60
|
+
children: /* @__PURE__ */ jsx(Cross2Icon, { "aria-hidden": "true" })
|
|
61
|
+
}
|
|
62
|
+
) })
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
export {
|
|
68
|
+
UserApiKeysSearch
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=user-api-keys-search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/user-api-keys/user-api-keys-search.tsx"],"sourcesContent":["\"use client\";\n\nimport { useComposedRefs } from \"radix-ui/internal\";\nimport { Cross2Icon, MagnifyingGlassIcon } from \"@radix-ui/react-icons\";\nimport cx from \"clsx\";\nimport * as React from \"react\";\nimport { useDebouncedCallback } from \"use-debounce\";\nimport { IconButton, TextField, TextFieldSlot } from \"../elements.js\";\nimport { useUserApiKeysSearchContext } from \"./user-api-keys-search-provider.js\";\nimport { useUserApiKeysContext } from \"./user-api-keys-context.js\";\nimport { namespaceClassNames } from \"../utils.js\";\nimport { useTranslation } from \"../i18n/use-translation.js\";\n\ntype UserApiKeysSearchProps = React.ComponentPropsWithoutRef<typeof TextField>;\n\nexport const UserApiKeysSearch = React.forwardRef<\n HTMLInputElement,\n UserApiKeysSearchProps\n>(({ className, ...props }, ref) => {\n const { inputRef, clearSearch, searchValue, setSearchValue } =\n useUserApiKeysSearchContext();\n const { dispatch } = useUserApiKeysContext();\n const translate = useTranslation();\n\n const filter = useDebouncedCallback((value) => {\n dispatch({ type: \"FILTER_BY_SEARCH\", searchQuery: value });\n }, 200);\n\n const resetSearch = () => {\n clearSearch();\n filter.cancel();\n };\n\n return (\n <TextField\n ref={useComposedRefs(inputRef, ref)}\n className={cx(namespaceClassNames(\"api-keys-search\"), className)}\n autoComplete=\"off\"\n placeholder={translate({\n defaultMessage: \"Search by name\",\n id: \"GC8aGI\",\n description: \"Placeholder for API key search input\",\n })}\n value={searchValue}\n onChange={(event) => {\n const value = event.target.value;\n setSearchValue(value);\n filter(value);\n }}\n onKeyDown={(event) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n resetSearch();\n }\n }}\n {...props}\n >\n <TextFieldSlot side=\"left\">\n <MagnifyingGlassIcon aria-hidden=\"true\" height=\"16\" width=\"16\" />\n </TextFieldSlot>\n\n <TextFieldSlot side=\"right\">\n {!!searchValue && (\n <IconButton\n size=\"1\"\n onClick={resetSearch}\n title={translate({\n defaultMessage: \"Clear search\",\n id: \"7enwzK\",\n description: \"Title tooltip for clear search button\",\n })}\n >\n <Cross2Icon aria-hidden=\"true\" />\n </IconButton>\n )}\n </TextFieldSlot>\n </TextField>\n );\n});\n"],"mappings":";AAkCI,SAwBI,KAxBJ;AAhCJ,SAAS,uBAAuB;AAChC,SAAS,YAAY,2BAA2B;AAChD,OAAO,QAAQ;AACf,YAAY,WAAW;AACvB,SAAS,4BAA4B;AACrC,SAAS,YAAY,WAAW,qBAAqB;AACrD,SAAS,mCAAmC;AAC5C,SAAS,6BAA6B;AACtC,SAAS,2BAA2B;AACpC,SAAS,sBAAsB;AAIxB,MAAM,oBAAoB,MAAM,WAGrC,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,QAAQ;AAClC,QAAM,EAAE,UAAU,aAAa,aAAa,eAAe,IACzD,4BAA4B;AAC9B,QAAM,EAAE,SAAS,IAAI,sBAAsB;AAC3C,QAAM,YAAY,eAAe;AAEjC,QAAM,SAAS,qBAAqB,CAAC,UAAU;AAC7C,aAAS,EAAE,MAAM,oBAAoB,aAAa,MAAM,CAAC;AAAA,EAC3D,GAAG,GAAG;AAEN,QAAM,cAAc,MAAM;AACxB,gBAAY;AACZ,WAAO,OAAO;AAAA,EAChB;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,KAAK,gBAAgB,UAAU,GAAG;AAAA,MAClC,WAAW,GAAG,oBAAoB,iBAAiB,GAAG,SAAS;AAAA,MAC/D,cAAa;AAAA,MACb,aAAa,UAAU;AAAA,QACrB,gBAAgB;AAAA,QAChB,IAAI;AAAA,QACJ,aAAa;AAAA,MACf,CAAC;AAAA,MACD,OAAO;AAAA,MACP,UAAU,CAAC,UAAU;AACnB,cAAM,QAAQ,MAAM,OAAO;AAC3B,uBAAe,KAAK;AACpB,eAAO,KAAK;AAAA,MACd;AAAA,MACA,WAAW,CAAC,UAAU;AACpB,YAAI,MAAM,QAAQ,UAAU;AAC1B,gBAAM,eAAe;AACrB,sBAAY;AAAA,QACd;AAAA,MACF;AAAA,MACC,GAAG;AAAA,MAEJ;AAAA,4BAAC,iBAAc,MAAK,QAClB,8BAAC,uBAAoB,eAAY,QAAO,QAAO,MAAK,OAAM,MAAK,GACjE;AAAA,QAEA,oBAAC,iBAAc,MAAK,SACjB,WAAC,CAAC,eACD;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,SAAS;AAAA,YACT,OAAO,UAAU;AAAA,cACf,gBAAgB;AAAA,cAChB,IAAI;AAAA,cACJ,aAAa;AAAA,YACf,CAAC;AAAA,YAED,8BAAC,cAAW,eAAY,QAAO;AAAA;AAAA,QACjC,GAEJ;AAAA;AAAA;AAAA,EACF;AAEJ,CAAC;","names":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ListMetadata, CreateUserApiKeyResponse } from '../../api/endpoint.js';
|
|
3
|
+
import '@tanstack/react-query';
|
|
4
|
+
import '../../api/widgets-api-client.js';
|
|
5
|
+
|
|
6
|
+
declare function useUserApiKeysState(initialState: UserApiKeysState): readonly [UserApiKeysState, React.ActionDispatch<[action: UserApiKeysAction]>];
|
|
7
|
+
interface UserApiKeysState {
|
|
8
|
+
searchQuery: string | null;
|
|
9
|
+
pagination: ListMetadata | null;
|
|
10
|
+
createDialogOpen: boolean;
|
|
11
|
+
createdApiKey: CreateUserApiKeyResponse | null;
|
|
12
|
+
}
|
|
13
|
+
type UserApiKeysAction = {
|
|
14
|
+
type: "INIT";
|
|
15
|
+
params: URLSearchParams;
|
|
16
|
+
} | {
|
|
17
|
+
type: "FILTER_BY_SEARCH";
|
|
18
|
+
searchQuery: string | null;
|
|
19
|
+
} | {
|
|
20
|
+
type: "SET_PAGINATION";
|
|
21
|
+
pagination: ListMetadata;
|
|
22
|
+
} | {
|
|
23
|
+
type: "RESET_PAGINATION";
|
|
24
|
+
} | {
|
|
25
|
+
type: "OPEN_CREATE_DIALOG";
|
|
26
|
+
} | {
|
|
27
|
+
type: "CLOSE_CREATE_DIALOG";
|
|
28
|
+
} | {
|
|
29
|
+
type: "SET_CREATED_API_KEY";
|
|
30
|
+
apiKey: CreateUserApiKeyResponse;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { type UserApiKeysAction, type UserApiKeysState, useUserApiKeysState };
|