@burdenoff/microfe-sandbox 2026.528.1 → 2026.528.2
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/generated/wspace-types.js +8 -0
- package/dist/generated/wspace-types.js.map +1 -0
- package/dist/sandbox/components/ExportSandboxesDialog.js +85 -84
- package/dist/sandbox/components/ExportSandboxesDialog.js.map +1 -1
- package/dist/sandbox/components/ui.js +2 -2
- package/dist/sandbox/hooks/useIsSuperAdmin.js +33 -0
- package/dist/sandbox/hooks/useIsSuperAdmin.js.map +1 -0
- package/dist/sandbox/pages/SandboxListPage.js +400 -384
- package/dist/sandbox/pages/SandboxListPage.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { Button as e, Checkbox as t, Dialog as n, DialogContent as r, DialogDescription as i, DialogFooter as a, DialogHeader as o, DialogTitle as s } from "./ui.js";
|
|
2
|
+
import { tWithFallback as c } from "../utils/i18n.js";
|
|
3
|
+
import { useSandboxEvents as l } from "../utils/sandboxEvents.js";
|
|
4
|
+
import { useRef as u, useState as d } from "react";
|
|
5
|
+
import { gql as f } from "@apollo/client";
|
|
6
|
+
import { useMutation as p, useSubscription as m } from "@apollo/client/react";
|
|
7
|
+
import { useI18n as h } from "@burdenoff/fe-libs/shared/providers/shell";
|
|
8
|
+
import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
8
9
|
//#region src/sandbox/components/ExportSandboxesDialog.tsx
|
|
9
|
-
var
|
|
10
|
+
var y = f`
|
|
10
11
|
mutation ExportSandboxes($input: ExportSandboxesInput!) {
|
|
11
12
|
exportSandboxes(input: $input) {
|
|
12
13
|
id
|
|
@@ -18,7 +19,7 @@ var d = i`
|
|
|
18
19
|
errorMessage
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
|
-
`,
|
|
22
|
+
`, b = f`
|
|
22
23
|
subscription OnSandboxExportJobChanged($workspaceId: ID!, $jobId: ID!) {
|
|
23
24
|
onSandboxExportJobChanged(workspaceId: $workspaceId, jobId: $jobId) {
|
|
24
25
|
id
|
|
@@ -31,102 +32,102 @@ var d = i`
|
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
`;
|
|
34
|
-
function
|
|
35
|
-
let { t:
|
|
36
|
-
|
|
35
|
+
function x({ workspaceId: f, open: x, onClose: S }) {
|
|
36
|
+
let { t: C } = h(), w = l(), [T, E] = d("CSV"), [D, O] = d(!1), k = u(null), [A, j] = d(!1), [M, N] = d(null), [P, { loading: F }] = p(y);
|
|
37
|
+
m(b, {
|
|
37
38
|
variables: {
|
|
38
|
-
workspaceId:
|
|
39
|
-
jobId:
|
|
39
|
+
workspaceId: f,
|
|
40
|
+
jobId: k.current
|
|
40
41
|
},
|
|
41
|
-
skip: !
|
|
42
|
+
skip: !A,
|
|
42
43
|
onData: ({ data: e }) => {
|
|
43
44
|
let t = e.data?.onSandboxExportJobChanged;
|
|
44
|
-
t &&
|
|
45
|
+
t && N(t);
|
|
45
46
|
}
|
|
46
|
-
})
|
|
47
|
-
let
|
|
48
|
-
let { data: e } = await
|
|
49
|
-
workspaceId:
|
|
50
|
-
format:
|
|
51
|
-
includeUsageEvents:
|
|
52
|
-
context: { workspaceId:
|
|
47
|
+
});
|
|
48
|
+
let I = async () => {
|
|
49
|
+
let { data: e } = await P({ variables: { input: {
|
|
50
|
+
workspaceId: f,
|
|
51
|
+
format: T,
|
|
52
|
+
includeUsageEvents: D,
|
|
53
|
+
context: { workspaceId: f }
|
|
53
54
|
} } });
|
|
54
|
-
e?.exportSandboxes && (
|
|
55
|
+
e?.exportSandboxes && (k.current = e.exportSandboxes.id, j(!0), N(e.exportSandboxes), w.sandboxExportRequested({
|
|
55
56
|
jobId: e.exportSandboxes.id,
|
|
56
|
-
format:
|
|
57
|
+
format: T
|
|
57
58
|
}));
|
|
58
|
-
},
|
|
59
|
-
return /* @__PURE__ */
|
|
60
|
-
open:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
children: /* @__PURE__ */
|
|
65
|
-
|
|
59
|
+
}, L = c(C, "sandbox.exportDialog.title", "Export sandboxes"), R = c(C, "sandbox.exportDialog.description", "Generate a downloadable snapshot of the sandboxes matching your current filters.");
|
|
60
|
+
return /* @__PURE__ */ _(n, {
|
|
61
|
+
open: x,
|
|
62
|
+
onOpenChange: (e) => {
|
|
63
|
+
e || S();
|
|
64
|
+
},
|
|
65
|
+
children: /* @__PURE__ */ v(r, {
|
|
66
|
+
"aria-label": L,
|
|
66
67
|
children: [
|
|
67
|
-
/* @__PURE__ */
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
href:
|
|
68
|
+
/* @__PURE__ */ v(o, { children: [/* @__PURE__ */ _(s, { children: L }), /* @__PURE__ */ _(i, { children: R })] }),
|
|
69
|
+
M ? /* @__PURE__ */ _("div", {
|
|
70
|
+
className: "space-y-3 text-sm text-text-secondary",
|
|
71
|
+
children: M.status === "COMPLETED" && M.downloadUrl ? /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ _("p", {
|
|
72
|
+
className: "text-status-success-text font-medium",
|
|
73
|
+
children: c(C, "sandbox.exportDialog.ready", "Export ready")
|
|
74
|
+
}), /* @__PURE__ */ _("a", {
|
|
75
|
+
href: M.downloadUrl,
|
|
75
76
|
target: "_blank",
|
|
76
77
|
rel: "noopener noreferrer",
|
|
77
|
-
className: "inline-
|
|
78
|
-
children:
|
|
79
|
-
})] }) :
|
|
80
|
-
className: "text-status-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
78
|
+
className: "inline-flex items-center rounded-md bg-status-info-bg-subtle px-3 py-1.5 text-status-info-text hover:bg-status-info-bg-default hover:text-status-info-text-inverse transition-colors",
|
|
79
|
+
children: c(C, "sandbox.exportDialog.download", "Download")
|
|
80
|
+
})] }) : M.status === "FAILED" ? /* @__PURE__ */ _("p", {
|
|
81
|
+
className: "text-status-danger-text",
|
|
82
|
+
role: "alert",
|
|
83
|
+
children: c(C, "sandbox.exportDialog.failed", `Export failed: ${M.errorMessage}`, { error: M.errorMessage ?? "unknown" })
|
|
84
|
+
}) : /* @__PURE__ */ _("p", {
|
|
85
|
+
className: "text-status-info-text",
|
|
86
|
+
children: c(C, "sandbox.exportDialog.preparing", "Preparing export…")
|
|
87
|
+
})
|
|
88
|
+
}) : /* @__PURE__ */ v("div", {
|
|
89
|
+
className: "space-y-4",
|
|
90
|
+
children: [/* @__PURE__ */ v("fieldset", { children: [/* @__PURE__ */ _("legend", {
|
|
91
|
+
className: "text-sm font-medium text-text-primary",
|
|
92
|
+
children: c(C, "sandbox.exportDialog.format.label", "Format")
|
|
93
|
+
}), /* @__PURE__ */ _("div", {
|
|
94
|
+
className: "mt-2 flex gap-4",
|
|
95
|
+
children: ["CSV", "JSON"].map((e) => /* @__PURE__ */ v("label", {
|
|
96
|
+
className: "inline-flex items-center gap-1.5 text-sm text-text-primary cursor-pointer",
|
|
97
|
+
children: [/* @__PURE__ */ _("input", {
|
|
93
98
|
type: "radio",
|
|
94
99
|
name: "format",
|
|
95
|
-
checked:
|
|
96
|
-
onChange: () =>
|
|
97
|
-
"aria-label": e
|
|
100
|
+
checked: T === e,
|
|
101
|
+
onChange: () => E(e),
|
|
102
|
+
"aria-label": e,
|
|
103
|
+
className: "accent-primary"
|
|
98
104
|
}), e]
|
|
99
105
|
}, e))
|
|
100
|
-
})] }), /* @__PURE__ */
|
|
101
|
-
className: "flex items-center gap-2 text-sm text-text-
|
|
102
|
-
children: [/* @__PURE__ */
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}), e(h, "sandbox.exportDialog.includeUsage", "Include usage events")]
|
|
106
|
+
})] }), /* @__PURE__ */ v("label", {
|
|
107
|
+
className: "flex items-center gap-2 text-sm text-text-primary cursor-pointer",
|
|
108
|
+
children: [/* @__PURE__ */ _(t, {
|
|
109
|
+
checked: D,
|
|
110
|
+
onCheckedChange: (e) => O(e === !0),
|
|
111
|
+
"aria-label": c(C, "sandbox.exportDialog.includeUsage", "Include usage events")
|
|
112
|
+
}), /* @__PURE__ */ _("span", { children: c(C, "sandbox.exportDialog.includeUsage", "Include usage events") })]
|
|
108
113
|
})]
|
|
109
114
|
}),
|
|
110
|
-
/* @__PURE__ */
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
className: "rounded-md bg-status-info-bg-default px-3 py-1.5 text-sm text-status-info-text-inverse disabled:opacity-50",
|
|
122
|
-
children: e(h, "sandbox.exportDialog.submit", "Export")
|
|
123
|
-
})]
|
|
124
|
-
})
|
|
115
|
+
/* @__PURE__ */ v(a, { children: [/* @__PURE__ */ _(e, {
|
|
116
|
+
type: "button",
|
|
117
|
+
variant: "outline",
|
|
118
|
+
onClick: S,
|
|
119
|
+
children: c(C, "sandbox.exportDialog.cancel", "Cancel")
|
|
120
|
+
}), !M && /* @__PURE__ */ _(e, {
|
|
121
|
+
type: "button",
|
|
122
|
+
onClick: I,
|
|
123
|
+
disabled: F,
|
|
124
|
+
children: c(C, "sandbox.exportDialog.submit", "Export")
|
|
125
|
+
})] })
|
|
125
126
|
]
|
|
126
127
|
})
|
|
127
128
|
});
|
|
128
129
|
}
|
|
129
130
|
//#endregion
|
|
130
|
-
export {
|
|
131
|
+
export { x as ExportSandboxesDialog };
|
|
131
132
|
|
|
132
133
|
//# sourceMappingURL=ExportSandboxesDialog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExportSandboxesDialog.js","names":[],"sources":["../../../src/sandbox/components/ExportSandboxesDialog.tsx"],"sourcesContent":["import { useState, useRef } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation, useSubscription } from '@apollo/client/react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { tWithFallback } from '../utils/i18n';\nimport { useSandboxEvents } from '../utils/sandboxEvents';\n\nconst EXPORT_MUTATION = gql`\n mutation ExportSandboxes($input: ExportSandboxesInput!) {\n exportSandboxes(input: $input) {\n id\n workspaceId\n status\n format\n downloadUrl\n expiresAt\n errorMessage\n }\n }\n`;\n\nconst EXPORT_SUBSCRIPTION = gql`\n subscription OnSandboxExportJobChanged($workspaceId: ID!, $jobId: ID!) {\n onSandboxExportJobChanged(workspaceId: $workspaceId, jobId: $jobId) {\n id\n status\n format\n rowCount\n downloadUrl\n expiresAt\n errorMessage\n }\n }\n`;\n\ntype ExportFormat = 'CSV' | 'JSON';\ntype Job = {\n id: string;\n status: 'PENDING' | 'RUNNING' | 'COMPLETED' | 'FAILED';\n format: ExportFormat;\n rowCount?: number | null;\n downloadUrl?: string | null;\n expiresAt?: string | null;\n errorMessage?: string | null;\n};\n\ninterface Props {\n workspaceId: string;\n open: boolean;\n onClose: () => void;\n}\n\nexport function ExportSandboxesDialog({ workspaceId, open, onClose }: Props) {\n const { t } = useI18n();\n const events = useSandboxEvents();\n const [format, setFormat] = useState<ExportFormat>('CSV');\n const [includeUsage, setIncludeUsage] = useState(false);\n // Job id is only read inside the subscription callback (not the render),\n // so keep it in a ref to avoid an unused-state re-render per status tick.\n const jobIdRef = useRef<string | null>(null);\n const [jobIdActive, setJobIdActive] = useState(false);\n const [job, setJob] = useState<Job | null>(null);\n\n const [trigger, { loading }] = useMutation<{ exportSandboxes: Job }>(EXPORT_MUTATION);\n\n useSubscription<{ onSandboxExportJobChanged: Job }>(EXPORT_SUBSCRIPTION, {\n variables: { workspaceId, jobId: jobIdRef.current! },\n skip: !jobIdActive,\n onData: ({ data }: { data: { data?: { onSandboxExportJobChanged?: Job } | null } }) => {\n const next = data.data?.onSandboxExportJobChanged;\n if (next) setJob(next);\n },\n });\n\n
|
|
1
|
+
{"version":3,"file":"ExportSandboxesDialog.js","names":[],"sources":["../../../src/sandbox/components/ExportSandboxesDialog.tsx"],"sourcesContent":["import { useState, useRef } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation, useSubscription } from '@apollo/client/react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { tWithFallback } from '../utils/i18n';\nimport { useSandboxEvents } from '../utils/sandboxEvents';\nimport {\n Button,\n Checkbox,\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n} from './ui';\n\nconst EXPORT_MUTATION = gql`\n mutation ExportSandboxes($input: ExportSandboxesInput!) {\n exportSandboxes(input: $input) {\n id\n workspaceId\n status\n format\n downloadUrl\n expiresAt\n errorMessage\n }\n }\n`;\n\nconst EXPORT_SUBSCRIPTION = gql`\n subscription OnSandboxExportJobChanged($workspaceId: ID!, $jobId: ID!) {\n onSandboxExportJobChanged(workspaceId: $workspaceId, jobId: $jobId) {\n id\n status\n format\n rowCount\n downloadUrl\n expiresAt\n errorMessage\n }\n }\n`;\n\ntype ExportFormat = 'CSV' | 'JSON';\ntype Job = {\n id: string;\n status: 'PENDING' | 'RUNNING' | 'COMPLETED' | 'FAILED';\n format: ExportFormat;\n rowCount?: number | null;\n downloadUrl?: string | null;\n expiresAt?: string | null;\n errorMessage?: string | null;\n};\n\ninterface Props {\n workspaceId: string;\n open: boolean;\n onClose: () => void;\n}\n\nexport function ExportSandboxesDialog({ workspaceId, open, onClose }: Props) {\n const { t } = useI18n();\n const events = useSandboxEvents();\n const [format, setFormat] = useState<ExportFormat>('CSV');\n const [includeUsage, setIncludeUsage] = useState(false);\n // Job id is only read inside the subscription callback (not the render),\n // so keep it in a ref to avoid an unused-state re-render per status tick.\n const jobIdRef = useRef<string | null>(null);\n const [jobIdActive, setJobIdActive] = useState(false);\n const [job, setJob] = useState<Job | null>(null);\n\n const [trigger, { loading }] = useMutation<{ exportSandboxes: Job }>(EXPORT_MUTATION);\n\n useSubscription<{ onSandboxExportJobChanged: Job }>(EXPORT_SUBSCRIPTION, {\n variables: { workspaceId, jobId: jobIdRef.current! },\n skip: !jobIdActive,\n onData: ({ data }: { data: { data?: { onSandboxExportJobChanged?: Job } | null } }) => {\n const next = data.data?.onSandboxExportJobChanged;\n if (next) setJob(next);\n },\n });\n\n const start = async () => {\n const { data } = await trigger({\n variables: {\n input: { workspaceId, format, includeUsageEvents: includeUsage, context: { workspaceId } },\n },\n });\n if (data?.exportSandboxes) {\n jobIdRef.current = data.exportSandboxes.id;\n setJobIdActive(true);\n setJob(data.exportSandboxes);\n events.sandboxExportRequested({ jobId: data.exportSandboxes.id, format });\n }\n };\n\n const heading = tWithFallback(t, 'sandbox.exportDialog.title', 'Export sandboxes');\n const description = tWithFallback(\n t,\n 'sandbox.exportDialog.description',\n 'Generate a downloadable snapshot of the sandboxes matching your current filters.'\n );\n\n return (\n <Dialog\n open={open}\n onOpenChange={(next) => {\n if (!next) onClose();\n }}\n >\n <DialogContent aria-label={heading}>\n <DialogHeader>\n <DialogTitle>{heading}</DialogTitle>\n <DialogDescription>{description}</DialogDescription>\n </DialogHeader>\n\n {job ? (\n <div className=\"space-y-3 text-sm text-text-secondary\">\n {job.status === 'COMPLETED' && job.downloadUrl ? (\n <>\n <p className=\"text-status-success-text font-medium\">\n {tWithFallback(t, 'sandbox.exportDialog.ready', 'Export ready')}\n </p>\n <a\n href={job.downloadUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"inline-flex items-center rounded-md bg-status-info-bg-subtle px-3 py-1.5 text-status-info-text hover:bg-status-info-bg-default hover:text-status-info-text-inverse transition-colors\"\n >\n {tWithFallback(t, 'sandbox.exportDialog.download', 'Download')}\n </a>\n </>\n ) : job.status === 'FAILED' ? (\n <p className=\"text-status-danger-text\" role=\"alert\">\n {tWithFallback(\n t,\n 'sandbox.exportDialog.failed',\n `Export failed: ${job.errorMessage}`,\n {\n error: job.errorMessage ?? 'unknown',\n }\n )}\n </p>\n ) : (\n <p className=\"text-status-info-text\">\n {tWithFallback(t, 'sandbox.exportDialog.preparing', 'Preparing export…')}\n </p>\n )}\n </div>\n ) : (\n <div className=\"space-y-4\">\n <fieldset>\n <legend className=\"text-sm font-medium text-text-primary\">\n {tWithFallback(t, 'sandbox.exportDialog.format.label', 'Format')}\n </legend>\n <div className=\"mt-2 flex gap-4\">\n {(['CSV', 'JSON'] as const).map((f) => (\n <label\n key={f}\n className=\"inline-flex items-center gap-1.5 text-sm text-text-primary cursor-pointer\"\n >\n <input\n type=\"radio\"\n name=\"format\"\n checked={format === f}\n onChange={() => setFormat(f)}\n aria-label={f}\n className=\"accent-primary\"\n />\n {f}\n </label>\n ))}\n </div>\n </fieldset>\n <label className=\"flex items-center gap-2 text-sm text-text-primary cursor-pointer\">\n <Checkbox\n checked={includeUsage}\n onCheckedChange={(checked: boolean | 'indeterminate') =>\n setIncludeUsage(checked === true)\n }\n aria-label={tWithFallback(\n t,\n 'sandbox.exportDialog.includeUsage',\n 'Include usage events'\n )}\n />\n <span>\n {tWithFallback(t, 'sandbox.exportDialog.includeUsage', 'Include usage events')}\n </span>\n </label>\n </div>\n )}\n\n <DialogFooter>\n <Button type=\"button\" variant=\"outline\" onClick={onClose}>\n {tWithFallback(t, 'sandbox.exportDialog.cancel', 'Cancel')}\n </Button>\n {!job && (\n <Button type=\"button\" onClick={start} disabled={loading}>\n {tWithFallback(t, 'sandbox.exportDialog.submit', 'Export')}\n </Button>\n )}\n </DialogFooter>\n </DialogContent>\n </Dialog>\n );\n}\n"],"mappings":";;;;;;;;;AAiBA,IAAM,IAAkB,CAAG;;;;;;;;;;;;GAcrB,IAAsB,CAAG;;;;;;;;;;;;;AA+B/B,SAAgB,EAAsB,EAAE,gBAAa,SAAM,cAAkB;C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kBAAC,GAAD;KAAQ,MAAK;KAAS,SAAS;KAAO,UAAU;eAC7C,EAAc,GAAG,+BAA+B,SAAS;KACnD,CAAA,CAEE,EAAA,CAAA;IACD;;EACT,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Badge as e, Button as t, Card as n, CardContent as r, Checkbox as i,
|
|
2
|
-
export { e as Badge, t as Button, n as Card, r as CardContent, i as Checkbox, a as
|
|
1
|
+
import { Badge as e, Button as t, Card as n, CardContent as r, Checkbox as i, Dialog as a, DialogContent as o, DialogDescription as s, DialogFooter as c, DialogHeader as l, DialogTitle as u, Input as d, Select as f, SelectContent as p, SelectItem as m, SelectTrigger as h, SelectValue as g, Skeleton as _, Switch as v } from "@burdenoff/fe-libs/ui";
|
|
2
|
+
export { e as Badge, t as Button, n as Card, r as CardContent, i as Checkbox, a as Dialog, o as DialogContent, s as DialogDescription, c as DialogFooter, l as DialogHeader, u as DialogTitle, d as Input, f as Select, p as SelectContent, m as SelectItem, h as SelectTrigger, g as SelectValue, _ as Skeleton, v as Switch };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useAuth as e } from "@burdenoff/fe-libs/shared/providers/shell/AuthProvider";
|
|
2
|
+
//#region src/sandbox/hooks/useIsSuperAdmin.ts
|
|
3
|
+
function t(e) {
|
|
4
|
+
if (!e) return {
|
|
5
|
+
role: null,
|
|
6
|
+
actorType: null
|
|
7
|
+
};
|
|
8
|
+
let t = e.split(".");
|
|
9
|
+
if (t.length !== 3) return {
|
|
10
|
+
role: null,
|
|
11
|
+
actorType: null
|
|
12
|
+
};
|
|
13
|
+
try {
|
|
14
|
+
let e = t[1].replace(/-/g, "+").replace(/_/g, "/"), n = e.padEnd(Math.ceil(e.length / 4) * 4, "="), r = JSON.parse(atob(n));
|
|
15
|
+
return {
|
|
16
|
+
role: typeof r.role == "string" ? r.role : null,
|
|
17
|
+
actorType: typeof r.actor_type == "string" ? r.actor_type : typeof r.actorType == "string" ? r.actorType : null
|
|
18
|
+
};
|
|
19
|
+
} catch {
|
|
20
|
+
return {
|
|
21
|
+
role: null,
|
|
22
|
+
actorType: null
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function n() {
|
|
27
|
+
let n = e(), r = t(n.tokens?.accessToken), i = typeof n.user?.actorType == "string" ? n.user.actorType : typeof n.user?.actor_type == "string" ? n.user.actor_type : null;
|
|
28
|
+
return n.user?.role === "SUPER_ADMIN" || n.user?.role === "super_admin" || i === "super_admin" || r.role === "SUPER_ADMIN" || r.role === "super_admin" || r.actorType === "super_admin";
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { n as useIsSuperAdmin };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=useIsSuperAdmin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIsSuperAdmin.js","names":[],"sources":["../../../src/sandbox/hooks/useIsSuperAdmin.ts"],"sourcesContent":["import { useAuth } from '@burdenoff/fe-libs/shared/providers/shell/AuthProvider';\n\ninterface JwtAccessClaims {\n role: string | null;\n actorType: string | null;\n}\n\nfunction decodeJwtAccessClaims(token: string | undefined): JwtAccessClaims {\n if (!token) return { role: null, actorType: null };\n const parts = token.split('.');\n if (parts.length !== 3) return { role: null, actorType: null };\n try {\n const base64 = parts[1].replace(/-/g, '+').replace(/_/g, '/');\n const normalized = base64.padEnd(Math.ceil(base64.length / 4) * 4, '=');\n const payload = JSON.parse(atob(normalized)) as Record<string, unknown>;\n return {\n role: typeof payload.role === 'string' ? payload.role : null,\n actorType:\n typeof payload.actor_type === 'string'\n ? payload.actor_type\n : typeof payload.actorType === 'string'\n ? payload.actorType\n : null,\n };\n } catch {\n return { role: null, actorType: null };\n }\n}\n\n/**\n * Returns true when the current actor is a super_admin. Mirrors the canonical\n * detection used by microfe-admin (`useAdminPermissions`) so the sandbox UI\n * stays in sync with the rest of the platform.\n *\n * Used to gate visibility of internal-only sandboxes on the list page. The\n * BE already prevents non-super_admin actors from seeing INTERNAL kind rows,\n * but this hook lets us hide the toggle UI for non-admins and surface the\n * filter for admins as an opt-in.\n */\nexport function useIsSuperAdmin(): boolean {\n const auth = useAuth();\n\n const jwtClaims = decodeJwtAccessClaims(auth.tokens?.accessToken);\n const userActorType =\n typeof auth.user?.actorType === 'string'\n ? auth.user.actorType\n : typeof auth.user?.actor_type === 'string'\n ? auth.user.actor_type\n : null;\n\n return (\n auth.user?.role === 'SUPER_ADMIN' ||\n auth.user?.role === 'super_admin' ||\n userActorType === 'super_admin' ||\n jwtClaims.role === 'SUPER_ADMIN' ||\n jwtClaims.role === 'super_admin' ||\n jwtClaims.actorType === 'super_admin'\n );\n}\n"],"mappings":";;AAOA,SAAS,EAAsB,GAA4C;AACzE,KAAI,CAAC,EAAO,QAAO;EAAE,MAAM;EAAM,WAAW;EAAM;CAClD,IAAM,IAAQ,EAAM,MAAM,IAAI;AAC9B,KAAI,EAAM,WAAW,EAAG,QAAO;EAAE,MAAM;EAAM,WAAW;EAAM;AAC9D,KAAI;EACF,IAAM,IAAS,EAAM,GAAG,QAAQ,MAAM,IAAI,CAAC,QAAQ,MAAM,IAAI,EACvD,IAAa,EAAO,OAAO,KAAK,KAAK,EAAO,SAAS,EAAE,GAAG,GAAG,IAAI,EACjE,IAAU,KAAK,MAAM,KAAK,EAAW,CAAC;AAC5C,SAAO;GACL,MAAM,OAAO,EAAQ,QAAS,WAAW,EAAQ,OAAO;GACxD,WACE,OAAO,EAAQ,cAAe,WAC1B,EAAQ,aACR,OAAO,EAAQ,aAAc,WAC3B,EAAQ,YACR;GACT;SACK;AACN,SAAO;GAAE,MAAM;GAAM,WAAW;GAAM;;;AAc1C,SAAgB,IAA2B;CACzC,IAAM,IAAO,GAAS,EAEhB,IAAY,EAAsB,EAAK,QAAQ,YAAY,EAC3D,IACJ,OAAO,EAAK,MAAM,aAAc,WAC5B,EAAK,KAAK,YACV,OAAO,EAAK,MAAM,cAAe,WAC/B,EAAK,KAAK,aACV;AAER,QACE,EAAK,MAAM,SAAS,iBACpB,EAAK,MAAM,SAAS,iBACpB,MAAkB,iBAClB,EAAU,SAAS,iBACnB,EAAU,SAAS,iBACnB,EAAU,cAAc"}
|