@burdenoff/microfe-sandbox 2026.623.1 → 2026.624.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/sandbox/components/ExtendTTLModal.js +57 -64
- package/dist/sandbox/components/ExtendTTLModal.js.map +1 -1
- package/dist/sandbox/components/FilesFolderPicker.js +11 -11
- package/dist/sandbox/components/FilesFolderPicker.js.map +1 -1
- package/dist/sandbox/components/PageLayout.js +4 -4
- package/dist/sandbox/components/PageLayout.js.map +1 -1
- package/dist/sandbox/components/ResourceDisplay.js +3 -3
- package/dist/sandbox/components/ResourceDisplay.js.map +1 -1
- package/dist/sandbox/components/RouteUtils.js +5 -5
- package/dist/sandbox/components/RouteUtils.js.map +1 -1
- package/dist/sandbox/components/SandboxActivityTab.js +1 -1
- package/dist/sandbox/components/SandboxActivityTab.js.map +1 -1
- package/dist/sandbox/components/SandboxAgentAppPanel.js +1 -1
- package/dist/sandbox/components/SandboxAgentAppPanel.js.map +1 -1
- package/dist/sandbox/components/SandboxScriptRunnerPanel.js +13 -13
- package/dist/sandbox/components/SandboxScriptRunnerPanel.js.map +1 -1
- package/dist/sandbox/components/StatusBadge.js +2 -2
- package/dist/sandbox/components/StatusBadge.js.map +1 -1
- package/dist/sandbox/components/TagsInput.js +1 -1
- package/dist/sandbox/components/TagsInput.js.map +1 -1
- package/dist/sandbox/pages/AdminTemplatesPage.js +93 -75
- package/dist/sandbox/pages/AdminTemplatesPage.js.map +1 -1
- package/dist/sandbox/pages/SandboxCreatePage.js +71 -71
- package/dist/sandbox/pages/SandboxCreatePage.js.map +1 -1
- package/dist/sandbox/pages/SandboxDetailPage.js +46 -46
- package/dist/sandbox/pages/SandboxDetailPage.js.map +1 -1
- package/dist/sandbox/pages/SandboxListPage.js +229 -213
- package/dist/sandbox/pages/SandboxListPage.js.map +1 -1
- package/dist/sandbox/pages/TemplateDetailPage.js +33 -33
- package/dist/sandbox/pages/TemplateDetailPage.js.map +1 -1
- package/dist/sandbox/pages/UserTemplatesPage.js +2 -2
- package/dist/sandbox/pages/UserTemplatesPage.js.map +1 -1
- package/package.json +1 -1
|
@@ -77,7 +77,7 @@ function E({ sandbox: m, workspaceId: E }) {
|
|
|
77
77
|
children: /* @__PURE__ */ C("h3", {
|
|
78
78
|
className: "flex items-center gap-2 font-semibold",
|
|
79
79
|
children: [/* @__PURE__ */ S("div", {
|
|
80
|
-
className: "rounded-lg bg-primary/10 p-1.5",
|
|
80
|
+
className: "rounded-lg bg-action-primary-bg/10 p-1.5",
|
|
81
81
|
children: /* @__PURE__ */ S(v, {
|
|
82
82
|
size: 14,
|
|
83
83
|
className: "text-primary"
|
|
@@ -86,7 +86,7 @@ function E({ sandbox: m, workspaceId: E }) {
|
|
|
86
86
|
})
|
|
87
87
|
}),
|
|
88
88
|
/* @__PURE__ */ S("p", {
|
|
89
|
-
className: "mb-3 text-sm text-
|
|
89
|
+
className: "mb-3 text-sm text-text-secondary",
|
|
90
90
|
children: A("sandbox.detail.scriptRunner.subtitle", "Run an AI-generated script in this isolated sandbox and review the output before promoting it to the real target.")
|
|
91
91
|
}),
|
|
92
92
|
!V && /* @__PURE__ */ C("div", {
|
|
@@ -101,7 +101,7 @@ function E({ sandbox: m, workspaceId: E }) {
|
|
|
101
101
|
children: [/* @__PURE__ */ S("select", {
|
|
102
102
|
value: F,
|
|
103
103
|
onChange: (e) => I(e.target.value),
|
|
104
|
-
className: "rounded-lg border bg-
|
|
104
|
+
className: "rounded-lg border bg-bg-surface px-2 py-1 font-mono text-xs",
|
|
105
105
|
children: w.map((e) => /* @__PURE__ */ S("option", {
|
|
106
106
|
value: e,
|
|
107
107
|
children: e
|
|
@@ -110,7 +110,7 @@ function E({ sandbox: m, workspaceId: E }) {
|
|
|
110
110
|
value: L,
|
|
111
111
|
onChange: (e) => R(e.target.value),
|
|
112
112
|
placeholder: A("sandbox.detail.scriptRunner.labelPlaceholder", "Label (optional)"),
|
|
113
|
-
className: "flex-1 rounded-lg border bg-
|
|
113
|
+
className: "flex-1 rounded-lg border bg-bg-surface px-2 py-1 text-xs"
|
|
114
114
|
})]
|
|
115
115
|
}),
|
|
116
116
|
/* @__PURE__ */ S("textarea", {
|
|
@@ -118,7 +118,7 @@ function E({ sandbox: m, workspaceId: E }) {
|
|
|
118
118
|
onChange: (e) => P(e.target.value),
|
|
119
119
|
spellCheck: !1,
|
|
120
120
|
placeholder: A("sandbox.detail.scriptRunner.placeholder", "# Paste the AI-generated script here, then Run to test it in the sandbox"),
|
|
121
|
-
className: "h-40 w-full resize-y rounded-lg border bg-
|
|
121
|
+
className: "h-40 w-full resize-y rounded-lg border bg-bg-surface p-3 font-mono text-xs"
|
|
122
122
|
}),
|
|
123
123
|
/* @__PURE__ */ S("div", {
|
|
124
124
|
className: "flex justify-end",
|
|
@@ -132,7 +132,7 @@ function E({ sandbox: m, workspaceId: E }) {
|
|
|
132
132
|
})
|
|
133
133
|
}),
|
|
134
134
|
K && /* @__PURE__ */ C("div", {
|
|
135
|
-
className: "flex items-center gap-2 rounded-lg bg-
|
|
135
|
+
className: "flex items-center gap-2 rounded-lg bg-status-error-bg/10 px-3 py-2 text-sm text-status-error-text",
|
|
136
136
|
children: [/* @__PURE__ */ S(y, { size: 14 }), K.message]
|
|
137
137
|
})
|
|
138
138
|
]
|
|
@@ -147,7 +147,7 @@ function E({ sandbox: m, workspaceId: E }) {
|
|
|
147
147
|
Y.length > 0 && /* @__PURE__ */ C("div", {
|
|
148
148
|
className: "mt-4",
|
|
149
149
|
children: [/* @__PURE__ */ S("h4", {
|
|
150
|
-
className: "mb-2 text-xs font-semibold uppercase text-
|
|
150
|
+
className: "mb-2 text-xs font-semibold uppercase text-text-secondary",
|
|
151
151
|
children: A("sandbox.detail.scriptRunner.history", "Run history")
|
|
152
152
|
}), /* @__PURE__ */ S("ul", {
|
|
153
153
|
className: "divide-y rounded-lg border",
|
|
@@ -170,7 +170,7 @@ function E({ sandbox: m, workspaceId: E }) {
|
|
|
170
170
|
}),
|
|
171
171
|
n.label ? ` · ${n.label}` : "",
|
|
172
172
|
/* @__PURE__ */ S("span", {
|
|
173
|
-
className: "ml-1 text-xs text-
|
|
173
|
+
className: "ml-1 text-xs text-text-secondary",
|
|
174
174
|
children: new Date(n.createdAt).toLocaleString()
|
|
175
175
|
})
|
|
176
176
|
]
|
|
@@ -204,16 +204,16 @@ function D({ status: t, exitCode: n, tr: r }) {
|
|
|
204
204
|
className: "gap-1 bg-green-500/10 text-green-600",
|
|
205
205
|
children: [/* @__PURE__ */ S(m, { size: 12 }), r("sandbox.detail.scriptRunner.status.succeeded", "Succeeded")]
|
|
206
206
|
}) : /* @__PURE__ */ C(e, {
|
|
207
|
-
className: "gap-1 bg-
|
|
207
|
+
className: "gap-1 bg-status-error-bg/10 text-status-error-text",
|
|
208
208
|
children: [/* @__PURE__ */ S(y, { size: 12 }), t === "error" ? r("sandbox.detail.scriptRunner.status.error", "Error") : `${r("sandbox.detail.scriptRunner.status.failed", "Failed")}${n == null ? "" : ` (${n})`}`]
|
|
209
209
|
});
|
|
210
210
|
}
|
|
211
211
|
function O({ run: e, tr: t }) {
|
|
212
212
|
return /* @__PURE__ */ C("div", {
|
|
213
|
-
className: "rounded-lg border bg-
|
|
213
|
+
className: "rounded-lg border bg-bg-sunken/30 p-3",
|
|
214
214
|
children: [
|
|
215
215
|
/* @__PURE__ */ C("div", {
|
|
216
|
-
className: "mb-2 flex items-center gap-2 text-xs text-
|
|
216
|
+
className: "mb-2 flex items-center gap-2 text-xs text-text-secondary",
|
|
217
217
|
children: [/* @__PURE__ */ S(D, {
|
|
218
218
|
status: e.status,
|
|
219
219
|
exitCode: e.exitCode,
|
|
@@ -225,11 +225,11 @@ function O({ run: e, tr: t }) {
|
|
|
225
225
|
children: e.stdout
|
|
226
226
|
}),
|
|
227
227
|
e.stderr && /* @__PURE__ */ S("pre", {
|
|
228
|
-
className: "mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-words font-mono text-xs text-
|
|
228
|
+
className: "mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-words font-mono text-xs text-status-error-text",
|
|
229
229
|
children: e.stderr
|
|
230
230
|
}),
|
|
231
231
|
!e.stdout && !e.stderr && /* @__PURE__ */ S("p", {
|
|
232
|
-
className: "text-xs text-
|
|
232
|
+
className: "text-xs text-text-secondary",
|
|
233
233
|
children: t("sandbox.detail.scriptRunner.noOutput", "(no output)")
|
|
234
234
|
})
|
|
235
235
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SandboxScriptRunnerPanel.js","names":[],"sources":["../../../src/sandbox/components/SandboxScriptRunnerPanel.tsx"],"sourcesContent":["import { useState, useEffect, useCallback, useMemo } from 'react';\nimport { useSearchParams } from 'react-router-dom';\nimport {\n Terminal,\n Play,\n Loader2,\n CheckCircle2,\n XCircle,\n AlertCircle,\n ArrowUpCircle,\n ShieldCheck,\n} from 'lucide-react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell';\n\nimport { Button, Card, CardContent, Badge } from './ui';\nimport { tWithFallback } from '../utils/i18n';\nimport {\n useSandboxScriptRunsQuery,\n useRunSandboxScriptMutation,\n usePromoteSandboxScriptRunMutation,\n type SandboxScriptRunFieldsFragment,\n} from '../../generated/wspace-operations';\n\nconst INTERPRETERS = ['bash', 'sh', 'python', 'node'] as const;\n\nfunction decodeSeed(raw: string | null): string {\n if (!raw) return '';\n try {\n // Accept base64 (used by deep-links, e.g. the assistant's \"Send to Sandbox\") or plain text.\n return atob(raw);\n } catch {\n return raw;\n }\n}\n\n/**\n * SandboxScriptRunnerPanel — the sandbox-safe-execution review surface. Paste (or deep-link in via\n * `?script=<base64>`) an AI-generated script, run it inside this isolated sandbox, and review the\n * captured stdout/stderr/exit code. Each run is recorded; a run that succeeded can be promoted to the\n * real target, which stamps the sign-off onto the same record. The sandbox must be running.\n */\nexport function SandboxScriptRunnerPanel({\n sandbox,\n workspaceId,\n}: {\n sandbox: { id: string; status?: string | null };\n workspaceId: string;\n}): React.ReactElement {\n const { t } = useI18n();\n const tr = (key: string, fallback: string): string => tWithFallback(t, key, fallback);\n const [searchParams, setSearchParams] = useSearchParams();\n\n const [script, setScript] = useState<string>(() => decodeSeed(searchParams.get('script')));\n const [interpreter, setInterpreter] = useState<(typeof INTERPRETERS)[number]>('bash');\n const [label, setLabel] = useState('');\n const [activeRunId, setActiveRunId] = useState<string | null>(null);\n\n const isRunning = sandbox.status === 'RUNNING';\n\n const { data, refetch } = useSandboxScriptRunsQuery({\n variables: { sandboxId: sandbox.id, context: { workspaceId } },\n skip: !workspaceId,\n fetchPolicy: 'cache-and-network',\n });\n const [runScript, { loading: running, error: runError }] = useRunSandboxScriptMutation();\n const [promote, { loading: promoting }] = usePromoteSandboxScriptRunMutation();\n\n const runs = useMemo<SandboxScriptRunFieldsFragment[]>(\n () => data?.sandboxScriptRuns ?? [],\n [data]\n );\n const activeRun = runs.find((r) => r.id === activeRunId) ?? runs[0] ?? null;\n\n // One-shot: if we were deep-linked with a script, clear it from the URL so a refresh doesn't re-seed.\n useEffect(() => {\n if (searchParams.get('script')) {\n const next = new URLSearchParams(searchParams);\n next.delete('script');\n setSearchParams(next, { replace: true });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const handleRun = useCallback(async () => {\n if (!script.trim() || !isRunning) return;\n try {\n const res = await runScript({\n variables: {\n input: {\n sandboxId: sandbox.id,\n script,\n interpreter,\n label: label.trim() || null,\n context: { workspaceId },\n },\n },\n });\n const created = res.data?.runSandboxScript;\n if (created) setActiveRunId(created.id);\n await refetch();\n } catch {\n // surfaced via runError below\n }\n }, [script, isRunning, runScript, sandbox.id, interpreter, label, workspaceId, refetch]);\n\n const handlePromote = useCallback(\n async (runId: string) => {\n try {\n await promote({ variables: { id: runId, note: null, context: { workspaceId } } });\n await refetch();\n } catch {\n // surfaced inline on the run row via refetch\n }\n },\n [promote, workspaceId, refetch]\n );\n\n return (\n <Card>\n <CardContent className=\"p-5\">\n <div className=\"mb-4 flex items-center justify-between\">\n <h3 className=\"flex items-center gap-2 font-semibold\">\n <div className=\"rounded-lg bg-primary/10 p-1.5\">\n <Terminal size={14} className=\"text-primary\" />\n </div>\n {tr('sandbox.detail.scriptRunner.title', 'Script Runner')}\n </h3>\n </div>\n <p className=\"mb-3 text-sm text-muted-foreground\">\n {tr(\n 'sandbox.detail.scriptRunner.subtitle',\n 'Run an AI-generated script in this isolated sandbox and review the output before promoting it to the real target.'\n )}\n </p>\n\n {!isRunning && (\n <div className=\"mb-3 flex items-center gap-2 rounded-lg bg-amber-500/10 px-3 py-2 text-sm text-amber-600\">\n <AlertCircle size={14} />\n {tr(\n 'sandbox.detail.scriptRunner.notRunning',\n 'The sandbox must be running to execute a script.'\n )}\n </div>\n )}\n\n <div className=\"space-y-3\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <select\n value={interpreter}\n onChange={(e) => setInterpreter(e.target.value as (typeof INTERPRETERS)[number])}\n className=\"rounded-lg border bg-background px-2 py-1 font-mono text-xs\"\n >\n {INTERPRETERS.map((i) => (\n <option key={i} value={i}>\n {i}\n </option>\n ))}\n </select>\n <input\n value={label}\n onChange={(e) => setLabel(e.target.value)}\n placeholder={tr('sandbox.detail.scriptRunner.labelPlaceholder', 'Label (optional)')}\n className=\"flex-1 rounded-lg border bg-background px-2 py-1 text-xs\"\n />\n </div>\n <textarea\n value={script}\n onChange={(e) => setScript(e.target.value)}\n spellCheck={false}\n placeholder={tr(\n 'sandbox.detail.scriptRunner.placeholder',\n '# Paste the AI-generated script here, then Run to test it in the sandbox'\n )}\n className=\"h-40 w-full resize-y rounded-lg border bg-background p-3 font-mono text-xs\"\n />\n <div className=\"flex justify-end\">\n <Button\n onClick={() => void handleRun()}\n disabled={!isRunning || running || !script.trim()}\n >\n {running ? <Loader2 size={14} className=\"animate-spin\" /> : <Play size={14} />}\n {tr('sandbox.detail.scriptRunner.run', 'Run in sandbox')}\n </Button>\n </div>\n {runError && (\n <div className=\"flex items-center gap-2 rounded-lg bg-destructive/10 px-3 py-2 text-sm text-destructive\">\n <XCircle size={14} />\n {runError.message}\n </div>\n )}\n </div>\n\n {activeRun && (\n <div className=\"mt-4\">\n <RunOutput run={activeRun} tr={tr} />\n </div>\n )}\n\n {runs.length > 0 && (\n <div className=\"mt-4\">\n <h4 className=\"mb-2 text-xs font-semibold uppercase text-muted-foreground\">\n {tr('sandbox.detail.scriptRunner.history', 'Run history')}\n </h4>\n <ul className=\"divide-y rounded-lg border\">\n {runs.map((r) => (\n <li key={r.id} className=\"flex items-center gap-3 px-3 py-2 text-sm\">\n <RunStatusBadge status={r.status} exitCode={r.exitCode} tr={tr} />\n <button\n type=\"button\"\n onClick={() => setActiveRunId(r.id)}\n className=\"min-w-0 flex-1 truncate text-left hover:underline\"\n >\n <span className=\"font-mono text-xs\">{r.interpreter}</span>\n {r.label ? ` · ${r.label}` : ''}\n <span className=\"ml-1 text-xs text-muted-foreground\">\n {new Date(r.createdAt as unknown as string).toLocaleString()}\n </span>\n </button>\n {r.promotedAt ? (\n <Badge className=\"shrink-0 gap-1 bg-green-500/10 text-green-600\">\n <ShieldCheck size={12} />\n {tr('sandbox.detail.scriptRunner.promoted', 'Promoted')}\n </Badge>\n ) : (\n r.status === 'succeeded' && (\n <Button\n variant=\"outline\"\n onClick={() => void handlePromote(r.id)}\n disabled={promoting}\n className=\"shrink-0\"\n title={tr(\n 'sandbox.detail.scriptRunner.promoteTitle',\n 'Sign off this reviewed run for the real target'\n )}\n >\n <ArrowUpCircle size={12} />\n {tr('sandbox.detail.scriptRunner.promote', 'Promote')}\n </Button>\n )\n )}\n </li>\n ))}\n </ul>\n </div>\n )}\n </CardContent>\n </Card>\n );\n}\n\nfunction RunStatusBadge({\n status,\n exitCode,\n tr,\n}: {\n status: string;\n exitCode?: number | null;\n tr: (k: string, f: string) => string;\n}): React.ReactElement {\n if (status === 'running') {\n return (\n <Badge className=\"gap-1 bg-blue-500/10 text-blue-600\">\n <Loader2 size={12} className=\"animate-spin\" />\n {tr('sandbox.detail.scriptRunner.status.running', 'Running')}\n </Badge>\n );\n }\n if (status === 'succeeded') {\n return (\n <Badge className=\"gap-1 bg-green-500/10 text-green-600\">\n <CheckCircle2 size={12} />\n {tr('sandbox.detail.scriptRunner.status.succeeded', 'Succeeded')}\n </Badge>\n );\n }\n return (\n <Badge className=\"gap-1 bg-destructive/10 text-destructive\">\n <XCircle size={12} />\n {status === 'error'\n ? tr('sandbox.detail.scriptRunner.status.error', 'Error')\n : `${tr('sandbox.detail.scriptRunner.status.failed', 'Failed')}${\n exitCode != null ? ` (${exitCode})` : ''\n }`}\n </Badge>\n );\n}\n\nfunction RunOutput({\n run,\n tr,\n}: {\n run: SandboxScriptRunFieldsFragment;\n tr: (k: string, f: string) => string;\n}): React.ReactElement {\n return (\n <div className=\"rounded-lg border bg-muted/30 p-3\">\n <div className=\"mb-2 flex items-center gap-2 text-xs text-muted-foreground\">\n <RunStatusBadge status={run.status} exitCode={run.exitCode} tr={tr} />\n {run.durationMs != null && <span>{run.durationMs} ms</span>}\n </div>\n {run.stdout && (\n <pre className=\"max-h-64 overflow-auto whitespace-pre-wrap break-words font-mono text-xs\">\n {run.stdout}\n </pre>\n )}\n {run.stderr && (\n <pre className=\"mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-words font-mono text-xs text-destructive\">\n {run.stderr}\n </pre>\n )}\n {!run.stdout && !run.stderr && (\n <p className=\"text-xs text-muted-foreground\">\n {tr('sandbox.detail.scriptRunner.noOutput', '(no output)')}\n </p>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAuBA,IAAM,IAAe;CAAC;CAAQ;CAAM;CAAU;CAAO;AAErD,SAAS,EAAW,GAA4B;AAC9C,KAAI,CAAC,EAAK,QAAO;AACjB,KAAI;AAEF,SAAO,KAAK,EAAI;SACV;AACN,SAAO;;;AAUX,SAAgB,EAAyB,EACvC,YACA,kBAIqB;CACrB,IAAM,EAAE,SAAM,GAAS,EACjB,KAAM,GAAa,MAA6B,EAAc,GAAG,GAAK,EAAS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ScriptRunnerPanel.tsx"],"sourcesContent":["import { useState, useEffect, useCallback, useMemo } from 'react';\nimport { useSearchParams } from 'react-router-dom';\nimport {\n Terminal,\n Play,\n Loader2,\n CheckCircle2,\n XCircle,\n AlertCircle,\n ArrowUpCircle,\n ShieldCheck,\n} from 'lucide-react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell';\n\nimport { Button, Card, CardContent, Badge } from './ui';\nimport { tWithFallback } from '../utils/i18n';\nimport {\n useSandboxScriptRunsQuery,\n useRunSandboxScriptMutation,\n usePromoteSandboxScriptRunMutation,\n type SandboxScriptRunFieldsFragment,\n} from '../../generated/wspace-operations';\n\nconst INTERPRETERS = ['bash', 'sh', 'python', 'node'] as const;\n\nfunction decodeSeed(raw: string | null): string {\n if (!raw) return '';\n try {\n // Accept base64 (used by deep-links, e.g. the assistant's \"Send to Sandbox\") or plain text.\n return atob(raw);\n } catch {\n return raw;\n }\n}\n\n/**\n * SandboxScriptRunnerPanel — the sandbox-safe-execution review surface. Paste (or deep-link in via\n * `?script=<base64>`) an AI-generated script, run it inside this isolated sandbox, and review the\n * captured stdout/stderr/exit code. Each run is recorded; a run that succeeded can be promoted to the\n * real target, which stamps the sign-off onto the same record. The sandbox must be running.\n */\nexport function SandboxScriptRunnerPanel({\n sandbox,\n workspaceId,\n}: {\n sandbox: { id: string; status?: string | null };\n workspaceId: string;\n}): React.ReactElement {\n const { t } = useI18n();\n const tr = (key: string, fallback: string): string => tWithFallback(t, key, fallback);\n const [searchParams, setSearchParams] = useSearchParams();\n\n const [script, setScript] = useState<string>(() => decodeSeed(searchParams.get('script')));\n const [interpreter, setInterpreter] = useState<(typeof INTERPRETERS)[number]>('bash');\n const [label, setLabel] = useState('');\n const [activeRunId, setActiveRunId] = useState<string | null>(null);\n\n const isRunning = sandbox.status === 'RUNNING';\n\n const { data, refetch } = useSandboxScriptRunsQuery({\n variables: { sandboxId: sandbox.id, context: { workspaceId } },\n skip: !workspaceId,\n fetchPolicy: 'cache-and-network',\n });\n const [runScript, { loading: running, error: runError }] = useRunSandboxScriptMutation();\n const [promote, { loading: promoting }] = usePromoteSandboxScriptRunMutation();\n\n const runs = useMemo<SandboxScriptRunFieldsFragment[]>(\n () => data?.sandboxScriptRuns ?? [],\n [data]\n );\n const activeRun = runs.find((r) => r.id === activeRunId) ?? runs[0] ?? null;\n\n // One-shot: if we were deep-linked with a script, clear it from the URL so a refresh doesn't re-seed.\n useEffect(() => {\n if (searchParams.get('script')) {\n const next = new URLSearchParams(searchParams);\n next.delete('script');\n setSearchParams(next, { replace: true });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const handleRun = useCallback(async () => {\n if (!script.trim() || !isRunning) return;\n try {\n const res = await runScript({\n variables: {\n input: {\n sandboxId: sandbox.id,\n script,\n interpreter,\n label: label.trim() || null,\n context: { workspaceId },\n },\n },\n });\n const created = res.data?.runSandboxScript;\n if (created) setActiveRunId(created.id);\n await refetch();\n } catch {\n // surfaced via runError below\n }\n }, [script, isRunning, runScript, sandbox.id, interpreter, label, workspaceId, refetch]);\n\n const handlePromote = useCallback(\n async (runId: string) => {\n try {\n await promote({ variables: { id: runId, note: null, context: { workspaceId } } });\n await refetch();\n } catch {\n // surfaced inline on the run row via refetch\n }\n },\n [promote, workspaceId, refetch]\n );\n\n return (\n <Card>\n <CardContent className=\"p-5\">\n <div className=\"mb-4 flex items-center justify-between\">\n <h3 className=\"flex items-center gap-2 font-semibold\">\n <div className=\"rounded-lg bg-action-primary-bg/10 p-1.5\">\n <Terminal size={14} className=\"text-primary\" />\n </div>\n {tr('sandbox.detail.scriptRunner.title', 'Script Runner')}\n </h3>\n </div>\n <p className=\"mb-3 text-sm text-text-secondary\">\n {tr(\n 'sandbox.detail.scriptRunner.subtitle',\n 'Run an AI-generated script in this isolated sandbox and review the output before promoting it to the real target.'\n )}\n </p>\n\n {!isRunning && (\n <div className=\"mb-3 flex items-center gap-2 rounded-lg bg-amber-500/10 px-3 py-2 text-sm text-amber-600\">\n <AlertCircle size={14} />\n {tr(\n 'sandbox.detail.scriptRunner.notRunning',\n 'The sandbox must be running to execute a script.'\n )}\n </div>\n )}\n\n <div className=\"space-y-3\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <select\n value={interpreter}\n onChange={(e) => setInterpreter(e.target.value as (typeof INTERPRETERS)[number])}\n className=\"rounded-lg border bg-bg-surface px-2 py-1 font-mono text-xs\"\n >\n {INTERPRETERS.map((i) => (\n <option key={i} value={i}>\n {i}\n </option>\n ))}\n </select>\n <input\n value={label}\n onChange={(e) => setLabel(e.target.value)}\n placeholder={tr('sandbox.detail.scriptRunner.labelPlaceholder', 'Label (optional)')}\n className=\"flex-1 rounded-lg border bg-bg-surface px-2 py-1 text-xs\"\n />\n </div>\n <textarea\n value={script}\n onChange={(e) => setScript(e.target.value)}\n spellCheck={false}\n placeholder={tr(\n 'sandbox.detail.scriptRunner.placeholder',\n '# Paste the AI-generated script here, then Run to test it in the sandbox'\n )}\n className=\"h-40 w-full resize-y rounded-lg border bg-bg-surface p-3 font-mono text-xs\"\n />\n <div className=\"flex justify-end\">\n <Button\n onClick={() => void handleRun()}\n disabled={!isRunning || running || !script.trim()}\n >\n {running ? <Loader2 size={14} className=\"animate-spin\" /> : <Play size={14} />}\n {tr('sandbox.detail.scriptRunner.run', 'Run in sandbox')}\n </Button>\n </div>\n {runError && (\n <div className=\"flex items-center gap-2 rounded-lg bg-status-error-bg/10 px-3 py-2 text-sm text-status-error-text\">\n <XCircle size={14} />\n {runError.message}\n </div>\n )}\n </div>\n\n {activeRun && (\n <div className=\"mt-4\">\n <RunOutput run={activeRun} tr={tr} />\n </div>\n )}\n\n {runs.length > 0 && (\n <div className=\"mt-4\">\n <h4 className=\"mb-2 text-xs font-semibold uppercase text-text-secondary\">\n {tr('sandbox.detail.scriptRunner.history', 'Run history')}\n </h4>\n <ul className=\"divide-y rounded-lg border\">\n {runs.map((r) => (\n <li key={r.id} className=\"flex items-center gap-3 px-3 py-2 text-sm\">\n <RunStatusBadge status={r.status} exitCode={r.exitCode} tr={tr} />\n <button\n type=\"button\"\n onClick={() => setActiveRunId(r.id)}\n className=\"min-w-0 flex-1 truncate text-left hover:underline\"\n >\n <span className=\"font-mono text-xs\">{r.interpreter}</span>\n {r.label ? ` · ${r.label}` : ''}\n <span className=\"ml-1 text-xs text-text-secondary\">\n {new Date(r.createdAt as unknown as string).toLocaleString()}\n </span>\n </button>\n {r.promotedAt ? (\n <Badge className=\"shrink-0 gap-1 bg-green-500/10 text-green-600\">\n <ShieldCheck size={12} />\n {tr('sandbox.detail.scriptRunner.promoted', 'Promoted')}\n </Badge>\n ) : (\n r.status === 'succeeded' && (\n <Button\n variant=\"outline\"\n onClick={() => void handlePromote(r.id)}\n disabled={promoting}\n className=\"shrink-0\"\n title={tr(\n 'sandbox.detail.scriptRunner.promoteTitle',\n 'Sign off this reviewed run for the real target'\n )}\n >\n <ArrowUpCircle size={12} />\n {tr('sandbox.detail.scriptRunner.promote', 'Promote')}\n </Button>\n )\n )}\n </li>\n ))}\n </ul>\n </div>\n )}\n </CardContent>\n </Card>\n );\n}\n\nfunction RunStatusBadge({\n status,\n exitCode,\n tr,\n}: {\n status: string;\n exitCode?: number | null;\n tr: (k: string, f: string) => string;\n}): React.ReactElement {\n if (status === 'running') {\n return (\n <Badge className=\"gap-1 bg-blue-500/10 text-blue-600\">\n <Loader2 size={12} className=\"animate-spin\" />\n {tr('sandbox.detail.scriptRunner.status.running', 'Running')}\n </Badge>\n );\n }\n if (status === 'succeeded') {\n return (\n <Badge className=\"gap-1 bg-green-500/10 text-green-600\">\n <CheckCircle2 size={12} />\n {tr('sandbox.detail.scriptRunner.status.succeeded', 'Succeeded')}\n </Badge>\n );\n }\n return (\n <Badge className=\"gap-1 bg-status-error-bg/10 text-status-error-text\">\n <XCircle size={12} />\n {status === 'error'\n ? tr('sandbox.detail.scriptRunner.status.error', 'Error')\n : `${tr('sandbox.detail.scriptRunner.status.failed', 'Failed')}${\n exitCode != null ? ` (${exitCode})` : ''\n }`}\n </Badge>\n );\n}\n\nfunction RunOutput({\n run,\n tr,\n}: {\n run: SandboxScriptRunFieldsFragment;\n tr: (k: string, f: string) => string;\n}): React.ReactElement {\n return (\n <div className=\"rounded-lg border bg-bg-sunken/30 p-3\">\n <div className=\"mb-2 flex items-center gap-2 text-xs text-text-secondary\">\n <RunStatusBadge status={run.status} exitCode={run.exitCode} tr={tr} />\n {run.durationMs != null && <span>{run.durationMs} ms</span>}\n </div>\n {run.stdout && (\n <pre className=\"max-h-64 overflow-auto whitespace-pre-wrap break-words font-mono text-xs\">\n {run.stdout}\n </pre>\n )}\n {run.stderr && (\n <pre className=\"mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-words font-mono text-xs text-status-error-text\">\n {run.stderr}\n </pre>\n )}\n {!run.stdout && !run.stderr && (\n <p className=\"text-xs text-text-secondary\">\n {tr('sandbox.detail.scriptRunner.noOutput', '(no output)')}\n </p>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAuBA,IAAM,IAAe;CAAC;CAAQ;CAAM;CAAU;CAAO;AAErD,SAAS,EAAW,GAA4B;AAC9C,KAAI,CAAC,EAAK,QAAO;AACjB,KAAI;AAEF,SAAO,KAAK,EAAI;SACV;AACN,SAAO;;;AAUX,SAAgB,EAAyB,EACvC,YACA,kBAIqB;CACrB,IAAM,EAAE,SAAM,GAAS,EACjB,KAAM,GAAa,MAA6B,EAAc,GAAG,GAAK,EAAS,EAC/E,CAAC,GAAc,KAAmB,GAAiB,EAEnD,CAAC,GAAQ,KAAa,QAAuB,EAAW,EAAa,IAAI,SAAS,CAAC,CAAC,EACpF,CAAC,GAAa,KAAkB,EAAwC,OAAO,EAC/E,CAAC,GAAO,KAAY,EAAS,GAAG,EAChC,CAAC,GAAa,KAAkB,EAAwB,KAAK,EAE7D,IAAY,EAAQ,WAAW,WAE/B,EAAE,SAAM,eAAY,EAA0B;EAClD,WAAW;GAAE,WAAW,EAAQ;GAAI,SAAS,EAAE,gBAAa;GA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AO,WAAU;YAAjB,CACE,kBAAC,GAAD,EAAc,MAAM,IAAM,CAAA,EACzB,EAAG,gDAAgD,YAAY,CAC1D;MAIV,kBAAC,GAAD;EAAO,WAAU;YAAjB,CACE,kBAAC,GAAD,EAAS,MAAM,IAAM,CAAA,EACpB,MAAW,UACR,EAAG,4CAA4C,QAAQ,GACvD,GAAG,EAAG,6CAA6C,SAAS,GAC1D,KAAY,OAA0B,KAAnB,KAAK,EAAS,KAEjC;;;AAIZ,SAAS,EAAU,EACjB,QACA,SAIqB;AACrB,QACE,kBAAC,OAAD;EAAK,WAAU;YAAf;GACE,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,GAAD;KAAgB,QAAQ,EAAI;KAAQ,UAAU,EAAI;KAAc;KAAM,CAAA,EACrE,EAAI,cAAc,QAAQ,kBAAC,QAAD,EAAA,UAAA,CAAO,EAAI,YAAW,MAAU,EAAA,CAAA,CACvD;;GACL,EAAI,UACH,kBAAC,OAAD;IAAK,WAAU;cACZ,EAAI;IACD,CAAA;GAEP,EAAI,UACH,kBAAC,OAAD;IAAK,WAAU;cACZ,EAAI;IACD,CAAA;GAEP,CAAC,EAAI,UAAU,CAAC,EAAI,UACnB,kBAAC,KAAD;IAAG,WAAU;cACV,EAAG,wCAAwC,cAAc;IACxD,CAAA;GAEF"}
|
|
@@ -56,8 +56,8 @@ var p = {
|
|
|
56
56
|
}, m = ({ status: n, className: r, showIcon: a = !0, size: o = "sm" }) => {
|
|
57
57
|
let { t: s } = u(), c = p[n] || {
|
|
58
58
|
label: n,
|
|
59
|
-
color: "text-
|
|
60
|
-
bg: "bg-
|
|
59
|
+
color: "text-text-secondary",
|
|
60
|
+
bg: "bg-bg-sunken border-border-subtle",
|
|
61
61
|
icon: i
|
|
62
62
|
}, l = c.icon, m = n === "PROVISIONING" || n === "STOPPING", h = {
|
|
63
63
|
PENDING: t(s, "sandbox.status.pending", "Pending"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatusBadge.js","names":[],"sources":["../../../src/sandbox/components/StatusBadge.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport {\n Clock,\n Loader2,\n CheckCircle2,\n StopCircle,\n AlertTriangle,\n TimerOff,\n XCircle,\n Circle,\n} from 'lucide-react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { cn } from '../utils/cn';\nimport type { SandboxStatus } from '../types';\nimport { tWithFallback } from '../utils/i18n';\n\ninterface StatusBadgeProps {\n status: SandboxStatus;\n className?: string;\n showIcon?: boolean;\n size?: 'sm' | 'md';\n}\n\nconst statusConfig: Record<\n SandboxStatus,\n { label: string; color: string; bg: string; icon: FC<{ size?: number; className?: string }> }\n> = {\n PENDING: {\n label: 'Pending',\n color: 'text-status-warning-text',\n bg: 'bg-status-warning-bg-subtle border-border-default',\n icon: Clock,\n },\n PROVISIONING: {\n label: 'Provisioning',\n color: 'text-status-info-text',\n bg: 'bg-status-info-bg-subtle border-border-default',\n icon: Loader2,\n },\n RUNNING: {\n label: 'Running',\n color: 'text-status-success-text',\n bg: 'bg-status-success-bg-subtle border-border-default',\n icon: CheckCircle2,\n },\n STOPPING: {\n label: 'Stopping',\n color: 'text-accent-orange',\n bg: 'bg-accent-orange-subtle border-border-default',\n icon: Loader2,\n },\n STOPPED: {\n label: 'Stopped',\n color: 'text-text-secondary',\n bg: 'bg-bg-sunken border-border-default',\n icon: StopCircle,\n },\n ERROR: {\n label: 'Error',\n color: 'text-status-error-text',\n bg: 'bg-status-error-bg-subtle border-border-default',\n icon: AlertTriangle,\n },\n EXPIRED: {\n label: 'Expired',\n color: 'text-text-secondary',\n bg: 'bg-bg-sunken border-border-default',\n icon: TimerOff,\n },\n FAILED: {\n label: 'Failed',\n color: 'text-status-error-text',\n bg: 'bg-status-error-bg-subtle border-border-default',\n icon: XCircle,\n },\n};\n\n/**\n * Color-coded status badge for sandbox lifecycle states\n */\nexport const StatusBadge: FC<StatusBadgeProps> = ({\n status,\n className,\n showIcon = true,\n size = 'sm',\n}) => {\n const { t } = useI18n();\n const config = statusConfig[status] || {\n label: status,\n color: 'text-
|
|
1
|
+
{"version":3,"file":"StatusBadge.js","names":[],"sources":["../../../src/sandbox/components/StatusBadge.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport {\n Clock,\n Loader2,\n CheckCircle2,\n StopCircle,\n AlertTriangle,\n TimerOff,\n XCircle,\n Circle,\n} from 'lucide-react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { cn } from '../utils/cn';\nimport type { SandboxStatus } from '../types';\nimport { tWithFallback } from '../utils/i18n';\n\ninterface StatusBadgeProps {\n status: SandboxStatus;\n className?: string;\n showIcon?: boolean;\n size?: 'sm' | 'md';\n}\n\nconst statusConfig: Record<\n SandboxStatus,\n { label: string; color: string; bg: string; icon: FC<{ size?: number; className?: string }> }\n> = {\n PENDING: {\n label: 'Pending',\n color: 'text-status-warning-text',\n bg: 'bg-status-warning-bg-subtle border-border-default',\n icon: Clock,\n },\n PROVISIONING: {\n label: 'Provisioning',\n color: 'text-status-info-text',\n bg: 'bg-status-info-bg-subtle border-border-default',\n icon: Loader2,\n },\n RUNNING: {\n label: 'Running',\n color: 'text-status-success-text',\n bg: 'bg-status-success-bg-subtle border-border-default',\n icon: CheckCircle2,\n },\n STOPPING: {\n label: 'Stopping',\n color: 'text-accent-orange',\n bg: 'bg-accent-orange-subtle border-border-default',\n icon: Loader2,\n },\n STOPPED: {\n label: 'Stopped',\n color: 'text-text-secondary',\n bg: 'bg-bg-sunken border-border-default',\n icon: StopCircle,\n },\n ERROR: {\n label: 'Error',\n color: 'text-status-error-text',\n bg: 'bg-status-error-bg-subtle border-border-default',\n icon: AlertTriangle,\n },\n EXPIRED: {\n label: 'Expired',\n color: 'text-text-secondary',\n bg: 'bg-bg-sunken border-border-default',\n icon: TimerOff,\n },\n FAILED: {\n label: 'Failed',\n color: 'text-status-error-text',\n bg: 'bg-status-error-bg-subtle border-border-default',\n icon: XCircle,\n },\n};\n\n/**\n * Color-coded status badge for sandbox lifecycle states\n */\nexport const StatusBadge: FC<StatusBadgeProps> = ({\n status,\n className,\n showIcon = true,\n size = 'sm',\n}) => {\n const { t } = useI18n();\n const config = statusConfig[status] || {\n label: status,\n color: 'text-text-secondary',\n bg: 'bg-bg-sunken border-border-subtle',\n icon: Circle,\n };\n const Icon = config.icon;\n const isAnimated = status === 'PROVISIONING' || status === 'STOPPING';\n const labels: Record<SandboxStatus, string> = {\n PENDING: tWithFallback(t, 'sandbox.status.pending', 'Pending'),\n PROVISIONING: tWithFallback(t, 'sandbox.status.provisioning', 'Provisioning'),\n RUNNING: tWithFallback(t, 'sandbox.status.running', 'Running'),\n STOPPING: tWithFallback(t, 'sandbox.status.stopping', 'Stopping'),\n STOPPED: tWithFallback(t, 'sandbox.status.stopped', 'Stopped'),\n ERROR: tWithFallback(t, 'sandbox.status.error', 'Error'),\n EXPIRED: tWithFallback(t, 'sandbox.status.expired', 'Expired'),\n FAILED: tWithFallback(t, 'sandbox.status.failed', 'Failed'),\n };\n\n const label = labels[status] ?? config.label;\n return (\n <output\n aria-label={label}\n className={cn(\n 'inline-flex items-center gap-1.5 border rounded-full font-medium',\n size === 'sm' ? 'px-2.5 py-0.5 text-xs' : 'px-3 py-1 text-sm',\n config.bg,\n config.color,\n className\n )}\n >\n {showIcon && (\n <Icon\n size={size === 'sm' ? 12 : 14}\n aria-hidden=\"true\"\n className={cn(isAnimated && 'animate-spin')}\n />\n )}\n {label}\n </output>\n );\n};\n"],"mappings":";;;;;;AAuBA,IAAM,IAGF;CACF,SAAS;EACP,OAAO;EACP,OAAO;EACP,IAAI;EACJ,MAAM;EACP;CACD,cAAc;EACZ,OAAO;EACP,OAAO;EACP,IAAI;EACJ,MAAM;EACP;CACD,SAAS;EACP,OAAO;EACP,OAAO;EACP,IAAI;EACJ,MAAM;EACP;CACD,UAAU;EACR,OAAO;EACP,OAAO;EACP,IAAI;EACJ,MAAM;EACP;CACD,SAAS;EACP,OAAO;EACP,OAAO;EACP,IAAI;EACJ,MAAM;EACP;CACD,OAAO;EACL,OAAO;EACP,OAAO;EACP,IAAI;EACJ,MAAM;EACP;CACD,SAAS;EACP,OAAO;EACP,OAAO;EACP,IAAI;EACJ,MAAM;EACP;CACD,QAAQ;EACN,OAAO;EACP,OAAO;EACP,IAAI;EACJ,MAAM;EACP;CACF,EAKY,KAAqC,EAChD,WACA,cACA,cAAW,IACX,UAAO,WACH;CACJ,IAAM,EAAE,SAAM,GAAS,EACjB,IAAS,EAAa,MAAW;EACrC,OAAO;EACP,OAAO;EACP,IAAI;EACJ,MAAM;EACP,EACK,IAAO,EAAO,MACd,IAAa,MAAW,kBAAkB,MAAW,YAYrD,IAXwC;EAC5C,SAAS,EAAc,GAAG,0BAA0B,UAAU;EAC9D,cAAc,EAAc,GAAG,+BAA+B,eAAe;EAC7E,SAAS,EAAc,GAAG,0BAA0B,UAAU;EAC9D,UAAU,EAAc,GAAG,2BAA2B,WAAW;EACjE,SAAS,EAAc,GAAG,0BAA0B,UAAU;EAC9D,OAAO,EAAc,GAAG,wBAAwB,QAAQ;EACxD,SAAS,EAAc,GAAG,0BAA0B,UAAU;EAC9D,QAAQ,EAAc,GAAG,yBAAyB,SAAS;EAC5D,CAEoB,MAAW,EAAO;AACvC,QACE,kBAAC,UAAD;EACE,cAAY;EACZ,WAAW,EACT,oEACA,MAAS,OAAO,0BAA0B,qBAC1C,EAAO,IACP,EAAO,OACP,EACD;YARH,CAUG,KACC,kBAAC,GAAD;GACE,MAAM,MAAS,OAAO,KAAK;GAC3B,eAAY;GACZ,WAAW,EAAG,KAAc,eAAe;GAC3C,CAAA,EAEH,EACM"}
|
|
@@ -36,7 +36,7 @@ function o({ value: o, onChange: s, placeholder: c, maxTags: l = 32, maxLength:
|
|
|
36
36
|
},
|
|
37
37
|
placeholder: o.length ? "" : _,
|
|
38
38
|
"aria-label": e(p, "sandbox.form.tags.input", "Add tag"),
|
|
39
|
-
className: "flex-1 min-w-[8rem] bg-transparent text-sm text-
|
|
39
|
+
className: "flex-1 min-w-[8rem] bg-transparent text-sm text-text-primary outline-none placeholder:text-text-tertiary"
|
|
40
40
|
})]
|
|
41
41
|
});
|
|
42
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TagsInput.js","names":[],"sources":["../../../src/sandbox/components/TagsInput.tsx"],"sourcesContent":["import { useState, type KeyboardEvent } from 'react';\nimport { X } from 'lucide-react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { tWithFallback } from '../utils/i18n';\n\ninterface Props {\n value: string[];\n onChange: (next: string[]) => void;\n placeholder?: string;\n maxTags?: number;\n maxLength?: number;\n}\n\n/**\n * Lightweight chip-style tag input. JSON-array tags (no FK to wspace-tags-svc),\n * matching the backend `tags: String[]` on Sandbox / SandboxTemplate.\n */\nexport function TagsInput({ value, onChange, placeholder, maxTags = 32, maxLength = 64 }: Props) {\n const [draft, setDraft] = useState('');\n const { t } = useI18n();\n\n const addTag = (raw: string) => {\n const tag = raw.trim().slice(0, maxLength);\n if (!tag) return;\n if (value.includes(tag)) return;\n if (value.length >= maxTags) return;\n onChange([...value, tag]);\n };\n\n const removeTag = (tag: string) => onChange(value.filter((t) => t !== tag));\n\n const handleKey = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter' || event.key === ',' || event.key === 'Tab') {\n if (draft.trim()) {\n event.preventDefault();\n addTag(draft);\n setDraft('');\n }\n } else if (event.key === 'Backspace' && draft === '' && value.length) {\n event.preventDefault();\n removeTag(value[value.length - 1]);\n }\n };\n\n const ph =\n placeholder ?? tWithFallback(t, 'sandbox.form.tags.placeholder', 'Add a tag and press Enter');\n\n return (\n <fieldset\n aria-label={tWithFallback(t, 'sandbox.form.tags.label', 'Tags')}\n className=\"flex flex-wrap items-center gap-1.5 rounded-md border border-border-subtle bg-bg-surface px-2 py-1.5\"\n >\n {value.map((tag) => (\n <span\n key={tag}\n className=\"inline-flex items-center gap-1 rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-text-secondary\"\n >\n {tag}\n <button\n type=\"button\"\n onClick={() => removeTag(tag)}\n aria-label={tWithFallback(t, 'sandbox.form.tags.remove', `Remove tag ${tag}`, { tag })}\n className=\"text-text-tertiary hover:text-text-secondary\"\n >\n <X size={12} aria-hidden=\"true\" />\n </button>\n </span>\n ))}\n <input\n type=\"text\"\n value={draft}\n onChange={(e) => setDraft(e.target.value.slice(0, maxLength))}\n onKeyDown={handleKey}\n onBlur={() => {\n if (draft.trim()) {\n addTag(draft);\n setDraft('');\n }\n }}\n placeholder={value.length ? '' : ph}\n aria-label={tWithFallback(t, 'sandbox.form.tags.input', 'Add tag')}\n className=\"flex-1 min-w-[8rem] bg-transparent text-sm text-
|
|
1
|
+
{"version":3,"file":"TagsInput.js","names":[],"sources":["../../../src/sandbox/components/TagsInput.tsx"],"sourcesContent":["import { useState, type KeyboardEvent } from 'react';\nimport { X } from 'lucide-react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { tWithFallback } from '../utils/i18n';\n\ninterface Props {\n value: string[];\n onChange: (next: string[]) => void;\n placeholder?: string;\n maxTags?: number;\n maxLength?: number;\n}\n\n/**\n * Lightweight chip-style tag input. JSON-array tags (no FK to wspace-tags-svc),\n * matching the backend `tags: String[]` on Sandbox / SandboxTemplate.\n */\nexport function TagsInput({ value, onChange, placeholder, maxTags = 32, maxLength = 64 }: Props) {\n const [draft, setDraft] = useState('');\n const { t } = useI18n();\n\n const addTag = (raw: string) => {\n const tag = raw.trim().slice(0, maxLength);\n if (!tag) return;\n if (value.includes(tag)) return;\n if (value.length >= maxTags) return;\n onChange([...value, tag]);\n };\n\n const removeTag = (tag: string) => onChange(value.filter((t) => t !== tag));\n\n const handleKey = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter' || event.key === ',' || event.key === 'Tab') {\n if (draft.trim()) {\n event.preventDefault();\n addTag(draft);\n setDraft('');\n }\n } else if (event.key === 'Backspace' && draft === '' && value.length) {\n event.preventDefault();\n removeTag(value[value.length - 1]);\n }\n };\n\n const ph =\n placeholder ?? tWithFallback(t, 'sandbox.form.tags.placeholder', 'Add a tag and press Enter');\n\n return (\n <fieldset\n aria-label={tWithFallback(t, 'sandbox.form.tags.label', 'Tags')}\n className=\"flex flex-wrap items-center gap-1.5 rounded-md border border-border-subtle bg-bg-surface px-2 py-1.5\"\n >\n {value.map((tag) => (\n <span\n key={tag}\n className=\"inline-flex items-center gap-1 rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-text-secondary\"\n >\n {tag}\n <button\n type=\"button\"\n onClick={() => removeTag(tag)}\n aria-label={tWithFallback(t, 'sandbox.form.tags.remove', `Remove tag ${tag}`, { tag })}\n className=\"text-text-tertiary hover:text-text-secondary\"\n >\n <X size={12} aria-hidden=\"true\" />\n </button>\n </span>\n ))}\n <input\n type=\"text\"\n value={draft}\n onChange={(e) => setDraft(e.target.value.slice(0, maxLength))}\n onKeyDown={handleKey}\n onBlur={() => {\n if (draft.trim()) {\n addTag(draft);\n setDraft('');\n }\n }}\n placeholder={value.length ? '' : ph}\n aria-label={tWithFallback(t, 'sandbox.form.tags.input', 'Add tag')}\n className=\"flex-1 min-w-[8rem] bg-transparent text-sm text-text-primary outline-none placeholder:text-text-tertiary\"\n />\n </fieldset>\n );\n}\n"],"mappings":";;;;;;AAiBA,SAAgB,EAAU,EAAE,UAAO,aAAU,gBAAa,aAAU,IAAI,eAAY,MAAa;CAC/F,IAAM,CAAC,GAAO,KAAY,EAAS,GAAG,EAChC,EAAE,SAAM,GAAS,EAEjB,KAAU,MAAgB;EAC9B,IAAM,IAAM,EAAI,MAAM,CAAC,MAAM,GAAG,EAAU;AACrC,QACD,EAAM,SAAS,EAAI,IACnB,EAAM,UAAU,KACpB,EAAS,CAAC,GAAG,GAAO,EAAI,CAAC;IAGrB,KAAa,MAAgB,EAAS,EAAM,QAAQ,MAAM,MAAM,EAAI,CAAC,EAErE,KAAa,MAA2C;AAC5D,EAAI,EAAM,QAAQ,WAAW,EAAM,QAAQ,OAAO,EAAM,QAAQ,QAC1D,EAAM,MAAM,KACd,EAAM,gBAAgB,EACtB,EAAO,EAAM,EACb,EAAS,GAAG,IAEL,EAAM,QAAQ,eAAe,MAAU,MAAM,EAAM,WAC5D,EAAM,gBAAgB,EACtB,EAAU,EAAM,EAAM,SAAS,GAAG;IAIhC,IACJ,KAAe,EAAc,GAAG,iCAAiC,4BAA4B;AAE/F,QACE,kBAAC,YAAD;EACE,cAAY,EAAc,GAAG,2BAA2B,OAAO;EAC/D,WAAU;YAFZ,CAIG,EAAM,KAAK,MACV,kBAAC,QAAD;GAEE,WAAU;aAFZ,CAIG,GACD,kBAAC,UAAD;IACE,MAAK;IACL,eAAe,EAAU,EAAI;IAC7B,cAAY,EAAc,GAAG,4BAA4B,cAAc,KAAO,EAAE,QAAK,CAAC;IACtF,WAAU;cAEV,kBAAC,GAAD;KAAG,MAAM;KAAI,eAAY;KAAS,CAAA;IAC3B,CAAA,CACJ;KAZA,EAYA,CACP,EACF,kBAAC,SAAD;GACE,MAAK;GACL,OAAO;GACP,WAAW,MAAM,EAAS,EAAE,OAAO,MAAM,MAAM,GAAG,EAAU,CAAC;GAC7D,WAAW;GACX,cAAc;AACZ,IAAI,EAAM,MAAM,KACd,EAAO,EAAM,EACb,EAAS,GAAG;;GAGhB,aAAa,EAAM,SAAS,KAAK;GACjC,cAAY,EAAc,GAAG,2BAA2B,UAAU;GAClE,WAAU;GACV,CAAA,CACO"}
|
|
@@ -6,150 +6,168 @@ import { SandboxTypeIcon as s } from "../components/SandboxTypeIcon.js";
|
|
|
6
6
|
import { EmptyState as c, PageLayout as l } from "../components/PageLayout.js";
|
|
7
7
|
import { useDeleteSandboxTemplateMutation as u, useListSandboxTemplatesQuery as d } from "../../generated/wspace-operations.js";
|
|
8
8
|
import { formatTTL as f } from "../utils/formatters.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { useState as p } from "react";
|
|
10
|
+
import { Container as m, LayoutTemplate as h, Loader2 as g, Pencil as _, Plus as v, Star as y, Trash2 as b } from "lucide-react";
|
|
11
|
+
import { useI18n as x } from "@burdenoff/fe-libs/shared/providers/shell";
|
|
12
|
+
import { jsx as S, jsxs as C } from "react/jsx-runtime";
|
|
13
|
+
import { AlertDialog as w, AlertDialogAction as T, AlertDialogCancel as E, AlertDialogContent as D, AlertDialogDescription as O, AlertDialogFooter as k, AlertDialogHeader as A, AlertDialogTitle as j } from "@burdenoff/fe-libs/ui";
|
|
12
14
|
//#region src/sandbox/pages/AdminTemplatesPage.tsx
|
|
13
|
-
function
|
|
14
|
-
let { basePath:
|
|
15
|
-
variables: { context: { workspaceId:
|
|
16
|
-
skip: !
|
|
17
|
-
}), [
|
|
18
|
-
|
|
19
|
-
},
|
|
20
|
-
|
|
15
|
+
function M() {
|
|
16
|
+
let { basePath: M = "/", navigate: N, workspaceId: P } = e(), { t: F } = x(), { data: I, loading: L, refetch: R } = d({
|
|
17
|
+
variables: { context: { workspaceId: P } },
|
|
18
|
+
skip: !P
|
|
19
|
+
}), [z] = u(), B = I?.listSandboxTemplates?.items ?? [], [V, H] = p(null), U = () => {
|
|
20
|
+
N?.(t(M, "templates/new"));
|
|
21
|
+
}, W = (e) => {
|
|
22
|
+
N?.(t(M, `templates/${e}`));
|
|
23
|
+
}, G = async (e) => {
|
|
24
|
+
H(null);
|
|
25
|
+
try {
|
|
26
|
+
await z({ variables: {
|
|
27
|
+
context: { workspaceId: P },
|
|
28
|
+
id: e
|
|
29
|
+
} }), await R();
|
|
30
|
+
} catch (e) {
|
|
31
|
+
console.error("[Sandbox] Failed to delete template:", e), window.alert(o(F, "sandbox.adminTemplates.actions.delete.error", "Failed to delete template. Please try again."));
|
|
32
|
+
}
|
|
21
33
|
};
|
|
22
|
-
return /* @__PURE__ */
|
|
23
|
-
title: o(
|
|
24
|
-
subtitle: o(
|
|
25
|
-
icon: /* @__PURE__ */
|
|
26
|
-
headerActions: /* @__PURE__ */
|
|
27
|
-
onClick:
|
|
34
|
+
return /* @__PURE__ */ C(l, {
|
|
35
|
+
title: o(F, "sandbox.adminTemplates.title", "Templates"),
|
|
36
|
+
subtitle: o(F, "sandbox.adminTemplates.subtitle", "Manage sandbox templates - create, edit, and configure predefined configurations"),
|
|
37
|
+
icon: /* @__PURE__ */ S(h, { size: 24 }),
|
|
38
|
+
headerActions: /* @__PURE__ */ C(r, {
|
|
39
|
+
onClick: U,
|
|
28
40
|
size: "lg",
|
|
29
|
-
children: [/* @__PURE__ */
|
|
41
|
+
children: [/* @__PURE__ */ S(v, { size: 18 }), o(F, "sandbox.adminTemplates.actions.create", "Create Template")]
|
|
30
42
|
}),
|
|
31
|
-
headerContent: /* @__PURE__ */
|
|
43
|
+
headerContent: /* @__PURE__ */ S(n, {
|
|
32
44
|
variant: "secondary",
|
|
33
|
-
children: o(
|
|
45
|
+
children: o(F, "sandbox.adminTemplates.header.count", "{count} templates", { count: B.length })
|
|
34
46
|
}),
|
|
35
|
-
children:
|
|
47
|
+
children: [L ? /* @__PURE__ */ S("div", {
|
|
36
48
|
className: "flex items-center justify-center min-h-[200px]",
|
|
37
|
-
children: /* @__PURE__ */
|
|
38
|
-
}) :
|
|
49
|
+
children: /* @__PURE__ */ S(g, { className: "size-8 animate-spin text-primary" })
|
|
50
|
+
}) : B.length > 0 ? /* @__PURE__ */ S("div", {
|
|
39
51
|
className: "grid grid-cols-1 md:grid-cols-2 gap-4",
|
|
40
|
-
children:
|
|
52
|
+
children: B.map((e, t) => /* @__PURE__ */ S(i, {
|
|
41
53
|
className: "group hover:shadow-md hover:border-primary/30 transition-all duration-200 animate-in fade-in-0 slide-in-from-bottom-2",
|
|
42
54
|
style: { animationDelay: `${t * 50}ms` },
|
|
43
|
-
children: /* @__PURE__ */
|
|
55
|
+
children: /* @__PURE__ */ C(a, {
|
|
44
56
|
className: "p-5",
|
|
45
57
|
children: [
|
|
46
|
-
/* @__PURE__ */
|
|
58
|
+
/* @__PURE__ */ C("div", {
|
|
47
59
|
className: "flex items-start justify-between mb-3",
|
|
48
|
-
children: [/* @__PURE__ */
|
|
60
|
+
children: [/* @__PURE__ */ C("div", {
|
|
49
61
|
className: "flex items-center gap-3",
|
|
50
|
-
children: [/* @__PURE__ */
|
|
51
|
-
className: "p-2 rounded-lg bg-
|
|
52
|
-
children: /* @__PURE__ */
|
|
62
|
+
children: [/* @__PURE__ */ S("div", {
|
|
63
|
+
className: "p-2 rounded-lg bg-bg-sunken/50",
|
|
64
|
+
children: /* @__PURE__ */ S(s, {
|
|
53
65
|
type: e.template,
|
|
54
66
|
size: 20
|
|
55
67
|
})
|
|
56
|
-
}), /* @__PURE__ */
|
|
68
|
+
}), /* @__PURE__ */ C("div", { children: [/* @__PURE__ */ C("div", {
|
|
57
69
|
className: "flex items-center gap-2",
|
|
58
|
-
children: [/* @__PURE__ */
|
|
70
|
+
children: [/* @__PURE__ */ S("h3", {
|
|
59
71
|
className: "font-semibold",
|
|
60
72
|
children: e.name
|
|
61
|
-
}), e.isDefault && /* @__PURE__ */
|
|
73
|
+
}), e.isDefault && /* @__PURE__ */ C(n, {
|
|
62
74
|
variant: "default",
|
|
63
75
|
className: "gap-1 text-xs bg-status-warning-bg-subtle text-status-warning-text border-border-default",
|
|
64
|
-
children: [/* @__PURE__ */
|
|
76
|
+
children: [/* @__PURE__ */ S(y, { size: 10 }), o(F, "sandbox.adminTemplates.badges.default", "Default")]
|
|
65
77
|
})]
|
|
66
|
-
}), /* @__PURE__ */
|
|
78
|
+
}), /* @__PURE__ */ S(s, {
|
|
67
79
|
type: e.template,
|
|
68
80
|
size: 12,
|
|
69
81
|
showLabel: !0,
|
|
70
82
|
className: "mt-0.5"
|
|
71
83
|
})] })]
|
|
72
|
-
}), /* @__PURE__ */
|
|
84
|
+
}), /* @__PURE__ */ C("div", {
|
|
73
85
|
className: "flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",
|
|
74
|
-
children: [/* @__PURE__ */
|
|
86
|
+
children: [/* @__PURE__ */ S(r, {
|
|
75
87
|
variant: "ghost",
|
|
76
88
|
size: "icon",
|
|
77
|
-
onClick: () =>
|
|
78
|
-
"aria-label": o(
|
|
79
|
-
children: /* @__PURE__ */
|
|
80
|
-
}), /* @__PURE__ */
|
|
89
|
+
onClick: () => W(e.id),
|
|
90
|
+
"aria-label": o(F, "sandbox.adminTemplates.actions.edit.ariaLabel", "Edit template"),
|
|
91
|
+
children: /* @__PURE__ */ S(_, { size: 14 })
|
|
92
|
+
}), /* @__PURE__ */ S(r, {
|
|
81
93
|
variant: "ghost",
|
|
82
94
|
size: "icon",
|
|
83
|
-
className: "text-
|
|
84
|
-
onClick:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
} catch (e) {
|
|
91
|
-
console.error("[Sandbox] Failed to delete template:", e), window.alert(o(E, "sandbox.adminTemplates.actions.delete.error", "Failed to delete template. Please try again."));
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
"aria-label": o(E, "sandbox.adminTemplates.actions.delete.ariaLabel", "Delete template"),
|
|
95
|
-
children: /* @__PURE__ */ x(y, { size: 14 })
|
|
95
|
+
className: "text-status-error-text hover:text-status-error-text",
|
|
96
|
+
onClick: () => H({
|
|
97
|
+
id: e.id,
|
|
98
|
+
name: e.name
|
|
99
|
+
}),
|
|
100
|
+
"aria-label": o(F, "sandbox.adminTemplates.actions.delete.ariaLabel", "Delete template"),
|
|
101
|
+
children: /* @__PURE__ */ S(b, { size: 14 })
|
|
96
102
|
})]
|
|
97
103
|
})]
|
|
98
104
|
}),
|
|
99
|
-
e.description && /* @__PURE__ */
|
|
100
|
-
className: "text-sm text-
|
|
105
|
+
e.description && /* @__PURE__ */ S("p", {
|
|
106
|
+
className: "text-sm text-text-secondary mb-3 line-clamp-2",
|
|
101
107
|
children: e.description
|
|
102
108
|
}),
|
|
103
|
-
/* @__PURE__ */
|
|
109
|
+
/* @__PURE__ */ C("div", {
|
|
104
110
|
className: "flex flex-wrap items-center gap-2",
|
|
105
111
|
children: [
|
|
106
|
-
/* @__PURE__ */
|
|
112
|
+
/* @__PURE__ */ C(n, {
|
|
107
113
|
variant: "outline",
|
|
108
114
|
className: "text-xs gap-1",
|
|
109
115
|
children: [e.resources?.cpuRequest ?? "?", " CPU"]
|
|
110
116
|
}),
|
|
111
|
-
/* @__PURE__ */
|
|
117
|
+
/* @__PURE__ */ C(n, {
|
|
112
118
|
variant: "outline",
|
|
113
119
|
className: "text-xs gap-1",
|
|
114
120
|
children: [e.resources?.memoryRequest ?? "?", " mem"]
|
|
115
121
|
}),
|
|
116
|
-
/* @__PURE__ */
|
|
122
|
+
/* @__PURE__ */ C(n, {
|
|
117
123
|
variant: "outline",
|
|
118
124
|
className: "text-xs gap-1",
|
|
119
|
-
children: [/* @__PURE__ */
|
|
125
|
+
children: [/* @__PURE__ */ S(m, { size: 10 }), o(F, "sandbox.adminTemplates.meta.containers", "{count} containers", { count: e.containers?.length ?? 0 })]
|
|
120
126
|
}),
|
|
121
|
-
/* @__PURE__ */
|
|
127
|
+
/* @__PURE__ */ C(n, {
|
|
122
128
|
variant: "outline",
|
|
123
129
|
className: "text-xs gap-1",
|
|
124
130
|
children: [f(e.ttlSeconds), " TTL"]
|
|
125
131
|
}),
|
|
126
|
-
e.storage?.mode && e.storage.mode !== "NONE" && /* @__PURE__ */
|
|
132
|
+
e.storage?.mode && e.storage.mode !== "NONE" && /* @__PURE__ */ C(n, {
|
|
127
133
|
variant: "outline",
|
|
128
134
|
className: "text-xs gap-1",
|
|
129
|
-
children: [e.storage.mode === "EPHEMERAL" ? o(
|
|
135
|
+
children: [e.storage.mode === "EPHEMERAL" ? o(F, "sandbox.adminTemplates.storage.ephemeral", "Ephemeral") : o(F, "sandbox.adminTemplates.storage.persistent", "Persistent"), e.storage.sizeGi ? ` ${e.storage.sizeGi}Gi` : ""]
|
|
130
136
|
}),
|
|
131
|
-
(e.allowedImages?.length ?? 0) > 0 && /* @__PURE__ */
|
|
137
|
+
(e.allowedImages?.length ?? 0) > 0 && /* @__PURE__ */ S(n, {
|
|
132
138
|
variant: "outline",
|
|
133
139
|
className: "text-xs gap-1",
|
|
134
|
-
children: o(
|
|
140
|
+
children: o(F, "sandbox.adminTemplates.meta.allowedImages", "{count} allowed images", { count: e.allowedImages.length })
|
|
135
141
|
})
|
|
136
142
|
]
|
|
137
143
|
})
|
|
138
144
|
]
|
|
139
145
|
})
|
|
140
146
|
}, e.id))
|
|
141
|
-
}) : /* @__PURE__ */
|
|
142
|
-
icon: /* @__PURE__ */
|
|
143
|
-
title: o(
|
|
144
|
-
description: o(
|
|
145
|
-
action: /* @__PURE__ */
|
|
146
|
-
onClick:
|
|
147
|
-
children: [/* @__PURE__ */
|
|
147
|
+
}) : /* @__PURE__ */ S(c, {
|
|
148
|
+
icon: /* @__PURE__ */ S(h, { size: 48 }),
|
|
149
|
+
title: o(F, "sandbox.adminTemplates.empty.title", "No templates yet"),
|
|
150
|
+
description: o(F, "sandbox.adminTemplates.empty.description", "Create templates for commonly used sandbox configurations to speed up provisioning."),
|
|
151
|
+
action: /* @__PURE__ */ C(r, {
|
|
152
|
+
onClick: U,
|
|
153
|
+
children: [/* @__PURE__ */ S(v, { size: 16 }), o(F, "sandbox.adminTemplates.empty.action", "Create First Template")]
|
|
148
154
|
})
|
|
149
|
-
})
|
|
155
|
+
}), /* @__PURE__ */ S(w, {
|
|
156
|
+
open: V !== null,
|
|
157
|
+
onOpenChange: (e) => {
|
|
158
|
+
e || H(null);
|
|
159
|
+
},
|
|
160
|
+
children: /* @__PURE__ */ C(D, { children: [/* @__PURE__ */ C(A, { children: [/* @__PURE__ */ S(j, { children: o(F, "sandbox.adminTemplates.actions.delete.ariaLabel", "Delete template") }), /* @__PURE__ */ S(O, { children: o(F, "sandbox.adminTemplates.actions.delete.confirm", "Delete template \"{name}\"? This cannot be undone.", { name: V?.name ?? "" }) })] }), /* @__PURE__ */ C(k, { children: [/* @__PURE__ */ S(E, { children: "Cancel" }), /* @__PURE__ */ S(T, {
|
|
161
|
+
className: "bg-status-error-bg text-status-error-text hover:bg-status-error-bg/90",
|
|
162
|
+
onClick: () => {
|
|
163
|
+
V && G(V.id);
|
|
164
|
+
},
|
|
165
|
+
children: "Delete"
|
|
166
|
+
})] })] })
|
|
167
|
+
})]
|
|
150
168
|
});
|
|
151
169
|
}
|
|
152
170
|
//#endregion
|
|
153
|
-
export {
|
|
171
|
+
export { M as AdminTemplatesPage };
|
|
154
172
|
|
|
155
173
|
//# sourceMappingURL=AdminTemplatesPage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdminTemplatesPage.js","names":[],"sources":["../../../src/sandbox/pages/AdminTemplatesPage.tsx"],"sourcesContent":["import { Plus, LayoutTemplate, Pencil, Trash2, Star, Container, Loader2 } from 'lucide-react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { Button, Badge, Card, CardContent } from '../components/ui';\nimport { SandboxTypeIcon } from '../components/SandboxTypeIcon';\nimport { useSandbox } from '../providers/SandboxProvider';\nimport { joinPath } from '../utils/navigation';\nimport { formatTTL } from '../utils/formatters';\nimport { tWithFallback } from '../utils/i18n';\nimport { PageLayout, EmptyState } from '../components/PageLayout';\nimport {\n useListSandboxTemplatesQuery,\n useDeleteSandboxTemplateMutation,\n} from '../../generated/wspace-operations';\nimport type { SandboxTemplate } from '../types';\n\n/**\n * Admin Templates Page\n * Full CRUD template management for workspace admins.\n * Admins can create, edit, and delete sandbox templates.\n */\nexport function AdminTemplatesPage() {\n const { basePath = '/', navigate, workspaceId } = useSandbox();\n const { t } = useI18n();\n const { data, loading, refetch } = useListSandboxTemplatesQuery({\n variables: { context: { workspaceId } },\n skip: !workspaceId,\n });\n const [deleteTemplate] = useDeleteSandboxTemplateMutation();\n const templates = (data?.listSandboxTemplates?.items ?? []) as SandboxTemplate[];\n\n const handleCreate = () => {\n navigate?.(joinPath(basePath, 'templates/new'));\n };\n\n const handleEdit = (templateId: string) => {\n navigate?.(joinPath(basePath, `templates/${templateId}`));\n };\n\n return (\n <PageLayout\n title={tWithFallback(t, 'sandbox.adminTemplates.title', 'Templates')}\n subtitle={tWithFallback(\n t,\n 'sandbox.adminTemplates.subtitle',\n 'Manage sandbox templates - create, edit, and configure predefined configurations'\n )}\n icon={<LayoutTemplate size={24} />}\n headerActions={\n <Button onClick={handleCreate} size=\"lg\">\n <Plus size={18} />\n {tWithFallback(t, 'sandbox.adminTemplates.actions.create', 'Create Template')}\n </Button>\n }\n headerContent={\n <Badge variant=\"secondary\">\n {tWithFallback(t, 'sandbox.adminTemplates.header.count', '{count} templates', {\n count: templates.length,\n })}\n </Badge>\n }\n >\n {loading ? (\n <div className=\"flex items-center justify-center min-h-[200px]\">\n <Loader2 className=\"size-8 animate-spin text-primary\" />\n </div>\n ) : templates.length > 0 ? (\n <div className=\"grid grid-cols-1 md:grid-cols-2 gap-4\">\n {templates.map((template, index) => (\n <Card\n key={template.id}\n className=\"group hover:shadow-md hover:border-primary/30 transition-all duration-200 animate-in fade-in-0 slide-in-from-bottom-2\"\n style={{ animationDelay: `${index * 50}ms` }}\n >\n <CardContent className=\"p-5\">\n <div className=\"flex items-start justify-between mb-3\">\n <div className=\"flex items-center gap-3\">\n <div className=\"p-2 rounded-lg bg-muted/50\">\n <SandboxTypeIcon type={template.template} size={20} />\n </div>\n <div>\n <div className=\"flex items-center gap-2\">\n <h3 className=\"font-semibold\">{template.name}</h3>\n {template.isDefault && (\n <Badge\n variant=\"default\"\n className=\"gap-1 text-xs bg-status-warning-bg-subtle text-status-warning-text border-border-default\"\n >\n <Star size={10} />\n {tWithFallback(t, 'sandbox.adminTemplates.badges.default', 'Default')}\n </Badge>\n )}\n </div>\n <SandboxTypeIcon\n type={template.template}\n size={12}\n showLabel\n className=\"mt-0.5\"\n />\n </div>\n </div>\n\n {/* Admin Actions */}\n <div className=\"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity\">\n <Button\n variant=\"ghost\"\n size=\"icon\"\n onClick={() => handleEdit(template.id)}\n aria-label={tWithFallback(\n t,\n 'sandbox.adminTemplates.actions.edit.ariaLabel',\n 'Edit template'\n )}\n >\n <Pencil size={14} />\n </Button>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n className=\"text-destructive hover:text-destructive\"\n onClick={async () => {\n const confirmed = window.confirm(\n tWithFallback(\n t,\n 'sandbox.adminTemplates.actions.delete.confirm',\n 'Delete template \"{name}\"? This cannot be undone.',\n { name: template.name }\n )\n );\n if (!confirmed) return;\n try {\n await deleteTemplate({\n variables: { context: { workspaceId }, id: template.id },\n });\n await refetch();\n } catch (err) {\n console.error('[Sandbox] Failed to delete template:', err);\n window.alert(\n tWithFallback(\n t,\n 'sandbox.adminTemplates.actions.delete.error',\n 'Failed to delete template. Please try again.'\n )\n );\n }\n }}\n aria-label={tWithFallback(\n t,\n 'sandbox.adminTemplates.actions.delete.ariaLabel',\n 'Delete template'\n )}\n >\n <Trash2 size={14} />\n </Button>\n </div>\n </div>\n\n {template.description && (\n <p className=\"text-sm text-muted-foreground mb-3 line-clamp-2\">\n {template.description}\n </p>\n )}\n\n {/* Resources & Info */}\n <div className=\"flex flex-wrap items-center gap-2\">\n <Badge variant=\"outline\" className=\"text-xs gap-1\">\n {template.resources?.cpuRequest ?? '?'} CPU\n </Badge>\n <Badge variant=\"outline\" className=\"text-xs gap-1\">\n {template.resources?.memoryRequest ?? '?'} mem\n </Badge>\n <Badge variant=\"outline\" className=\"text-xs gap-1\">\n <Container size={10} />\n {tWithFallback(\n t,\n 'sandbox.adminTemplates.meta.containers',\n '{count} containers',\n { count: template.containers?.length ?? 0 }\n )}\n </Badge>\n <Badge variant=\"outline\" className=\"text-xs gap-1\">\n {formatTTL(template.ttlSeconds)} TTL\n </Badge>\n {template.storage?.mode && template.storage.mode !== 'NONE' && (\n <Badge variant=\"outline\" className=\"text-xs gap-1\">\n {template.storage.mode === 'EPHEMERAL'\n ? tWithFallback(t, 'sandbox.adminTemplates.storage.ephemeral', 'Ephemeral')\n : tWithFallback(\n t,\n 'sandbox.adminTemplates.storage.persistent',\n 'Persistent'\n )}\n {template.storage.sizeGi ? ` ${template.storage.sizeGi}Gi` : ''}\n </Badge>\n )}\n {(template.allowedImages?.length ?? 0) > 0 && (\n <Badge variant=\"outline\" className=\"text-xs gap-1\">\n {tWithFallback(\n t,\n 'sandbox.adminTemplates.meta.allowedImages',\n '{count} allowed images',\n { count: template.allowedImages!.length }\n )}\n </Badge>\n )}\n </div>\n </CardContent>\n </Card>\n ))}\n </div>\n ) : (\n <EmptyState\n icon={<LayoutTemplate size={48} />}\n title={tWithFallback(t, 'sandbox.adminTemplates.empty.title', 'No templates yet')}\n description={tWithFallback(\n t,\n 'sandbox.adminTemplates.empty.description',\n 'Create templates for commonly used sandbox configurations to speed up provisioning.'\n )}\n action={\n <Button onClick={handleCreate}>\n <Plus size={16} />\n {tWithFallback(t, 'sandbox.adminTemplates.empty.action', 'Create First Template')}\n </Button>\n }\n />\n )}\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAoBA,SAAgB,IAAqB;CACnC,IAAM,EAAE,cAAW,KAAK,aAAU,mBAAgB,GAAY,EACxD,EAAE,SAAM,GAAS,EACjB,EAAE,SAAM,YAAS,eAAY,EAA6B;EAC9D,WAAW,EAAE,SAAS,EAAE,gBAAa,EAAE;EACvC,MAAM,CAAC;EACR,CAAC,EACI,CAAC,KAAkB,GAAkC,EACrD,IAAa,GAAM,sBAAsB,SAAS,EAAE,EAEpD,UAAqB;AACzB,MAAW,EAAS,GAAU,gBAAgB,CAAC;IAG3C,KAAc,MAAuB;AACzC,MAAW,EAAS,GAAU,aAAa,IAAa,CAAC;;AAG3D,QACE,kBAAC,GAAD;EACE,OAAO,EAAc,GAAG,gCAAgC,YAAY;EACpE,UAAU,EACR,GACA,mCACA,mFACD;EACD,MAAM,kBAAC,GAAD,EAAgB,MAAM,IAAM,CAAA;EAClC,eACE,kBAAC,GAAD;GAAQ,SAAS;GAAc,MAAK;a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S,QAAQ,OAAO,MAAM,GACvD;;SAER,EAAS,eAAe,UAAU,KAAK,KACvC,kBAAC,GAAD;SAAO,SAAQ;SAAU,WAAU;mBAChC,EACC,GACA,6CACA,0BACA,EAAE,OAAO,EAAS,cAAe,QAAQ,CAC1C;SACK,CAAA;QAEN;;MACM;;IACT,EAzIA,EAAS,GAyIT,CACP;GACE,CAAA,GAEN,kBAAC,GAAD;GACE,MAAM,kBAAC,GAAD,EAAgB,MAAM,IAAM,CAAA;GAClC,OAAO,EAAc,GAAG,sCAAsC,mBAAmB;GACjF,aAAa,EACX,GACA,4CACA,sFACD;GACD,QACE,kBAAC,GAAD;IAAQ,SAAS;cAAjB,CACE,kBAAC,GAAD,EAAM,MAAM,IAAM,CAAA,EACjB,EAAc,GAAG,uCAAuC,wBAAwB,CAC1E;;GAEX,CAAA;EAEO,CAAA"}
|
|
1
|
+
{"version":3,"file":"AdminTemplatesPage.js","names":[],"sources":["../../../src/sandbox/pages/AdminTemplatesPage.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { Plus, LayoutTemplate, Pencil, Trash2, Star, Container, Loader2 } from 'lucide-react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell';\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n} from '@burdenoff/fe-libs/ui';\nimport { Button, Badge, Card, CardContent } from '../components/ui';\nimport { SandboxTypeIcon } from '../components/SandboxTypeIcon';\nimport { useSandbox } from '../providers/SandboxProvider';\nimport { joinPath } from '../utils/navigation';\nimport { formatTTL } from '../utils/formatters';\nimport { tWithFallback } from '../utils/i18n';\nimport { PageLayout, EmptyState } from '../components/PageLayout';\nimport {\n useListSandboxTemplatesQuery,\n useDeleteSandboxTemplateMutation,\n} from '../../generated/wspace-operations';\nimport type { SandboxTemplate } from '../types';\n\n/**\n * Admin Templates Page\n * Full CRUD template management for workspace admins.\n * Admins can create, edit, and delete sandbox templates.\n */\nexport function AdminTemplatesPage() {\n const { basePath = '/', navigate, workspaceId } = useSandbox();\n const { t } = useI18n();\n const { data, loading, refetch } = useListSandboxTemplatesQuery({\n variables: { context: { workspaceId } },\n skip: !workspaceId,\n });\n const [deleteTemplate] = useDeleteSandboxTemplateMutation();\n const templates = (data?.listSandboxTemplates?.items ?? []) as SandboxTemplate[];\n const [pendingDelete, setPendingDelete] = useState<{ id: string; name: string } | null>(null);\n\n const handleCreate = () => {\n navigate?.(joinPath(basePath, 'templates/new'));\n };\n\n const handleEdit = (templateId: string) => {\n navigate?.(joinPath(basePath, `templates/${templateId}`));\n };\n\n const performDelete = async (templateId: string) => {\n setPendingDelete(null);\n try {\n await deleteTemplate({\n variables: { context: { workspaceId }, id: templateId },\n });\n await refetch();\n } catch (err) {\n console.error('[Sandbox] Failed to delete template:', err);\n window.alert(\n tWithFallback(\n t,\n 'sandbox.adminTemplates.actions.delete.error',\n 'Failed to delete template. Please try again.'\n )\n );\n }\n };\n\n return (\n <PageLayout\n title={tWithFallback(t, 'sandbox.adminTemplates.title', 'Templates')}\n subtitle={tWithFallback(\n t,\n 'sandbox.adminTemplates.subtitle',\n 'Manage sandbox templates - create, edit, and configure predefined configurations'\n )}\n icon={<LayoutTemplate size={24} />}\n headerActions={\n <Button onClick={handleCreate} size=\"lg\">\n <Plus size={18} />\n {tWithFallback(t, 'sandbox.adminTemplates.actions.create', 'Create Template')}\n </Button>\n }\n headerContent={\n <Badge variant=\"secondary\">\n {tWithFallback(t, 'sandbox.adminTemplates.header.count', '{count} templates', {\n count: templates.length,\n })}\n </Badge>\n }\n >\n {loading ? (\n <div className=\"flex items-center justify-center min-h-[200px]\">\n <Loader2 className=\"size-8 animate-spin text-primary\" />\n </div>\n ) : templates.length > 0 ? (\n <div className=\"grid grid-cols-1 md:grid-cols-2 gap-4\">\n {templates.map((template, index) => (\n <Card\n key={template.id}\n className=\"group hover:shadow-md hover:border-primary/30 transition-all duration-200 animate-in fade-in-0 slide-in-from-bottom-2\"\n style={{ animationDelay: `${index * 50}ms` }}\n >\n <CardContent className=\"p-5\">\n <div className=\"flex items-start justify-between mb-3\">\n <div className=\"flex items-center gap-3\">\n <div className=\"p-2 rounded-lg bg-bg-sunken/50\">\n <SandboxTypeIcon type={template.template} size={20} />\n </div>\n <div>\n <div className=\"flex items-center gap-2\">\n <h3 className=\"font-semibold\">{template.name}</h3>\n {template.isDefault && (\n <Badge\n variant=\"default\"\n className=\"gap-1 text-xs bg-status-warning-bg-subtle text-status-warning-text border-border-default\"\n >\n <Star size={10} />\n {tWithFallback(t, 'sandbox.adminTemplates.badges.default', 'Default')}\n </Badge>\n )}\n </div>\n <SandboxTypeIcon\n type={template.template}\n size={12}\n showLabel\n className=\"mt-0.5\"\n />\n </div>\n </div>\n\n {/* Admin Actions */}\n <div className=\"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity\">\n <Button\n variant=\"ghost\"\n size=\"icon\"\n onClick={() => handleEdit(template.id)}\n aria-label={tWithFallback(\n t,\n 'sandbox.adminTemplates.actions.edit.ariaLabel',\n 'Edit template'\n )}\n >\n <Pencil size={14} />\n </Button>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n className=\"text-status-error-text hover:text-status-error-text\"\n onClick={() => setPendingDelete({ id: template.id, name: template.name })}\n aria-label={tWithFallback(\n t,\n 'sandbox.adminTemplates.actions.delete.ariaLabel',\n 'Delete template'\n )}\n >\n <Trash2 size={14} />\n </Button>\n </div>\n </div>\n\n {template.description && (\n <p className=\"text-sm text-text-secondary mb-3 line-clamp-2\">\n {template.description}\n </p>\n )}\n\n {/* Resources & Info */}\n <div className=\"flex flex-wrap items-center gap-2\">\n <Badge variant=\"outline\" className=\"text-xs gap-1\">\n {template.resources?.cpuRequest ?? '?'} CPU\n </Badge>\n <Badge variant=\"outline\" className=\"text-xs gap-1\">\n {template.resources?.memoryRequest ?? '?'} mem\n </Badge>\n <Badge variant=\"outline\" className=\"text-xs gap-1\">\n <Container size={10} />\n {tWithFallback(\n t,\n 'sandbox.adminTemplates.meta.containers',\n '{count} containers',\n { count: template.containers?.length ?? 0 }\n )}\n </Badge>\n <Badge variant=\"outline\" className=\"text-xs gap-1\">\n {formatTTL(template.ttlSeconds)} TTL\n </Badge>\n {template.storage?.mode && template.storage.mode !== 'NONE' && (\n <Badge variant=\"outline\" className=\"text-xs gap-1\">\n {template.storage.mode === 'EPHEMERAL'\n ? tWithFallback(t, 'sandbox.adminTemplates.storage.ephemeral', 'Ephemeral')\n : tWithFallback(\n t,\n 'sandbox.adminTemplates.storage.persistent',\n 'Persistent'\n )}\n {template.storage.sizeGi ? ` ${template.storage.sizeGi}Gi` : ''}\n </Badge>\n )}\n {(template.allowedImages?.length ?? 0) > 0 && (\n <Badge variant=\"outline\" className=\"text-xs gap-1\">\n {tWithFallback(\n t,\n 'sandbox.adminTemplates.meta.allowedImages',\n '{count} allowed images',\n { count: template.allowedImages!.length }\n )}\n </Badge>\n )}\n </div>\n </CardContent>\n </Card>\n ))}\n </div>\n ) : (\n <EmptyState\n icon={<LayoutTemplate size={48} />}\n title={tWithFallback(t, 'sandbox.adminTemplates.empty.title', 'No templates yet')}\n description={tWithFallback(\n t,\n 'sandbox.adminTemplates.empty.description',\n 'Create templates for commonly used sandbox configurations to speed up provisioning.'\n )}\n action={\n <Button onClick={handleCreate}>\n <Plus size={16} />\n {tWithFallback(t, 'sandbox.adminTemplates.empty.action', 'Create First Template')}\n </Button>\n }\n />\n )}\n <AlertDialog\n open={pendingDelete !== null}\n onOpenChange={(open) => {\n if (!open) setPendingDelete(null);\n }}\n >\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>\n {tWithFallback(t, 'sandbox.adminTemplates.actions.delete.ariaLabel', 'Delete template')}\n </AlertDialogTitle>\n <AlertDialogDescription>\n {tWithFallback(\n t,\n 'sandbox.adminTemplates.actions.delete.confirm',\n 'Delete template \"{name}\"? This cannot be undone.',\n { name: pendingDelete?.name ?? '' }\n )}\n </AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel>Cancel</AlertDialogCancel>\n <AlertDialogAction\n className=\"bg-status-error-bg text-status-error-text hover:bg-status-error-bg/90\"\n onClick={() => {\n if (pendingDelete) void performDelete(pendingDelete.id);\n }}\n >\n Delete\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AA+BA,SAAgB,IAAqB;CACnC,IAAM,EAAE,cAAW,KAAK,aAAU,mBAAgB,GAAY,EACxD,EAAE,SAAM,GAAS,EACjB,EAAE,SAAM,YAAS,eAAY,EAA6B;EAC9D,WAAW,EAAE,SAAS,EAAE,gBAAa,EAAE;EACvC,MAAM,CAAC;EACR,CAAC,EACI,CAAC,KAAkB,GAAkC,EACrD,IAAa,GAAM,sBAAsB,SAAS,EAAE,EACpD,CAAC,GAAe,KAAoB,EAA8C,KAAK,EAEvF,UAAqB;AACzB,MAAW,EAAS,GAAU,gBAAgB,CAAC;IAG3C,KAAc,MAAuB;AACzC,MAAW,EAAS,GAAU,aAAa,IAAa,CAAC;IAGrD,IAAgB,OAAO,MAAuB;AAClD,IAAiB,KAAK;AACtB,MAAI;AAIF,GAHA,MAAM,EAAe,EACnB,WAAW;IAAE,SAAS,EAAE,gBAAa;IAAE,IAAI;IAAY,EACxD,CAAC,EACF,MAAM,GAAS;WACR,GAAK;AAEZ,GADA,QAAQ,MAAM,wCAAwC,EAAI,EAC1D,OAAO,MACL,EACE,GACA,+CACA,+CACD,CACF;;;AAIL,QACE,kBAAC,GAAD;EACE,OAAO,EAAc,GAAG,gCAAgC,YAAY;EACpE,UAAU,EACR,GACA,mCACA,mFACD;EACD,MAAM,kBAAC,GAAD,EAAgB,MAAM,IAAM,CAAA;EAClC,eACE,kBAAC,GAAD;GAAQ,SAAS;GAAc,MAAK;aAApC,CACE,kBAAC,GAAD,EAAM,MAAM,IAAM,CAAA,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