@rebasepro/studio 0.34.2 → 0.35.0
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/README.md +1 -1
- package/dist/{ApiExplorer-BhQFd_iR.js → ApiExplorer-C61w8gCc.js} +73 -58
- package/dist/ApiExplorer-C61w8gCc.js.map +1 -0
- package/dist/{ApiKeysView-CLBXUCgu.js → ApiKeysView-BdqASL_2.js} +33 -32
- package/dist/ApiKeysView-BdqASL_2.js.map +1 -0
- package/dist/{BranchesView-BKGhk-PC.js → BranchesView-Bh5lq9T_.js} +5 -5
- package/dist/BranchesView-Bh5lq9T_.js.map +1 -0
- package/dist/{CronJobsView-CwF_m6ZB.js → CronJobsView-DUuyzkJK.js} +392 -8
- package/dist/CronJobsView-DUuyzkJK.js.map +1 -0
- package/dist/FixedEditorOverlay-DtgPBSjq.js +93 -0
- package/dist/FixedEditorOverlay-DtgPBSjq.js.map +1 -0
- package/dist/{JSEditor-Br22PfLh.js → JSEditor-Bi2Aol-Y.js} +27 -21
- package/dist/JSEditor-Bi2Aol-Y.js.map +1 -0
- package/dist/{LogsExplorer-DOLRFQaW.js → LogsExplorer-BA8RfTwd.js} +46 -67
- package/dist/LogsExplorer-BA8RfTwd.js.map +1 -0
- package/dist/{RLSEditor-RE4YpN_z.js → RLSEditor-CTG3jLE7.js} +478 -224
- package/dist/RLSEditor-CTG3jLE7.js.map +1 -0
- package/dist/{SQLEditor-Dj5INEUZ.js → SQLEditor-DRo5kW1h.js} +15 -96
- package/dist/SQLEditor-DRo5kW1h.js.map +1 -0
- package/dist/{SchemaVisualizer-D2_cck4I.js → SchemaVisualizer-Dy4kWKT5.js} +15 -14
- package/dist/SchemaVisualizer-Dy4kWKT5.js.map +1 -0
- package/dist/{StorageView-DHm22S7y.js → StorageView-D0D8z4lI.js} +497 -4
- package/dist/StorageView-D0D8z4lI.js.map +1 -0
- package/dist/TableEditorView-BKhSBG-K.js +1694 -0
- package/dist/TableEditorView-BKhSBG-K.js.map +1 -0
- package/dist/UsersAndRolesView-CKw4SJPj.js +689 -0
- package/dist/UsersAndRolesView-CKw4SJPj.js.map +1 -0
- package/dist/WebhooksView-CFPY-N9h.js +465 -0
- package/dist/WebhooksView-CFPY-N9h.js.map +1 -0
- package/dist/adminFetch-BfOnfRgU.js +108 -0
- package/dist/adminFetch-BfOnfRgU.js.map +1 -0
- package/dist/components/ApiExplorer/TryItPanel.d.ts +6 -0
- package/dist/components/ApiKeys/scope-words.d.ts +1 -1
- package/dist/components/AuthSimulationSelector.d.ts +9 -1
- package/dist/components/CronJobs/DbCronJobsPanel.d.ts +2 -0
- package/dist/components/RLSEditor/DirectRlsPoliciesPanel.d.ts +7 -0
- package/dist/components/RebaseStudio.d.ts +1 -1
- package/dist/components/RebaseStudioApp.d.ts +28 -0
- package/dist/components/SQLEditor/FixedEditorOverlay.d.ts +12 -0
- package/dist/components/SQLEditor/SQLEditor.d.ts +2 -11
- package/dist/components/StorageView/StoragePoliciesPanel.d.ts +2 -0
- package/dist/components/StudioHomePage.d.ts +3 -1
- package/dist/components/TableEditor/TableEditorView.d.ts +2 -0
- package/dist/components/UsersAndRoles/UsersAndRolesView.d.ts +2 -0
- package/dist/components/Webhooks/WebhooksView.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +739 -109
- package/dist/index.es.js.map +1 -1
- package/dist/policy-presets-CJKzAvQp.js +167 -0
- package/dist/policy-presets-CJKzAvQp.js.map +1 -0
- package/dist/{useRunAsUsers-CLaAtXt6.js → useRunAsUsers-CF7tkGzj.js} +22 -3
- package/dist/useRunAsUsers-CF7tkGzj.js.map +1 -0
- package/dist/utils/adminFetch.d.ts +25 -0
- package/package.json +12 -16
- package/dist/ApiExplorer-BhQFd_iR.js.map +0 -1
- package/dist/ApiKeysView-CLBXUCgu.js.map +0 -1
- package/dist/BranchesView-BKGhk-PC.js.map +0 -1
- package/dist/CronJobsView-CwF_m6ZB.js.map +0 -1
- package/dist/JSEditor-Br22PfLh.js.map +0 -1
- package/dist/LogsExplorer-DOLRFQaW.js.map +0 -1
- package/dist/RLSEditor-RE4YpN_z.js.map +0 -1
- package/dist/SQLEditor-Dj5INEUZ.js.map +0 -1
- package/dist/SchemaVisualizer-D2_cck4I.js.map +0 -1
- package/dist/StorageView-DHm22S7y.js.map +0 -1
- package/dist/useRunAsUsers-CLaAtXt6.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiKeysView-BdqASL_2.js","names":[],"sources":["../src/components/ApiKeys/scopes.ts","../src/components/ApiKeys/scope-words.ts","../src/components/ApiKeys/CreateApiKeyDialog.tsx","../src/components/ApiKeys/ApiKeysView.tsx"],"sourcesContent":["/**\n * The pure half of the API-key panel: reading a key's scopes back as groups a\n * person can scan, and turning the create dialog's picker into the scope list\n * the server mints.\n *\n * The vocabulary itself — what a scope is, which ones take a target, which\n * plane each belongs to — is `@rebasepro/types`' `scopes.ts`, the same module\n * the server enforces with. Nothing here re-derives it; this file only shapes\n * it for the screen, so it can be tested without rendering one.\n *\n * @module\n */\n\nimport {\n describeScope,\n isAdminScope,\n isDataPlaneScope,\n KEY_MANAGEMENT_SCOPES,\n parseScope,\n scopeGrantsAny,\n scopeTargets,\n summarizeScopes,\n type ScopeSummary\n} from \"@rebasepro/types\";\n\n/** Which plane a scope belongs to, as `GET /auth/scopes` names it. */\nexport type ScopePlane = ScopeSummary[\"plane\"];\n\n/** The planes in the order the panel shows them. */\nexport const SCOPE_PLANES: readonly ScopePlane[] = [\"data\", \"admin\", \"app\"];\n\n/* ═══════════════════════════════════════════════════════════════\n Reading a key's scopes\n ═══════════════════════════════════════════════════════════════ */\n\n/** One scope a key holds, with every target it holds it on. */\nexport interface HeldScope {\n /** `resource:action`, without a target. */\n scope: string;\n label: string;\n description: string;\n plane: ScopePlane;\n /** What a target names — `collection`, `bucket`, `function`, or an app's own word. */\n targetKind?: string;\n /** `\"all\"` for the unqualified grant, otherwise the targets it is narrowed to. */\n targets: \"all\" | string[];\n}\n\nexport interface ScopeGroup {\n plane: ScopePlane;\n scopes: HeldScope[];\n}\n\nfunction planeOf(scope: string): ScopePlane {\n if (isDataPlaneScope(scope)) return \"data\";\n if (isAdminScope(scope)) return \"admin\";\n return \"app\";\n}\n\n/**\n * A key's scopes, grouped by plane and folded per scope: `data:read:posts` and\n * `data:read:authors` read as one \"Read data\" row narrowed to two collections,\n * and `data:read` beside them as the same row on every collection.\n *\n * Ordered the way the catalogue lists scopes; a scope the catalogue does not\n * know (an app scope removed since the key was minted) keeps its raw name and\n * lands at the end of the plane it would belong to.\n */\nexport function groupKeyScopes(\n scopes: readonly string[],\n catalogue: readonly ScopeSummary[] = summarizeScopes()\n): ScopeGroup[] {\n const bases: string[] = [];\n for (const entry of scopes) {\n const base = parseScope(entry)?.scope ?? entry;\n if (!bases.includes(base)) bases.push(base);\n }\n\n const position = (base: string): number => {\n const index = catalogue.findIndex(summary => summary.scope === base);\n return index < 0 ? catalogue.length + bases.indexOf(base) : index;\n };\n bases.sort((a, b) => position(a) - position(b));\n\n const held: HeldScope[] = bases.map(base => {\n const summary = catalogue.find(entry => entry.scope === base);\n const parsed = parseScope(base);\n const fallback = describeScope(base);\n return {\n scope: base,\n label: summary?.label ?? fallback.label,\n description: summary?.description ?? fallback.description,\n plane: summary?.plane ?? planeOf(base),\n ...(summary?.target ? { targetKind: summary.target } : {}),\n targets: parsed ? scopeTargets(scopes, base) : \"all\"\n };\n });\n\n return SCOPE_PLANES\n .map(plane => ({ plane, scopes: held.filter(entry => entry.plane === plane) }))\n .filter(group => group.scopes.length > 0);\n}\n\n/* ═══════════════════════════════════════════════════════════════\n What the create dialog may offer\n ═══════════════════════════════════════════════════════════════ */\n\n/** Never offered: a key that manages keys could mint its own successor. */\nexport function isKeyManagementScope(scope: string): boolean {\n return (KEY_MANAGEMENT_SCOPES as readonly string[]).includes(scope);\n}\n\n/**\n * The catalogue entries a caller may put on a key: the ones they hold, on at\n * least one target, minus key management. The server refuses anything else\n * (`SCOPE_EXCEEDS_CREATOR`, `KEY_MANAGEMENT_SCOPE`), so offering it would only\n * be a way to fail.\n */\nexport function grantableScopes(catalogue: readonly ScopeSummary[], held: readonly string[]): ScopeSummary[] {\n return catalogue.filter(summary => !isKeyManagementScope(summary.scope) && scopeGrantsAny(held, summary.scope));\n}\n\n/* ═══════════════════════════════════════════════════════════════\n Picker state\n ═══════════════════════════════════════════════════════════════ */\n\n/** For one chosen scope: every target, or only the listed ones. */\nexport type TargetChoice =\n | { mode: \"all\" }\n | { mode: \"some\"; targets: string[] };\n\n/** The chosen scopes, keyed by `resource:action`. A scope absent here is not chosen. */\nexport type ScopeSelection = Readonly<Record<string, TargetChoice>>;\n\n/** `data:read` on everything — the narrowest useful key, and what the dialog opens with. */\nexport function defaultSelection(grantable: readonly ScopeSummary[]): ScopeSelection {\n return grantable.some(summary => summary.scope === \"data:read\") ? { \"data:read\": { mode: \"all\" } } : {};\n}\n\nfunction cleanTargets(targets: readonly string[]): string[] {\n const out: string[] = [];\n for (const raw of targets) {\n const target = raw.trim();\n if (target && !/\\s/.test(target) && !out.includes(target)) out.push(target);\n }\n return out;\n}\n\n/**\n * The scope strings a selection mints, in catalogue order when one is given.\n *\n * A scope on every target is sent unqualified; one narrowed to targets is sent\n * once per target. A scope narrowed to no target at all grants nothing and is\n * left out — {@link incompleteScopes} is how the dialog says so.\n */\nexport function buildScopeList(selection: ScopeSelection, order: readonly string[] = []): string[] {\n const chosen = Object.keys(selection);\n const rank = (scope: string): number => {\n const index = order.indexOf(scope);\n return index < 0 ? order.length + chosen.indexOf(scope) : index;\n };\n const out: string[] = [];\n for (const scope of [...chosen].sort((a, b) => rank(a) - rank(b))) {\n const choice = selection[scope];\n if (choice.mode === \"all\") {\n out.push(scope);\n } else {\n for (const target of cleanTargets(choice.targets)) out.push(`${scope}:${target}`);\n }\n }\n return out;\n}\n\n/** Scopes switched to \"only some\" with nothing chosen yet. */\nexport function incompleteScopes(selection: ScopeSelection): string[] {\n return Object.entries(selection)\n .filter(([, choice]) => choice.mode === \"some\" && cleanTargets(choice.targets).length === 0)\n .map(([scope]) => scope);\n}\n\n/** Free text in a target field: commas or whitespace separate entries. */\nexport function splitList(text: string): string[] {\n return cleanTargets(text.split(/[\\s,]+/));\n}\n\n/* ═══════════════════════════════════════════════════════════════\n The roles a service key runs as\n ═══════════════════════════════════════════════════════════════ */\n\n/**\n * The roles a service key runs as beside `service`: the picked ones, then any\n * typed ones, deduplicated. `service` itself is every service key's identity\n * already, so listing it adds nothing and is dropped, as the server does.\n */\nexport function combineRoles(picked: readonly string[], typed: string): string[] {\n const out: string[] = [];\n for (const role of [...picked, ...splitList(typed)]) {\n const id = role.trim();\n if (id && id !== \"service\" && !out.includes(id)) out.push(id);\n }\n return out;\n}\n\n/* ═══════════════════════════════════════════════════════════════\n Limits\n ═══════════════════════════════════════════════════════════════ */\n\nexport const EXPIRY_CHOICES = [\"never\", \"7d\", \"30d\", \"90d\", \"1y\"] as const;\nexport type ExpiryChoice = (typeof EXPIRY_CHOICES)[number];\n\nconst EXPIRY_DAYS: Record<Exclude<ExpiryChoice, \"never\">, number> = { \"7d\": 7, \"30d\": 30, \"90d\": 90, \"1y\": 365 };\n\nexport function isExpiryChoice(value: string): value is ExpiryChoice {\n return (EXPIRY_CHOICES as readonly string[]).includes(value);\n}\n\n/** The `expires_at` an expiry choice sends: an ISO instant, or null for never. */\nexport function expiresAtFor(choice: ExpiryChoice, now: number = Date.now()): string | null {\n if (choice === \"never\") return null;\n return new Date(now + EXPIRY_DAYS[choice] * 86_400_000).toISOString();\n}\n\n/** The `rate_limit` a rate-limit field sends: a positive integer, or null for the server default. */\nexport function rateLimitFrom(text: string): number | null {\n const digits = text.replace(/\\D/g, \"\");\n if (!digits) return null;\n const value = parseInt(digits, 10);\n return value >= 1 ? value : null;\n}\n\n/* ═══════════════════════════════════════════════════════════════\n What the server answers\n ═══════════════════════════════════════════════════════════════ */\n\n/** The minting refusals the dialog names, beside the server's own message. */\nexport const KEY_ERROR_CODES = [\n \"INVALID_SCOPES\",\n \"SCOPE_EXCEEDS_CREATOR\",\n \"ROLE_EXCEEDS_CREATOR\",\n \"UNKNOWN_SCOPE_TARGET\",\n \"KEY_MANAGEMENT_SCOPE\"\n] as const;\nexport type KeyErrorCode = (typeof KEY_ERROR_CODES)[number];\n\nexport interface KeyError {\n /** One of {@link KEY_ERROR_CODES}, or null for anything else. */\n code: KeyErrorCode | null;\n /** The server's message, never re-worded. */\n message: string;\n}\n\nfunction codeOf(error: unknown): string | null {\n if (typeof error !== \"object\" || error === null || !(\"code\" in error)) return null;\n return typeof error.code === \"string\" ? error.code : null;\n}\n\nfunction isKeyErrorCode(code: string | null): code is KeyErrorCode {\n return code !== null && (KEY_ERROR_CODES as readonly string[]).includes(code);\n}\n\nexport function readKeyError(error: unknown): KeyError {\n const code = codeOf(error);\n return {\n code: isKeyErrorCode(code) ? code : null,\n message: error instanceof Error ? error.message : String(error)\n };\n}\n\n/** The backend answered `403 PERSONAL_KEYS_DISABLED`: the app has not switched them on. */\nexport function isPersonalKeysDisabled(error: unknown): boolean {\n return codeOf(error) === \"PERSONAL_KEYS_DISABLED\";\n}\n\nfunction isStringArray(value: unknown): value is string[] {\n return Array.isArray(value) && value.every(entry => typeof entry === \"string\");\n}\n\nfunction isPlane(value: unknown): value is ScopePlane {\n return value === \"data\" || value === \"admin\" || value === \"app\";\n}\n\nfunction readScopeSummary(value: unknown): ScopeSummary | null {\n if (typeof value !== \"object\" || value === null) return null;\n if (!(\"scope\" in value) || typeof value.scope !== \"string\") return null;\n if (!(\"plane\" in value) || !isPlane(value.plane)) return null;\n const label = \"label\" in value && typeof value.label === \"string\" ? value.label : value.scope;\n const description = \"description\" in value && typeof value.description === \"string\" ? value.description : \"\";\n const target = \"target\" in value && typeof value.target === \"string\" ? value.target : undefined;\n return { scope: value.scope, label, description, plane: value.plane, ...(target ? { target } : {}) };\n}\n\n/** What `GET /auth/scopes` answers. */\nexport interface ScopeListing {\n scopes: ScopeSummary[];\n held: string[];\n}\n\n\n/**\n * Read `GET /auth/scopes`. Null for anything that is not that shape — a backend\n * older than scopes answers this route with something else, and offering a\n * picker built from it would offer scopes the server does not know.\n */\nexport function readScopeListing(body: unknown): ScopeListing | null {\n if (typeof body !== \"object\" || body === null) return null;\n if (!(\"scopes\" in body) || !Array.isArray(body.scopes)) return null;\n if (!(\"held\" in body) || !isStringArray(body.held)) return null;\n const scopes: ScopeSummary[] = [];\n for (const entry of body.scopes) {\n const summary = readScopeSummary(entry);\n if (summary) scopes.push(summary);\n }\n return { scopes, held: body.held };\n}\n\n/** Function names out of `GET /functions` — `{ functions: [{ name }] }`. */\nexport function functionNamesFrom(body: unknown): string[] {\n if (typeof body !== \"object\" || body === null || !(\"functions\" in body) || !Array.isArray(body.functions)) return [];\n const names: string[] = [];\n for (const entry of body.functions) {\n if (typeof entry === \"object\" && entry !== null && \"name\" in entry && typeof entry.name === \"string\" && entry.name) {\n names.push(entry.name);\n }\n }\n return names;\n}\n","/**\n * How the key panel words scopes: plane headings, \"every collection\", the\n * title over a minting refusal. One place, so the detail panel, the create\n * dialog and the secret confirmation cannot drift apart.\n *\n * Every string is a translation key. A built-in scope's label and description\n * are keys too, derived from the scope (`data:read` →\n * `studio_scope_data_read_label`); an app's own scopes are worded as the app\n * declared them, in the server's catalogue (`GET /auth/scopes`).\n *\n * @module\n */\n\nimport { DEFAULT_STORAGE_SOURCE_KEY, isBuiltInScope, type ScopeSummary } from \"@rebasepro/types\";\n\nimport type { HeldScope, KeyErrorCode, ScopePlane } from \"./scopes\";\n\n/** The panel's `t`, from `useTranslation()`. */\nexport type Translate = (key: string, vars?: Record<string, string | number>) => string;\n\n/** `data:read` → `studio_scope_data_read_label`. */\nexport function scopeLabelKey(scope: string): string {\n return `studio_scope_${scope.replace(/[^a-z0-9]/g, \"_\")}_label`;\n}\n\n/** `data:read` → `studio_scope_data_read_description`. */\nexport function scopeDescriptionKey(scope: string): string {\n return `studio_scope_${scope.replace(/[^a-z0-9]/g, \"_\")}_description`;\n}\n\n/** The translation, or `fallback` when the catalogue has none — i18next answers a missing key with the key. */\nfunction translatedOr(t: Translate, key: string, fallback: string): string {\n const text = t(key);\n return text && text !== key ? text : fallback;\n}\n\n/**\n * The catalogue in the panel's language. Built-in scopes are translated; an\n * app scope keeps the label its app declared, and a built-in scope this panel\n * has no key for (one the server added since) keeps the server's wording\n * rather than rendering blank or as a key.\n */\nexport function localizeScopes(t: Translate, catalogue: readonly ScopeSummary[]): ScopeSummary[] {\n return catalogue.map(summary => isBuiltInScope(summary.scope)\n ? {\n ...summary,\n label: translatedOr(t, scopeLabelKey(summary.scope), summary.label),\n description: translatedOr(t, scopeDescriptionKey(summary.scope), summary.description)\n }\n : summary);\n}\n\nexport function planeLabel(t: Translate, plane: ScopePlane): string {\n switch (plane) {\n case \"data\": return t(\"studio_api_keys_plane_data\");\n case \"admin\": return t(\"studio_api_keys_plane_admin\");\n case \"app\": return t(\"studio_api_keys_plane_app\");\n }\n}\n\nexport function planeHint(t: Translate, plane: ScopePlane): string {\n switch (plane) {\n case \"data\": return t(\"studio_api_keys_plane_data_hint\");\n case \"admin\": return t(\"studio_api_keys_plane_admin_hint\");\n case \"app\": return t(\"studio_api_keys_plane_app_hint\");\n }\n}\n\n/** \"Every table\", \"Every storage source\", \"Every function\", \"Any project\". */\nexport function everyTargetLabel(t: Translate, targetKind: string): string {\n switch (targetKind) {\n case \"collection\": return t(\"studio_api_keys_target_all_collection\");\n case \"bucket\": return t(\"studio_api_keys_target_all_bucket\");\n case \"function\": return t(\"studio_api_keys_target_all_function\");\n default: return t(\"studio_api_keys_target_all_other\", { kind: targetKind });\n }\n}\n\n/** One target as a person reads it: the default storage source is \"Default bucket\", not `(default)`. */\nexport function targetLabel(t: Translate, targetKind: string | undefined, target: string): string {\n if (targetKind === \"bucket\" && target === DEFAULT_STORAGE_SOURCE_KEY) return t(\"studio_api_keys_bucket_default\");\n return target;\n}\n\n/** A held scope as one line: \"Read data — posts, authors\", \"Read data — every collection\", \"Read server logs\". */\nexport function heldScopeLine(t: Translate, held: HeldScope): string {\n if (!held.targetKind && held.targets === \"all\") return held.label;\n const reach = held.targets === \"all\"\n ? everyTargetLabel(t, held.targetKind ?? \"\")\n : held.targets.map(target => targetLabel(t, held.targetKind, target)).join(\", \");\n return `${held.label} — ${reach}`;\n}\n\n/** The title over a refused create; the server's own message goes underneath. */\nexport function keyErrorTitle(t: Translate, code: KeyErrorCode | null): string {\n switch (code) {\n case \"INVALID_SCOPES\": return t(\"studio_api_keys_error_invalid_scopes\");\n case \"SCOPE_EXCEEDS_CREATOR\": return t(\"studio_api_keys_error_scope_exceeds_creator\");\n case \"ROLE_EXCEEDS_CREATOR\": return t(\"studio_api_keys_error_role_exceeds_creator\");\n case \"UNKNOWN_SCOPE_TARGET\": return t(\"studio_api_keys_error_unknown_scope_target\");\n case \"KEY_MANAGEMENT_SCOPE\": return t(\"studio_api_keys_error_key_management_scope\");\n case null: return t(\"studio_api_keys_error_generic\");\n }\n}\n","import React, { useEffect, useMemo, useState } from \"react\";\nimport {\n Alert,\n Button,\n Checkbox,\n CircularProgress,\n cls,\n DatabaseIcon,\n defaultBorderMixin,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n iconSize,\n Label,\n MultiSelect,\n MultiSelectItem,\n Select,\n SelectItem,\n ShieldIcon,\n TagIcon,\n TextField,\n Tooltip,\n Typography,\n WrenchIcon\n} from \"@rebasepro/ui\";\nimport {\n useApiBase,\n useApiConfig,\n useRebaseClient,\n useStorageSources,\n useTableDescriptors,\n useTranslation\n} from \"@rebasepro/app\";\nimport {\n DEFAULT_STORAGE_SOURCE_KEY,\n hasAdminRole,\n scopeTargets,\n type ApiKeyKind,\n type ApiKeyWithSecret,\n type RebaseClient,\n type RoleSummary,\n type ScopeSummary\n} from \"@rebasepro/types\";\n\nimport {\n buildScopeList,\n combineRoles,\n defaultSelection,\n EXPIRY_CHOICES,\n expiresAtFor,\n functionNamesFrom,\n grantableScopes,\n groupKeyScopes,\n incompleteScopes,\n isExpiryChoice,\n rateLimitFrom,\n readKeyError,\n SCOPE_PLANES,\n splitList,\n type ExpiryChoice,\n type KeyError,\n type ScopeListing,\n type ScopePlane,\n type ScopeSelection,\n type TargetChoice\n} from \"./scopes\";\nimport { everyTargetLabel, heldScopeLine, keyErrorTitle, localizeScopes, planeHint, planeLabel, type Translate } from \"./scope-words\";\n\n/** The scope catalogue as the panel holds it: still loading, read, or not readable. */\nexport type ScopeListingState =\n | { status: \"loading\" }\n | { status: \"ready\"; listing: ScopeListing }\n | { status: \"failed\"; message: string };\n\n/* ═══════════════════════════════════════════════════════════════\n Section heading\n ═══════════════════════════════════════════════════════════════ */\n\nfunction SectionLabel({ children, hint }: { children: React.ReactNode; hint?: React.ReactNode }) {\n return (\n <div className=\"flex items-baseline gap-2 mb-2\">\n <Typography\n variant=\"label\"\n className=\"text-2xs uppercase tracking-wider font-semibold text-surface-600 dark:text-surface-300\"\n gutterBottom={false}\n >\n {children}\n </Typography>\n {hint && (\n <Typography variant=\"caption\" color=\"secondary\" className=\"text-xs\" gutterBottom={false}>\n {hint}\n </Typography>\n )}\n </div>\n );\n}\n\nexport function PlaneIcon({ plane, className }: { plane: ScopePlane; className?: string }) {\n const Component = plane === \"data\" ? DatabaseIcon : plane === \"admin\" ? WrenchIcon : TagIcon;\n return <Component size={iconSize.smallest} className={className}/>;\n}\n\n/* ═══════════════════════════════════════════════════════════════\n One scope in the picker\n ═══════════════════════════════════════════════════════════════ */\n\ninterface ScopeRowProps {\n summary: ScopeSummary;\n choice: TargetChoice | undefined;\n /** What the caller holds this scope on: every target, or only these. */\n reach: \"all\" | string[];\n /** The targets the panel can list for this scope's kind, or null to type them. */\n options: { value: string; label: string }[] | null;\n draft: string | undefined;\n onToggle: (on: boolean) => void;\n onChoice: (choice: TargetChoice) => void;\n onDraft: (text: string) => void;\n first: boolean;\n t: Translate;\n}\n\nfunction ScopeRow({ summary, choice, reach, options, draft, onToggle, onChoice, onDraft, first, t }: ScopeRowProps) {\n const id = `api-key-scope-${summary.scope.replace(/[^a-z0-9-]/gi, \"-\")}`;\n const targetKind = summary.target;\n const pickable = reach === \"all\" ? options : reach.map(value => ({ value, label: value }));\n return (\n <div className={cls(\"flex flex-col gap-2 px-3 py-2.5\", !first && cls(\"border-t\", defaultBorderMixin))}>\n <div className=\"flex items-start gap-3\">\n {/* The kit's checkbox sits in a 32px hit area; pulled up and left so\n the box lines up with the label's first line and the row's edge. */}\n <div className=\"-my-1.5 -ml-2 shrink-0\">\n <Checkbox id={id} size=\"small\" checked={!!choice} onCheckedChange={onToggle}/>\n </div>\n <Label htmlFor={id} className=\"flex-1 min-w-0 cursor-pointer\">\n <Typography variant=\"body2\" component=\"span\" gutterBottom={false} className=\"block text-[13px] font-medium\">\n {summary.label}\n </Typography>\n {summary.description && (\n <Typography variant=\"caption\" component=\"span\" color=\"secondary\" gutterBottom={false} className=\"block text-xs leading-snug font-normal\">\n {summary.description}\n </Typography>\n )}\n </Label>\n <Typography variant=\"caption\" color=\"disabled\" gutterBottom={false} className=\"font-mono text-xs shrink-0 pt-0.5\">\n {summary.scope}\n </Typography>\n </div>\n\n {choice && targetKind && (\n <div className=\"flex flex-wrap items-center gap-2 pl-9\">\n {reach === \"all\" && (\n <div className=\"w-52 shrink-0\">\n <Select\n size=\"small\"\n fullWidth\n position=\"popper\"\n value={choice.mode}\n aria-label={t(\"studio_api_keys_target_mode\")}\n onValueChange={(mode) => onChoice(mode === \"all\"\n ? { mode: \"all\" }\n : { mode: \"some\", targets: choice.mode === \"some\" ? choice.targets : [] })}\n renderValue={(mode) => mode === \"all\"\n ? everyTargetLabel(t, targetKind)\n : t(\"studio_api_keys_target_some\")}\n >\n <SelectItem value=\"all\">{everyTargetLabel(t, targetKind)}</SelectItem>\n <SelectItem value=\"some\">{t(\"studio_api_keys_target_some\")}</SelectItem>\n </Select>\n </div>\n )}\n {choice.mode === \"some\" && (pickable && pickable.length > 0\n ? (\n <div className=\"flex-1 min-w-[12rem]\">\n <MultiSelect\n size=\"small\"\n className=\"w-full\"\n value={choice.targets}\n placeholder={t(\"studio_api_keys_target_pick\")}\n onValueChange={(targets) => onChoice({ mode: \"some\", targets })}\n >\n {pickable.map(option => (\n <MultiSelectItem key={option.value} value={option.value}>\n {option.label}\n </MultiSelectItem>\n ))}\n </MultiSelect>\n </div>\n )\n : (\n <TextField\n size=\"small\"\n className=\"flex-1 min-w-[12rem]\"\n aria-label={t(\"studio_api_keys_target_typed_placeholder\", { kind: targetKind })}\n placeholder={t(\"studio_api_keys_target_typed_placeholder\", { kind: targetKind })}\n value={draft ?? (choice.mode === \"some\" ? choice.targets.join(\", \") : \"\")}\n onChange={(e) => {\n onDraft(e.target.value);\n onChoice({ mode: \"some\", targets: splitList(e.target.value) });\n }}\n />\n ))}\n </div>\n )}\n </div>\n );\n}\n\n/* ═══════════════════════════════════════════════════════════════\n Create API Key Dialog\n ═══════════════════════════════════════════════════════════════ */\n\nexport function CreateApiKeyDialog({\n kind,\n scopeListing,\n onRetryScopes,\n onClose,\n onCreated\n }: {\n /** A service key for the project, or a personal key for the signed-in account. */\n kind: ApiKeyKind;\n scopeListing: ScopeListingState;\n onRetryScopes: () => void;\n onClose: () => void;\n onCreated: (key: ApiKeyWithSecret) => void;\n}) {\n const client = useRebaseClient<RebaseClient>();\n const { t } = useTranslation();\n const descriptors = useTableDescriptors();\n const storageSources = useStorageSources();\n const apiConfig = useApiConfig();\n const apiBase = useApiBase();\n\n const listing = scopeListing.status === \"ready\" ? scopeListing.listing : null;\n /** Built-in scopes in the panel's language; app scopes as the app declared them. */\n const catalogue = useMemo(() => listing ? localizeScopes(t, listing.scopes) : [], [listing, t]);\n const grantable = useMemo(() => listing ? grantableScopes(catalogue, listing.held) : [], [listing, catalogue]);\n const order = useMemo(() => catalogue.map(summary => summary.scope), [catalogue]);\n\n const [name, setName] = useState(\"\");\n /** Null until the person changes it: the default follows the catalogue once it arrives. */\n const [chosen, setChosen] = useState<ScopeSelection | null>(null);\n const [drafts, setDrafts] = useState<Record<string, string>>({});\n const [pickedRoles, setPickedRoles] = useState<string[]>([]);\n const [typedRoles, setTypedRoles] = useState(\"\");\n const [roleOptions, setRoleOptions] = useState<RoleSummary[]>([]);\n const [rolesUnavailable, setRolesUnavailable] = useState(false);\n const [rateLimit, setRateLimit] = useState(\"\");\n const [expiry, setExpiry] = useState<ExpiryChoice>(\"never\");\n const [creating, setCreating] = useState(false);\n const [error, setError] = useState<KeyError | null>(null);\n\n const selection = chosen ?? defaultSelection(grantable);\n\n /* ── What a target can name, for the scopes that take one ── */\n\n /**\n * The slugs a `data:*` scope can name: the tables the server serves. When\n * it serves none (a runtime older than the route, or the request failed)\n * the target is typed instead — and the server refuses a slug it does not\n * serve.\n */\n const tableSlugs = useMemo(\n () => descriptors.unavailable || descriptors.status === \"error\"\n ? null\n : descriptors.tables\n .map(table => table.slug)\n .sort((a, b) => a.localeCompare(b)),\n [descriptors.unavailable, descriptors.status, descriptors.tables]\n );\n\n const buckets = useMemo(() => {\n const keys = Object.keys(storageSources.sources);\n if (!keys.includes(DEFAULT_STORAGE_SOURCE_KEY)) keys.unshift(DEFAULT_STORAGE_SOURCE_KEY);\n return keys.map(key => ({\n value: key,\n label: storageSources.registry[key]?.label\n ?? (key === DEFAULT_STORAGE_SOURCE_KEY ? t(\"studio_api_keys_bucket_default\") : key)\n }));\n }, [storageSources.sources, storageSources.registry, t]);\n\n /**\n * Served functions, so a key can be narrowed to one by name. Best-effort:\n * a backend that serves none, or refuses the index, leaves the free-text\n * field — and the server refuses a name it does not serve.\n */\n const [functionNames, setFunctionNames] = useState<string[]>([]);\n useEffect(() => {\n if (!apiBase) return;\n let cancelled = false;\n (async () => {\n try {\n const token = await apiConfig?.getAuthToken?.();\n const res = await fetch(`${apiBase}/functions`, {\n headers: token ? { Authorization: `Bearer ${token}` } : undefined\n });\n if (!res.ok) return;\n const names = functionNamesFrom(await res.json());\n if (!cancelled) setFunctionNames(names);\n } catch {\n /* No listing available; the free-text field covers it. */\n }\n })();\n return () => { cancelled = true; };\n }, [apiBase, apiConfig]);\n\n const optionsFor = (summary: ScopeSummary): { value: string; label: string }[] | null => {\n switch (summary.target) {\n case \"collection\": return tableSlugs ? tableSlugs.map(slug => ({ value: slug, label: slug })) : null;\n case \"bucket\": return buckets;\n case \"function\": return functionNames.map(fn => ({ value: fn, label: `${fn}()` }));\n default: return null;\n }\n };\n\n /* ── Roles a service key runs as ── */\n\n useEffect(() => {\n if (kind !== \"service\") return;\n const admin = client?.admin;\n if (!admin) {\n setRolesUnavailable(true);\n return;\n }\n let cancelled = false;\n admin.listRoles()\n .then(res => { if (!cancelled) setRoleOptions(res.roles); })\n .catch(() => { if (!cancelled) setRolesUnavailable(true); });\n return () => { cancelled = true; };\n }, [client, kind]);\n\n /* ── Picker edits ── */\n\n const toggle = (summary: ScopeSummary, on: boolean) => {\n setChosen(current => {\n const next: Record<string, TargetChoice> = { ...(current ?? defaultSelection(grantable)) };\n if (!on) {\n delete next[summary.scope];\n return next;\n }\n const reach = listing ? scopeTargets(listing.held, summary.scope) : \"all\";\n next[summary.scope] = reach === \"all\" ? { mode: \"all\" } : { mode: \"some\", targets: [] };\n return next;\n });\n };\n\n const setChoice = (scope: string, choice: TargetChoice) => {\n setChosen(current => ({ ...(current ?? defaultSelection(grantable)), [scope]: choice }));\n };\n\n /* ── What would be sent ── */\n\n const scopes = buildScopeList(selection, order);\n const incomplete = incompleteScopes(selection);\n const roles = kind === \"service\" ? combineRoles(pickedRoles, typedRoles) : [];\n const runsAsAdmin = hasAdminRole(roles);\n const granted = groupKeyScopes(scopes, catalogue);\n const labelOf = (scope: string) => catalogue.find(summary => summary.scope === scope)?.label ?? scope;\n\n const canSubmit = !!listing && !!name.trim() && scopes.length > 0 && incomplete.length === 0 && !creating;\n const submitBlockedReason = !name.trim()\n ? t(\"studio_api_keys_block_name\")\n : scopes.length === 0\n ? t(\"studio_api_keys_block_scopes\")\n : incomplete.length > 0\n ? t(\"studio_api_keys_block_targets\")\n : \"\";\n\n const handleCreate = async () => {\n if (!canSubmit || !client) return;\n setCreating(true);\n setError(null);\n try {\n const expires_at = expiresAtFor(expiry);\n const created = kind === \"service\"\n ? await client.apiKeys?.createKey({\n name: name.trim(),\n scopes,\n roles,\n rate_limit: rateLimitFrom(rateLimit),\n expires_at\n })\n : await client.personalKeys?.createKey({ name: name.trim(), scopes, expires_at });\n if (!created) {\n setError({ code: null, message: t(\"studio_api_keys_unsupported\") });\n return;\n }\n onCreated(created.key);\n } catch (e: unknown) {\n setError(readKeyError(e));\n } finally {\n setCreating(false);\n }\n };\n\n const planes = SCOPE_PLANES\n .map(plane => ({ plane, scopes: grantable.filter(summary => summary.plane === plane) }))\n .filter(group => group.scopes.length > 0);\n\n return (\n <Dialog open onOpenChange={(open) => { if (!open && !creating) onClose(); }} maxWidth=\"2xl\">\n\n <DialogTitle variant=\"subtitle1\" gutterBottom={false} className=\"font-semibold\">\n {kind === \"service\" ? t(\"studio_api_keys_create_title\") : t(\"studio_api_keys_create_personal_title\")}\n </DialogTitle>\n\n <DialogContent includeMargin={false} className=\"px-8 pt-2 pb-4 flex flex-col gap-6\">\n\n <Typography variant=\"body2\" color=\"secondary\" gutterBottom={false} className=\"text-[13px] max-w-[62ch]\">\n {kind === \"service\" ? t(\"studio_api_keys_create_intro\") : t(\"studio_api_keys_create_personal_intro\")}\n </Typography>\n\n <TextField\n label={t(\"studio_api_keys_field_name\")}\n value={name}\n onChange={(e) => setName(e.target.value)}\n placeholder={t(\"studio_api_keys_field_name_placeholder\")}\n size=\"small\"\n autoFocus\n />\n\n {/* ── Scopes ── */}\n <div>\n <SectionLabel hint={t(\"studio_api_keys_section_scopes_hint\")}>\n {t(\"studio_api_keys_scopes\")}\n </SectionLabel>\n\n {scopeListing.status === \"loading\" && (\n <div className=\"flex justify-center py-6\"><CircularProgress size=\"small\"/></div>\n )}\n\n {scopeListing.status === \"failed\" && (\n <Alert\n color=\"error\"\n size=\"small\"\n action={<Button size=\"small\" variant=\"text\" onClick={onRetryScopes}>{t(\"retry\")}</Button>}\n >\n <Typography variant=\"body2\" gutterBottom={false} className=\"font-medium\">\n {t(\"studio_api_keys_scopes_read_failed\")}\n </Typography>\n {scopeListing.message && (\n <Typography variant=\"caption\" gutterBottom={false} className=\"block font-mono break-all\">\n {scopeListing.message}\n </Typography>\n )}\n </Alert>\n )}\n\n {listing && (\n <div className=\"flex flex-col gap-4\">\n {planes.map(({ plane, scopes: offered }) => (\n <div key={plane}>\n <div className=\"flex items-center gap-2 mb-1.5\">\n <PlaneIcon plane={plane} className=\"text-surface-500 dark:text-surface-400\"/>\n <Typography variant=\"body2\" gutterBottom={false} className=\"text-[13px] font-medium\">\n {planeLabel(t, plane)}\n </Typography>\n <Typography variant=\"caption\" color=\"secondary\" gutterBottom={false} className=\"text-xs truncate\">\n {planeHint(t, plane)}\n </Typography>\n </div>\n <div className={cls(\"rounded-lg border overflow-hidden\", defaultBorderMixin)}>\n {offered.map((summary, index) => (\n <ScopeRow\n key={summary.scope}\n summary={summary}\n choice={selection[summary.scope]}\n reach={scopeTargets(listing.held, summary.scope)}\n options={optionsFor(summary)}\n draft={drafts[summary.scope]}\n onToggle={(on) => toggle(summary, on)}\n onChoice={(choice) => setChoice(summary.scope, choice)}\n onDraft={(text) => setDrafts(current => ({ ...current, [summary.scope]: text }))}\n first={index === 0}\n t={t}\n />\n ))}\n </div>\n </div>\n ))}\n <Typography variant=\"caption\" color=\"secondary\" gutterBottom={false} className=\"text-xs leading-snug max-w-[70ch]\">\n {t(\"studio_api_keys_scopes_offered_note\")}\n </Typography>\n </div>\n )}\n </div>\n\n {/* ── RLS roles ── */}\n {kind === \"service\" && (\n <div>\n <SectionLabel hint={t(\"studio_api_keys_roles_rows_hint\")}>\n {t(\"studio_api_keys_roles\")}\n </SectionLabel>\n <Typography variant=\"caption\" color=\"secondary\" gutterBottom={false} className=\"block mb-3 text-xs leading-snug max-w-[70ch]\">\n {t(\"studio_api_keys_roles_explainer\")}\n </Typography>\n <div className=\"grid grid-cols-1 sm:grid-cols-2 gap-3 items-start\">\n {roleOptions.length > 0 && (\n <div>\n <MultiSelect\n size=\"small\"\n className=\"w-full\"\n label={t(\"roles\")}\n value={pickedRoles}\n onValueChange={setPickedRoles}\n >\n {roleOptions.map(role => (\n <MultiSelectItem key={role.id} value={role.id}>\n {role.name === role.id ? role.id : `${role.name} (${role.id})`}\n </MultiSelectItem>\n ))}\n </MultiSelect>\n </div>\n )}\n <TextField\n size=\"small\"\n label={t(\"studio_api_keys_roles_other\")}\n placeholder={t(\"studio_api_keys_roles_other_placeholder\")}\n value={typedRoles}\n onChange={(e) => setTypedRoles(e.target.value)}\n />\n </div>\n {rolesUnavailable && (\n <Typography variant=\"caption\" color=\"secondary\" gutterBottom={false} className=\"block mt-1.5 text-xs\">\n {t(\"studio_api_keys_roles_unavailable\")}\n </Typography>\n )}\n {runsAsAdmin && (\n <Alert color=\"warning\" size=\"small\" outerClassName=\"mt-3\">\n {t(\"studio_api_keys_roles_admin_warning\")}\n </Alert>\n )}\n </div>\n )}\n\n {/* ── Limits ── */}\n <div>\n <SectionLabel>{t(\"studio_api_keys_section_limits\")}</SectionLabel>\n <div className=\"grid grid-cols-1 sm:grid-cols-2 gap-3 items-end\">\n {/* Each control gets its own cell: `Select.Root` renders no DOM\n node, so an unwrapped Select puts its label and its control\n into two separate grid items. */}\n <div>\n <Select\n label={t(\"studio_api_keys_stat_expires\")}\n value={expiry}\n onValueChange={(value) => { if (isExpiryChoice(value)) setExpiry(value); }}\n size=\"small\"\n fullWidth\n position=\"popper\"\n renderValue={(value) => expiryLabel(t, isExpiryChoice(value) ? value : \"never\")}\n >\n {EXPIRY_CHOICES.map(choice => (\n <SelectItem key={choice} value={choice}>{expiryLabel(t, choice)}</SelectItem>\n ))}\n </Select>\n </div>\n {kind === \"service\" && (\n <div>\n {/* Labelled above rather than floating inside, so it lines\n up with the Select beside it. */}\n <Label\n htmlFor=\"api-key-rate-limit\"\n className=\"block ml-3.5 mb-1 text-text-secondary dark:text-text-secondary-dark\"\n >\n {t(\"studio_api_keys_stat_rate_limit\")}\n </Label>\n <TextField\n id=\"api-key-rate-limit\"\n value={rateLimit}\n onChange={(e) => setRateLimit(e.target.value.replace(/\\D/g, \"\"))}\n placeholder=\"1000\"\n size=\"small\"\n endAdornment={\n <Typography variant=\"caption\" color=\"secondary\" component=\"span\" gutterBottom={false} className=\"text-xs whitespace-nowrap\">\n {t(\"studio_api_keys_rate_limit_unit\")}\n </Typography>\n }\n />\n </div>\n )}\n </div>\n {kind === \"service\" && (\n <Typography variant=\"caption\" color=\"secondary\" gutterBottom={false} className=\"block mt-1.5 text-xs\">\n {t(\"studio_api_keys_rate_limit_hint\")} {t(\"studio_api_keys_rate_limit_scope\")}\n </Typography>\n )}\n </div>\n\n {/* ── Plain-language read-back of the key being built ── */}\n {listing && (\n <div className={cls(\"rounded-lg border px-3 py-2.5 bg-surface-field\", defaultBorderMixin)}>\n <Typography\n variant=\"label\"\n gutterBottom={false}\n className=\"text-2xs uppercase tracking-wider font-semibold text-surface-600 dark:text-surface-300\"\n >\n {t(\"studio_api_keys_summary_title\")}\n </Typography>\n {granted.length === 0\n ? (\n <Typography variant=\"body2\" color=\"secondary\" gutterBottom={false} className=\"mt-1.5 text-[13px]\">\n {t(\"studio_api_keys_summary_empty\")}\n </Typography>\n )\n : (\n <div className=\"mt-1.5 flex flex-col gap-1\">\n {granted.flatMap(group => group.scopes.map(held => (\n <div key={held.scope} className=\"flex items-start gap-2\">\n <PlaneIcon plane={group.plane} className=\"mt-[3px] shrink-0 text-surface-500 dark:text-surface-400\"/>\n <Typography variant=\"body2\" gutterBottom={false} className=\"text-[13px] leading-snug\">\n {heldScopeLine(t, held)}\n </Typography>\n </div>\n )))}\n {kind === \"service\" && roles.length > 0 && (\n <div className=\"flex items-start gap-2\">\n <ShieldIcon\n size={iconSize.smallest}\n className={cls(\"mt-[3px] shrink-0\", runsAsAdmin\n ? \"text-amber-600 dark:text-amber-400\"\n : \"text-surface-500 dark:text-surface-400\")}\n />\n <Typography variant=\"body2\" gutterBottom={false} className=\"text-[13px] leading-snug\">\n {t(\"studio_api_keys_summary_roles\", { roles: [\"service\", ...roles].join(\", \") })}\n </Typography>\n </div>\n )}\n </div>\n )}\n {incomplete.length > 0 && (\n <Typography variant=\"caption\" color=\"secondary\" gutterBottom={false} className=\"block mt-2 text-xs\">\n {incomplete.map(scope => t(\"studio_api_keys_target_missing\", { scope: labelOf(scope) })).join(\" \")}\n </Typography>\n )}\n </div>\n )}\n\n {error && (\n <Alert color=\"error\" size=\"small\">\n <Typography variant=\"body2\" gutterBottom={false} className=\"font-medium\">\n {keyErrorTitle(t, error.code)}\n </Typography>\n <Typography variant=\"caption\" gutterBottom={false} className=\"block leading-snug\">\n {error.message}\n </Typography>\n </Alert>\n )}\n\n </DialogContent>\n\n <DialogActions>\n <Button variant=\"text\" onClick={onClose} disabled={creating}>{t(\"cancel\")}</Button>\n <Tooltip title={submitBlockedReason}>\n <span>\n <Button\n color=\"primary\"\n onClick={handleCreate}\n disabled={!canSubmit}\n startIcon={creating ? <CircularProgress size=\"smallest\"/> : undefined}\n >\n {creating ? t(\"studio_api_keys_creating\") : t(\"studio_api_keys_create\")}\n </Button>\n </span>\n </Tooltip>\n </DialogActions>\n </Dialog>\n );\n}\n\nfunction expiryLabel(t: Translate, choice: ExpiryChoice): string {\n switch (choice) {\n case \"never\": return t(\"studio_api_keys_never\");\n case \"7d\": return t(\"studio_api_keys_expiry_7d\");\n case \"30d\": return t(\"studio_api_keys_expiry_30d\");\n case \"90d\": return t(\"studio_api_keys_expiry_90d\");\n case \"1y\": return t(\"studio_api_keys_expiry_1y\");\n }\n}\n","\nimport React, { useState, useEffect, useRef, useCallback, useMemo } from \"react\";\nimport {\n Alert,\n Button,\n Chip,\n CircularProgress,\n cls,\n defaultBorderMixin,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n IconButton,\n iconSize,\n KeyRoundIcon,\n RefreshCwIcon,\n ShieldIcon,\n Tab,\n Tabs,\n Tooltip,\n Typography,\n CopyIcon,\n PlusIcon as AddIcon,\n Trash2Icon as DeleteIcon,\n AlertCircleIcon,\n CheckCircleIcon\n} from \"@rebasepro/ui\";\nimport { useRebaseClient, useSnackbarController, useStudioCapabilities, useTranslation } from \"@rebasepro/app\";\nimport {\n ADMIN_ROLE,\n hasAdminRole,\n summarizeScopes,\n type ApiKeyKind,\n type ApiKeyMasked,\n type ApiKeyWithSecret,\n type RebaseClient,\n type ScopeSummary\n} from \"@rebasepro/types\";\n\nimport { CreateApiKeyDialog, PlaneIcon, type ScopeListingState } from \"./CreateApiKeyDialog\";\nimport { groupKeyScopes, isPersonalKeysDisabled, readScopeListing, type ScopeGroup } from \"./scopes\";\nimport { everyTargetLabel, heldScopeLine, localizeScopes, planeHint, planeLabel, targetLabel, type Translate } from \"./scope-words\";\nimport { classifyLoadFailure, type LoadFailure } from \"../load-failure\";\nimport { LoadFailureView } from \"../load-failure-view\";\n\n/* ═══════════════════════════════════════════════════════════════\n Helpers\n ═══════════════════════════════════════════════════════════════ */\n\n/** Within a day, relative and in the panel's language; beyond it, the date. */\nfunction formatRelative(iso: string | null | undefined, language: string): string {\n if (!iso) return \"—\";\n const date = new Date(iso);\n const diff = date.getTime() - Date.now();\n const abs = Math.abs(diff);\n try {\n if (abs >= 86_400_000) return date.toLocaleDateString(language);\n const format = new Intl.RelativeTimeFormat(language, { numeric: \"auto\", style: \"short\" });\n if (abs < 3_600_000) return format.format(Math.round(diff / 60_000), \"minute\");\n return format.format(Math.round(diff / 3_600_000), \"hour\");\n } catch {\n return date.toLocaleDateString();\n }\n}\n\nfunction isExpired(key: ApiKeyMasked): boolean {\n return !!(key.expires_at && new Date(key.expires_at) < new Date());\n}\n\ntype KeyStatusKind = \"active\" | \"expired\" | \"revoked\";\n\nfunction keyStatus(key: ApiKeyMasked): { kind: KeyStatusKind; color: string } {\n if (key.revoked_at) return { kind: \"revoked\", color: \"text-red-500\" };\n if (isExpired(key)) return { kind: \"expired\", color: \"text-amber-500\" };\n return { kind: \"active\", color: \"text-emerald-500\" };\n}\n\nfunction statusLabel(t: Translate, kind: KeyStatusKind): string {\n switch (kind) {\n case \"active\": return t(\"studio_api_keys_status_active\");\n case \"expired\": return t(\"studio_api_keys_status_expired\");\n case \"revoked\": return t(\"studio_api_keys_status_revoked\");\n }\n}\n\n/**\n * A service key that runs as `admin`: row-level security does not limit its\n * reads, writes or deletes, and it passes `admin` checks in functions and\n * storage. A personal key has no roles of its own.\n */\nfunction runsAsAdmin(key: ApiKeyMasked): boolean {\n return key.kind === \"service\" && hasAdminRole(key.roles);\n}\n\n/** One short phrase for a list row: the one scope a key holds, or how many. */\nfunction scopeBrief(t: Translate, groups: ScopeGroup[]): string {\n const held = groups.flatMap(group => group.scopes);\n if (held.length === 0) return \"—\";\n if (held.length === 1) return held[0].label;\n return t(\"studio_api_keys_scopes_count\", { count: held.length });\n}\n\n/**\n * The scope catalogue — every scope this backend knows, worded, and what the\n * signed-in account holds. The create dialog offers from it; the detail panel\n * labels a key's scopes with it, and falls back to the built-in wording while\n * it is loading or when this backend does not serve it.\n */\nfunction useScopeListing(client: RebaseClient | undefined): [ScopeListingState, () => void] {\n const [state, setState] = useState<ScopeListingState>({ status: \"loading\" });\n const [attempt, setAttempt] = useState(0);\n\n useEffect(() => {\n const api = client?.personalKeys;\n if (!api) {\n setState({ status: \"failed\", message: \"\" });\n return;\n }\n let cancelled = false;\n setState({ status: \"loading\" });\n (async () => {\n try {\n const listing = readScopeListing(await api.listScopes());\n if (!cancelled) setState(listing ? { status: \"ready\", listing } : { status: \"failed\", message: \"\" });\n } catch (e: unknown) {\n if (!cancelled) setState({ status: \"failed\", message: e instanceof Error ? e.message : String(e) });\n }\n })();\n return () => { cancelled = true; };\n }, [client, attempt]);\n\n const retry = useCallback(() => setAttempt(n => n + 1), []);\n return [state, retry];\n}\n\n/* ═══════════════════════════════════════════════════════════════\n Main Component\n ═══════════════════════════════════════════════════════════════ */\n\nexport function ApiKeysView() {\n const client = useRebaseClient<RebaseClient>();\n const { t } = useTranslation();\n // Under a host whose requests all run as a service key there is no\n // signed-in account to own personal keys: only service keys are shown.\n const serviceIdentity = useStudioCapabilities().requestIdentity !== undefined;\n const [chosenKind, setKind] = useState<ApiKeyKind>(\"service\");\n const kind: ApiKeyKind = serviceIdentity ? \"service\" : chosenKind;\n const [scopeListing, retryScopes] = useScopeListing(client);\n\n const tabs = serviceIdentity ? null : (\n <Tabs\n value={kind}\n onValueChange={(value) => setKind(value === \"personal\" ? \"personal\" : \"service\")}\n variant=\"boxy\"\n className=\"border-b border-hairline px-4 bg-surface-sheet shrink-0\"\n >\n <Tab value=\"service\">{t(\"studio_api_keys_tab_service\")}</Tab>\n <Tab value=\"personal\">{t(\"studio_api_keys_tab_personal\")}</Tab>\n </Tabs>\n );\n\n // Keyed by kind: each tab is its own list, selection and failure.\n return (\n <KeysPane\n key={kind}\n kind={kind}\n tabs={tabs}\n scopeListing={scopeListing}\n onRetryScopes={retryScopes}\n />\n );\n}\n\n/* ═══════════════════════════════════════════════════════════════\n One tab: service keys, or the signed-in account's own\n ═══════════════════════════════════════════════════════════════ */\n\nfunction KeysPane({\n kind,\n tabs,\n scopeListing,\n onRetryScopes\n }: {\n kind: ApiKeyKind;\n tabs: React.ReactNode;\n scopeListing: ScopeListingState;\n onRetryScopes: () => void;\n}) {\n const client = useRebaseClient<RebaseClient>();\n const snackbar = useSnackbarController();\n const { t } = useTranslation();\n const [keys, setKeys] = useState<ApiKeyMasked[]>([]);\n const [loading, setLoading] = useState(true);\n const [selectedId, setSelectedId] = useState<string | null>(null);\n const [showCreate, setShowCreate] = useState(false);\n const [showSecret, setShowSecret] = useState<ApiKeyWithSecret | null>(null);\n const [revoking, setRevoking] = useState<string | null>(null);\n const [confirmRevoke, setConfirmRevoke] = useState<ApiKeyMasked | null>(null);\n /** Why the key listing failed, classified — see `load-failure.ts`. */\n const [failure, setFailure] = useState<LoadFailure | null>(null);\n /** The backend answered PERSONAL_KEYS_DISABLED: a setting, not a failure. */\n const [personalOff, setPersonalOff] = useState(false);\n\n // Built-in scopes in the panel's language; app scopes as the app declared them.\n const catalogue: readonly ScopeSummary[] = useMemo(\n () => localizeScopes(t, scopeListing.status === \"ready\" ? scopeListing.listing.scopes : summarizeScopes()),\n [t, scopeListing]\n );\n\n const clientRef = useRef(client);\n clientRef.current = client;\n const snackbarRef = useRef(snackbar);\n snackbarRef.current = snackbar;\n\n const keysApi = useCallback(() => {\n const c = clientRef.current;\n return kind === \"service\" ? c?.apiKeys : c?.personalKeys;\n }, [kind]);\n\n const loadKeys = useCallback(async () => {\n const api = keysApi();\n if (!api) { setLoading(false); return; }\n try {\n const res = await api.listKeys();\n setKeys(res.keys);\n setFailure(null);\n setPersonalOff(false);\n } catch (e: unknown) {\n // \"No API keys yet\" is a claim about the project. A refused listing\n // is a claim about the caller, and only one of the two is an\n // invitation to create a key. Personal keys switched off is a third\n // thing: the app's own setting, explained rather than reported.\n if (kind === \"personal\" && isPersonalKeysDisabled(e)) {\n setPersonalOff(true);\n setFailure(null);\n } else {\n setFailure(classifyLoadFailure(e));\n }\n } finally {\n setLoading(false);\n }\n }, [keysApi, kind]);\n\n useEffect(() => { loadKeys(); }, [loadKeys]);\n\n const handleRevoke = async (id: string) => {\n const api = keysApi();\n if (!api) return;\n setRevoking(id);\n try {\n await api.revokeKey(id);\n snackbarRef.current.open({ type: \"success\", message: t(\"studio_api_keys_revoked\") });\n await loadKeys();\n if (selectedId === id) setSelectedId(null);\n } catch (e: unknown) {\n snackbarRef.current.open({ type: \"error\", message: e instanceof Error ? e.message : String(e) });\n } finally { setRevoking(null); }\n };\n\n const handleCreated = (keyWithSecret: ApiKeyWithSecret) => {\n setShowCreate(false);\n setShowSecret(keyWithSecret);\n loadKeys();\n };\n\n const selectedKey = keys.find(k => k.id === selectedId);\n const activeKeys = keys.filter(k => !k.revoked_at && !isExpired(k));\n const inactiveKeys = keys.filter(k => k.revoked_at || isExpired(k));\n\n return (\n <>\n {/* The tabs span both panes, as the Cron view's do, so the list's\n header and the key's header start on the same line. */}\n <div className=\"flex flex-col h-full w-full overflow-hidden bg-surface-card\">\n {tabs}\n <div className=\"flex flex-1 min-h-0 w-full overflow-hidden\">\n {/* ── Key List ── */}\n <div className={cls(\"flex flex-col w-[340px] min-w-[280px] border-r h-full\", defaultBorderMixin)}>\n <div className={cls(\"flex items-center justify-between px-4 h-14 shrink-0 border-b bg-surface-sheet\", defaultBorderMixin)}>\n <div className=\"flex items-center gap-2\">\n <KeyRoundIcon size={iconSize.smallest} className=\"text-primary\"/>\n <Typography variant=\"subtitle2\" className=\"font-semibold\">{t(\"studio_tool_api_keys\")}</Typography>\n <Chip size=\"smallest\" className=\"bg-surface-raised text-surface-600 dark:text-surface-300\">{activeKeys.length}</Chip>\n </div>\n <div className=\"flex items-center gap-1\">\n <IconButton aria-label={t(\"studio_api_keys_refresh\")} size=\"small\" onClick={loadKeys} title={t(\"studio_api_keys_refresh\")}><RefreshCwIcon size={iconSize.smallest}/></IconButton>\n <Button\n size=\"small\"\n color=\"primary\"\n disabled={personalOff}\n onClick={() => setShowCreate(true)}\n startIcon={<AddIcon size={iconSize.smallest}/>}\n >\n {t(\"studio_api_keys_new\")}\n </Button>\n </div>\n </div>\n <div className=\"flex-1 overflow-y-auto p-2 space-y-1\">\n {loading && (\n <div className=\"flex items-center justify-center h-full\"><CircularProgress/></div>\n )}\n {!loading && failure && (\n <LoadFailureView\n failure={failure}\n title={kind === \"service\" ? t(\"studio_api_keys_read_failed\") : t(\"studio_api_keys_personal_read_failed\")}\n deniedTitle={kind === \"service\" ? t(\"studio_api_keys_denied_title\") : t(\"studio_api_keys_personal_denied_title\")}\n deniedHint={kind === \"service\" ? t(\"studio_api_keys_denied_hint\") : t(\"studio_api_keys_personal_denied_hint\")}\n onRetry={loadKeys}\n />\n )}\n {!loading && personalOff && <PersonalKeysOff/>}\n {!loading && !failure && !personalOff && activeKeys.length === 0 && inactiveKeys.length === 0 && (\n <div className=\"flex flex-col items-center justify-center h-full gap-3 text-center p-6\">\n <KeyRoundIcon size={iconSize.medium} className=\"text-surface-300 dark:text-surface-600\"/>\n <Typography variant=\"body2\" color=\"secondary\">\n {kind === \"service\" ? t(\"studio_api_keys_empty_title\") : t(\"studio_api_keys_personal_empty_title\")}\n </Typography>\n <Typography variant=\"caption\" color=\"disabled\">\n {kind === \"service\" ? t(\"studio_api_keys_empty_hint\") : t(\"studio_api_keys_personal_empty_hint\")}\n </Typography>\n </div>\n )}\n {!loading && activeKeys.map(key => (\n <KeyListItem key={key.id} apiKey={key} catalogue={catalogue} selected={selectedId === key.id} onClick={() => setSelectedId(key.id)}/>\n ))}\n {!loading && inactiveKeys.length > 0 && (\n <>\n <div className=\"px-2 pt-3 pb-1\">\n <Typography variant=\"caption\" color=\"disabled\" className=\"text-[10px] uppercase tracking-wider font-medium\">{t(\"studio_api_keys_inactive_heading\")}</Typography>\n </div>\n {inactiveKeys.map(key => (\n <KeyListItem key={key.id} apiKey={key} catalogue={catalogue} selected={selectedId === key.id} onClick={() => setSelectedId(key.id)}/>\n ))}\n </>\n )}\n </div>\n </div>\n\n {/* ── Detail Panel ── */}\n <div className=\"flex-1 flex flex-col min-w-0 h-full overflow-hidden\">\n {!selectedKey ? (\n <div className=\"flex items-center justify-center h-full\">\n {!personalOff && (\n <Typography variant=\"body2\" color=\"disabled\">{t(\"studio_api_keys_select_hint\")}</Typography>\n )}\n </div>\n ) : (\n <KeyDetail\n apiKey={selectedKey}\n catalogue={catalogue}\n revoking={revoking === selectedKey.id}\n onRevoke={() => setConfirmRevoke(selectedKey)}\n />\n )}\n </div>\n </div>\n </div>\n\n {/* Revoke Confirmation Dialog */}\n <Dialog\n open={confirmRevoke !== null}\n onOpenChange={(open) => {\n if (!open && !revoking) setConfirmRevoke(null);\n }}\n >\n <DialogTitle hidden>{t(\"studio_api_keys_revoke_confirmation\")}</DialogTitle>\n <DialogContent>\n <Typography variant=\"subtitle1\" className=\"font-semibold mb-2\">\n {t(\"studio_api_keys_revoke_title\", { name: confirmRevoke?.name ?? \"\" })}\n </Typography>\n <Typography variant=\"body2\" color=\"secondary\">\n {t(\"studio_api_keys_revoke_body\")}\n </Typography>\n </DialogContent>\n <DialogActions>\n <Button\n variant=\"text\"\n onClick={() => setConfirmRevoke(null)}\n disabled={revoking !== null}\n >\n {t(\"cancel\")}\n </Button>\n <Button\n color=\"error\"\n disabled={revoking !== null}\n startIcon={revoking !== null ? <CircularProgress size=\"smallest\"/> : <DeleteIcon size={iconSize.smallest}/>}\n onClick={async () => {\n if (!confirmRevoke) return;\n await handleRevoke(confirmRevoke.id);\n setConfirmRevoke(null);\n }}\n >\n {t(\"studio_api_keys_revoke\")}\n </Button>\n </DialogActions>\n </Dialog>\n\n {/* Create Dialog */}\n {showCreate && (\n <CreateApiKeyDialog\n kind={kind}\n scopeListing={scopeListing}\n onRetryScopes={onRetryScopes}\n onClose={() => setShowCreate(false)}\n onCreated={handleCreated}\n />\n )}\n\n {/* Secret Display Dialog */}\n {showSecret && (\n <SecretDisplayDialog\n keyWithSecret={showSecret}\n catalogue={catalogue}\n onClose={() => setShowSecret(null)}\n />\n )}\n </>\n );\n}\n\n/* ═══════════════════════════════════════════════════════════════\n Personal keys switched off\n ═══════════════════════════════════════════════════════════════ */\n\n/**\n * Not an error and not a refusal of this person: the app has not enabled\n * personal keys. Says what they are and where the switch is.\n */\nfunction PersonalKeysOff() {\n const { t } = useTranslation();\n return (\n <div className=\"flex flex-col items-center justify-center h-full gap-3 text-center p-6\">\n <KeyRoundIcon size={iconSize.medium} className=\"text-surface-300 dark:text-surface-600\"/>\n <Typography variant=\"body2\" color=\"secondary\">{t(\"studio_api_keys_personal_off_title\")}</Typography>\n <Typography variant=\"caption\" color=\"disabled\" className=\"max-w-[34ch]\">\n {t(\"studio_api_keys_personal_off_body\")}\n </Typography>\n <Typography variant=\"mono\" component=\"div\" className=\"text-xs px-2 py-1 rounded-md bg-surface-field\">\n {\"auth: { personalKeys: true }\"}\n </Typography>\n </div>\n );\n}\n\n/* ═══════════════════════════════════════════════════════════════\n List item\n ═══════════════════════════════════════════════════════════════ */\n\n/**\n * Marks a service key that runs as the admin role.\n *\n * Not cosmetic: such a key reads, changes and deletes every row its scopes\n * reach through the admin policies, and without this it is indistinguishable\n * in the list from a narrow one.\n */\nfunction AdminChip() {\n const { t } = useTranslation();\n return (\n <Tooltip title={t(\"studio_api_keys_admin_chip_tooltip\")}>\n <Chip size=\"smallest\" colorScheme=\"yellow\" className=\"shrink-0\" icon={<ShieldIcon size={10}/>}>\n {ADMIN_ROLE}\n </Chip>\n </Tooltip>\n );\n}\n\nfunction KeyListItem({ apiKey, catalogue, selected, onClick }: {\n apiKey: ApiKeyMasked;\n catalogue: readonly ScopeSummary[];\n selected: boolean;\n onClick: () => void;\n}) {\n const { t } = useTranslation();\n const status = keyStatus(apiKey);\n return (\n <div\n onClick={onClick}\n className={cls(\n \"flex items-center gap-3 px-3 py-2.5 rounded-lg cursor-pointer transition-all\",\n selected\n ? \"bg-primary/10 dark:bg-primary/15 ring-1 ring-primary/30\"\n : \"hover:bg-surface-hover\"\n )}\n >\n <div className={cls(\"w-2 h-2 rounded-full shrink-0\",\n status.kind === \"active\" ? \"bg-emerald-400\" :\n status.kind === \"expired\" ? \"bg-amber-400\" : \"bg-red-400\"\n )}/>\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-center gap-1.5 min-w-0\">\n <Typography variant=\"body2\" className=\"truncate font-medium text-[13px]\">{apiKey.name}</Typography>\n {runsAsAdmin(apiKey) && <AdminChip/>}\n </div>\n <Typography variant=\"caption\" color=\"secondary\" className=\"truncate text-xs font-mono\">{apiKey.key_prefix}•••</Typography>\n </div>\n <div className=\"shrink-0\">\n <Typography variant=\"caption\" color=\"disabled\" className=\"text-xs\">\n {scopeBrief(t, groupKeyScopes(apiKey.scopes, catalogue))}\n </Typography>\n </div>\n </div>\n );\n}\n\n/* ═══════════════════════════════════════════════════════════════\n Detail\n ═══════════════════════════════════════════════════════════════ */\n\nfunction KeyDetail({ apiKey, catalogue, revoking, onRevoke }: {\n apiKey: ApiKeyMasked;\n catalogue: readonly ScopeSummary[];\n revoking: boolean;\n onRevoke: () => void;\n}) {\n const { t, i18n } = useTranslation();\n const language = i18n.language;\n const status = keyStatus(apiKey);\n const groups = groupKeyScopes(apiKey.scopes, catalogue);\n const service = apiKey.kind === \"service\";\n\n return (\n <>\n {/* Header */}\n <div className={cls(\"flex items-center justify-between px-5 h-14 shrink-0 border-b bg-surface-sheet\", defaultBorderMixin)}>\n <div className=\"flex items-center gap-3 min-w-0\">\n <KeyRoundIcon size={iconSize.small} className=\"text-primary shrink-0\"/>\n <div className=\"min-w-0\">\n <div className=\"flex items-center gap-2 min-w-0\">\n <Typography variant=\"subtitle1\" className=\"font-semibold truncate\">{apiKey.name}</Typography>\n {runsAsAdmin(apiKey) && <AdminChip/>}\n </div>\n <Typography variant=\"caption\" color=\"secondary\" className=\"font-mono text-xs\">{apiKey.key_prefix}•••</Typography>\n </div>\n </div>\n <div className=\"flex items-center gap-2 shrink-0\">\n {!apiKey.revoked_at && (\n <Button\n size=\"small\"\n color=\"error\"\n variant=\"outlined\"\n onClick={onRevoke}\n disabled={revoking}\n startIcon={revoking ? <CircularProgress size=\"smallest\"/> : <DeleteIcon size={iconSize.smallest}/>}\n >\n {t(\"studio_api_keys_revoke\")}\n </Button>\n )}\n </div>\n </div>\n\n {/* Stats */}\n <div className=\"px-5 py-4 bg-surface-sheet\">\n <div className=\"grid grid-cols-2 md:grid-cols-4 gap-3\">\n <StatCard label={t(\"studio_api_keys_stat_status\")} value={statusLabel(t, status.kind)} className={status.color}/>\n <StatCard label={t(\"created\")} value={formatRelative(apiKey.created_at, language)}/>\n <StatCard label={t(\"studio_api_keys_stat_last_used\")} value={formatRelative(apiKey.last_used_at, language)}/>\n <StatCard label={t(\"studio_api_keys_stat_expires\")} value={apiKey.expires_at ? formatRelative(apiKey.expires_at, language) : t(\"studio_api_keys_never\")}/>\n </div>\n <div className=\"grid grid-cols-2 md:grid-cols-3 gap-3 mt-3\">\n <StatCard\n label={t(\"studio_api_keys_stat_kind\")}\n value={service ? t(\"studio_api_keys_kind_service\") : t(\"studio_api_keys_kind_personal\")}\n />\n <StatCard\n label={t(\"studio_api_keys_stat_rate_limit\")}\n value={apiKey.rate_limit\n ? t(\"studio_api_keys_rate_limit_value\", { limit: apiKey.rate_limit })\n : t(\"studio_api_keys_rate_limit_default\")}\n />\n {service\n ? <StatCard label={t(\"studio_api_keys_stat_created_by\")} value={apiKey.created_by} mono/>\n : <StatCard label={t(\"studio_api_keys_stat_owner\")} value={apiKey.owner_uid ?? \"—\"} mono/>}\n </div>\n <Typography variant=\"caption\" color=\"secondary\" className=\"block mt-2 text-xs leading-snug\">\n {t(\"studio_api_keys_rate_limit_scope\")}\n </Typography>\n </div>\n\n {/* Scopes */}\n <div className={cls(\"flex items-center gap-2 px-5 py-2 border-y bg-surface-card\", defaultBorderMixin)}>\n <Typography variant=\"subtitle2\" className=\"font-semibold text-[13px]\">{t(\"studio_api_keys_scopes\")}</Typography>\n <Chip size=\"smallest\" className=\"bg-surface-raised text-surface-600 dark:text-surface-300\">\n {apiKey.scopes.length}\n </Chip>\n </div>\n <div className=\"flex-1 overflow-y-auto px-5 py-3 flex flex-col gap-5\">\n <RolesBlock apiKey={apiKey}/>\n {groups.length === 0\n ? <Typography variant=\"body2\" color=\"disabled\">{t(\"studio_api_keys_no_scopes\")}</Typography>\n : groups.map(group => (\n <div key={group.plane}>\n <BlockHeading\n icon={<PlaneIcon plane={group.plane} className=\"text-surface-500 dark:text-surface-400\"/>}\n label={planeLabel(t, group.plane)}\n hint={planeHint(t, group.plane)}\n />\n <div className=\"space-y-2\">\n {group.scopes.map(held => (\n <div key={held.scope} className={cls(\"flex items-center gap-3 px-3 py-2 rounded-lg border\", defaultBorderMixin)}>\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-baseline gap-2 min-w-0\">\n <Typography variant=\"body2\" className=\"text-[13px] font-medium truncate\">\n {held.label}\n </Typography>\n <Typography variant=\"caption\" color=\"disabled\" className=\"font-mono text-xs shrink-0\">\n {held.scope}\n </Typography>\n </div>\n {held.description && (\n <Typography variant=\"caption\" color=\"secondary\" className=\"block text-xs leading-snug\">\n {held.description}\n </Typography>\n )}\n </div>\n {held.targetKind && (\n <div className=\"flex flex-wrap justify-end gap-1 shrink-0 max-w-[50%]\">\n {held.targets === \"all\"\n ? (\n <Chip size=\"smallest\" className=\"bg-surface-raised text-surface-600 dark:text-surface-300\">\n {everyTargetLabel(t, held.targetKind)}\n </Chip>\n )\n : held.targets.map(target => (\n <Chip key={target} size=\"smallest\" className=\"font-mono bg-surface-raised text-surface-700 dark:text-surface-200\">\n {targetLabel(t, held.targetKind, target)}\n </Chip>\n ))}\n </div>\n )}\n </div>\n ))}\n </div>\n </div>\n ))}\n </div>\n </>\n );\n}\n\nfunction BlockHeading({ icon, label, hint }: { icon: React.ReactNode; label: string; hint: string }) {\n return (\n <div className=\"flex items-center gap-2 mb-2 min-w-0\">\n {icon}\n <Typography variant=\"body2\" className=\"text-[13px] font-medium shrink-0\">{label}</Typography>\n <Typography variant=\"caption\" color=\"secondary\" className=\"text-xs truncate\">{hint}</Typography>\n </div>\n );\n}\n\n/**\n * Who the key runs as — which rows it reads. Scopes, below it, are which\n * endpoints it may call; the two are separate and both are shown.\n */\nfunction RolesBlock({ apiKey }: { apiKey: ApiKeyMasked }) {\n const { t } = useTranslation();\n const shield = <ShieldIcon size={iconSize.smallest} className=\"text-surface-500 dark:text-surface-400\"/>;\n\n if (apiKey.kind === \"personal\") {\n return (\n <div>\n <BlockHeading icon={shield} label={t(\"studio_api_keys_roles\")} hint={t(\"studio_api_keys_roles_rows_hint\")}/>\n <Typography variant=\"caption\" color=\"secondary\" className=\"block text-[12px] leading-snug\">\n {t(\"studio_api_keys_personal_roles\")}\n </Typography>\n </div>\n );\n }\n\n return (\n <div>\n <BlockHeading icon={shield} label={t(\"studio_api_keys_roles\")} hint={t(\"studio_api_keys_roles_rows_hint\")}/>\n <div className=\"flex flex-wrap gap-1.5\">\n <Chip size=\"small\" className=\"font-mono bg-surface-raised text-surface-600 dark:text-surface-300\">service</Chip>\n {apiKey.roles.map(role => (\n <Chip\n key={role}\n size=\"small\"\n colorScheme={role === ADMIN_ROLE ? \"yellow\" : undefined}\n className={cls(\"font-mono\", role !== ADMIN_ROLE && \"bg-surface-raised text-surface-700 dark:text-surface-200\")}\n >\n {role}\n </Chip>\n ))}\n </div>\n {runsAsAdmin(apiKey)\n ? (\n <Alert color=\"warning\" size=\"small\" outerClassName=\"mt-2\">\n {t(\"studio_api_keys_admin_bypasses_rls\")}\n </Alert>\n )\n : (\n <Typography variant=\"caption\" color=\"secondary\" className=\"block mt-1.5 text-xs leading-snug\">\n {apiKey.roles.length === 0 ? t(\"studio_api_keys_roles_service_only\") : t(\"studio_api_keys_roles_service_plus\")}\n </Typography>\n )}\n </div>\n );\n}\n\n/* ═══════════════════════════════════════════════════════════════\n Stat card\n ═══════════════════════════════════════════════════════════════ */\n\nfunction StatCard({ label, value, mono, className }: { label: string; value: string; mono?: boolean; className?: string }) {\n return (\n <div className={cls(\"px-3 py-2 rounded-lg border bg-surface-card\", defaultBorderMixin)}>\n <Typography variant=\"caption\" color=\"secondary\" className=\"text-[10px] uppercase tracking-wider font-medium\">{label}</Typography>\n <Typography variant=\"body2\" className={cls(\n \"mt-0.5 font-semibold text-[13px] truncate\",\n mono && \"font-mono\",\n className\n )}>{value}</Typography>\n </div>\n );\n}\n\n/* ═══════════════════════════════════════════════════════════════\n Secret Display Dialog — shown exactly once after creation\n ═══════════════════════════════════════════════════════════════ */\n\nfunction SecretDisplayDialog({ keyWithSecret, catalogue, onClose }: {\n keyWithSecret: ApiKeyWithSecret;\n catalogue: readonly ScopeSummary[];\n onClose: () => void;\n}) {\n const { t } = useTranslation();\n const snackbar = useSnackbarController();\n const [copied, setCopied] = useState(false);\n const granted = groupKeyScopes(keyWithSecret.scopes, catalogue).flatMap(group => group.scopes);\n\n const handleCopy = async () => {\n try {\n await navigator.clipboard.writeText(keyWithSecret.key);\n setCopied(true);\n snackbar.open({ type: \"success\", message: t(\"studio_api_keys_copied\") });\n setTimeout(() => setCopied(false), 2000);\n } catch {\n snackbar.open({ type: \"error\", message: t(\"studio_api_keys_copy_failed\") });\n }\n };\n\n return (\n <Dialog open onOpenChange={(open) => { if (!open) onClose(); }} maxWidth=\"md\">\n <DialogTitle>\n <div className=\"flex items-center gap-2\">\n <CheckCircleIcon size={iconSize.small} className=\"text-emerald-500\"/>\n {t(\"studio_api_keys_created_title\")}\n </div>\n </DialogTitle>\n <DialogContent>\n <div className=\"p-3 rounded-lg bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800/50 mb-4\">\n <div className=\"flex items-center gap-2 mb-1\">\n <AlertCircleIcon size={iconSize.smallest} className=\"text-amber-600 dark:text-amber-400\"/>\n <Typography variant=\"caption\" className=\"font-semibold text-amber-700 dark:text-amber-400\">\n {t(\"studio_api_keys_copy_now\")}\n </Typography>\n </div>\n <Typography variant=\"caption\" className=\"text-amber-600 dark:text-amber-300\">\n {t(\"studio_api_keys_copy_now_hint\")}\n </Typography>\n </div>\n\n <div className={cls(\"flex items-center gap-2 p-3 rounded-lg border bg-surface-sheet\", defaultBorderMixin)}>\n <code className=\"flex-1 text-[12px] font-mono break-all text-surface-700 dark:text-surface-300 select-all\">\n {keyWithSecret.key}\n </code>\n <Tooltip title={copied ? t(\"copied\") : t(\"copy\")}>\n <IconButton aria-label={copied ? t(\"copied\") : t(\"copy\")} size=\"small\" onClick={handleCopy}>\n {copied\n ? <CheckCircleIcon size={iconSize.smallest} className=\"text-emerald-500\"/>\n : <CopyIcon size={iconSize.smallest}/>\n }\n </IconButton>\n </Tooltip>\n </div>\n\n <div className=\"mt-4 space-y-1\">\n <Typography variant=\"caption\" color=\"secondary\" className=\"block\">\n <strong>{t(\"studio_api_keys_name_label\")}</strong> {keyWithSecret.name}\n </Typography>\n <Typography variant=\"caption\" color=\"secondary\" className=\"block\">\n <strong>{t(\"studio_api_keys_access_label\")}</strong>{\" \"}\n {granted.length > 0 ? granted.map(held => heldScopeLine(t, held)).join(\"; \") : \"—\"}\n </Typography>\n {runsAsAdmin(keyWithSecret) && (\n <Typography variant=\"caption\" className=\"flex items-center gap-1.5 text-amber-700 dark:text-amber-300\">\n <ShieldIcon size={iconSize.smallest} className=\"shrink-0\"/>\n <span><strong>{t(\"studio_api_keys_admin_granted\")}</strong> — {t(\"studio_api_keys_admin_granted_hint\")}</span>\n </Typography>\n )}\n </div>\n </DialogContent>\n <DialogActions>\n <Button color=\"primary\" onClick={onClose}>{t(\"studio_api_keys_done\")}</Button>\n </DialogActions>\n </Dialog>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA6BA,IAAa,eAAsC;CAAC;CAAQ;CAAS;AAAK;AAwB1E,SAAS,QAAQ,OAA2B;CACxC,IAAI,iBAAiB,KAAK,GAAG,OAAO;CACpC,IAAI,aAAa,KAAK,GAAG,OAAO;CAChC,OAAO;AACX;;;;;;;;;;AAWA,SAAgB,eACZ,QACA,YAAqC,gBAAgB,GACzC;CACZ,MAAM,QAAkB,CAAC;CACzB,KAAK,MAAM,SAAS,QAAQ;EACxB,MAAM,OAAO,WAAW,KAAK,CAAC,EAAE,SAAS;EACzC,IAAI,CAAC,MAAM,SAAS,IAAI,GAAG,MAAM,KAAK,IAAI;CAC9C;CAEA,MAAM,YAAY,SAAyB;EACvC,MAAM,QAAQ,UAAU,WAAU,YAAW,QAAQ,UAAU,IAAI;EACnE,OAAO,QAAQ,IAAI,UAAU,SAAS,MAAM,QAAQ,IAAI,IAAI;CAChE;CACA,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,SAAS,CAAC,CAAC;CAE9C,MAAM,OAAoB,MAAM,KAAI,SAAQ;EACxC,MAAM,UAAU,UAAU,MAAK,UAAS,MAAM,UAAU,IAAI;EAC5D,MAAM,SAAS,WAAW,IAAI;EAC9B,MAAM,WAAW,cAAc,IAAI;EACnC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EAAA,UAAA;QAAM,oBAAC,UAAD,EAAA,UAAS,EAAE,+BAA+B,EAAU,CAAA;QAAC;QAAI,EAAE,oCAAoC;OAAQ,EAAA,CAAA,CACrG;;KAEf;;GACM,EAAA,CAAA;GACf,oBAAC,eAAD,EAAA,UACI,oBAAC,QAAD;IAAQ,OAAM;IAAU,SAAS;cAAU,EAAE,sBAAsB;GAAU,CAAA,EAClE,CAAA;EACX;;AAEhB"}
|
|
@@ -144,12 +144,12 @@ function BranchDiffView({ branch, details, onMerged }) {
|
|
|
144
144
|
className: "flex flex-col flex-1 min-h-0",
|
|
145
145
|
children: [
|
|
146
146
|
/* @__PURE__ */ jsxs("div", {
|
|
147
|
-
className: "flex items-end justify-between gap-3 px-5
|
|
147
|
+
className: "flex items-end justify-between gap-3 px-5 border-b border-hairline bg-surface-sheet shrink-0",
|
|
148
148
|
children: [/* @__PURE__ */ jsxs(Tabs, {
|
|
149
149
|
value: tab,
|
|
150
150
|
onValueChange: (value) => setTab(value === "data" || value === "details" ? value : "schema"),
|
|
151
151
|
variant: "boxy",
|
|
152
|
-
className: "
|
|
152
|
+
className: "flex-1 min-w-0",
|
|
153
153
|
children: [
|
|
154
154
|
/* @__PURE__ */ jsxs(Tab, {
|
|
155
155
|
value: "schema",
|
|
@@ -880,7 +880,7 @@ function BranchesView() {
|
|
|
880
880
|
/* @__PURE__ */ jsxs("div", {
|
|
881
881
|
className: cls("flex flex-col w-[340px] min-w-[280px] border-r h-full", defaultBorderMixin),
|
|
882
882
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
883
|
-
className: cls("flex items-center justify-between px-4
|
|
883
|
+
className: cls("flex items-center justify-between px-4 h-14 shrink-0 border-b bg-surface-sheet", defaultBorderMixin),
|
|
884
884
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
885
885
|
className: "flex items-center gap-2",
|
|
886
886
|
children: [
|
|
@@ -989,7 +989,7 @@ function BranchesView() {
|
|
|
989
989
|
children: branches.length === 0 ? t("studio_branches_empty_detail") : t("studio_branches_select_prompt")
|
|
990
990
|
})]
|
|
991
991
|
}) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
|
|
992
|
-
className: cls("flex items-center justify-between px-5
|
|
992
|
+
className: cls("flex items-center justify-between px-5 h-14 shrink-0 border-b bg-surface-sheet", defaultBorderMixin),
|
|
993
993
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
994
994
|
className: "flex items-center gap-3 min-w-0",
|
|
995
995
|
children: [/* @__PURE__ */ jsx("div", { className: "w-2.5 h-2.5 rounded-full bg-emerald-500" }), /* @__PURE__ */ jsxs("div", {
|
|
@@ -1256,4 +1256,4 @@ function StatCard({ label, value, mono }) {
|
|
|
1256
1256
|
//#endregion
|
|
1257
1257
|
export { BranchesView };
|
|
1258
1258
|
|
|
1259
|
-
//# sourceMappingURL=BranchesView-
|
|
1259
|
+
//# sourceMappingURL=BranchesView-Bh5lq9T_.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BranchesView-Bh5lq9T_.js","names":[],"sources":["../src/components/Branches/split-line-diff.ts","../src/components/Branches/BranchDiffView.tsx","../src/components/Branches/BranchesView.tsx"],"sourcesContent":["/**\n * Two texts as the rows of a side-by-side diff: what the target has on the\n * left, what the branch has on the right, an unchanged line on both.\n *\n * A longest-common-subsequence over lines. The texts are one table's\n * `CREATE TABLE` or one policy — tens of lines — so the quadratic table is\n * nothing, and exact beats a heuristic that can pair the wrong lines.\n */\nexport interface SplitDiffRow {\n /** The target's line, or `null` where the branch added one. */\n left: string | null;\n /** The branch's line, or `null` where it removed one. */\n right: string | null;\n /** Whether the two sides hold the same line. */\n same: boolean;\n}\n\nexport function splitLineDiff(before: string | undefined, after: string | undefined): SplitDiffRow[] {\n const a = before === undefined ? [] : before.split(\"\\n\");\n const b = after === undefined ? [] : after.split(\"\\n\");\n\n // lcs[i][j]: the common lines of a[i..] and b[j..].\n const lcs: number[][] = Array.from({ length: a.length + 1 }, () => new Array<number>(b.length + 1).fill(0));\n for (let i = a.length - 1; i >= 0; i -= 1) {\n for (let j = b.length - 1; j >= 0; j -= 1) {\n lcs[i][j] = a[i] === b[j] ? lcs[i + 1][j + 1] + 1 : Math.max(lcs[i + 1][j], lcs[i][j + 1]);\n }\n }\n\n const rows: SplitDiffRow[] = [];\n let removed: string[] = [];\n let added: string[] = [];\n // A run of removals and additions becomes rows side by side, so a changed\n // line sits next to what replaced it.\n const flush = () => {\n for (let k = 0; k < Math.max(removed.length, added.length); k += 1) {\n rows.push({ left: removed[k] ?? null, right: added[k] ?? null, same: false });\n }\n removed = [];\n added = [];\n };\n let i = 0;\n let j = 0;\n while (i < a.length || j < b.length) {\n if (i < a.length && j < b.length && a[i] === b[j]) {\n flush();\n rows.push({ left: a[i], right: b[j], same: true });\n i += 1;\n j += 1;\n } else if (j < b.length && (i >= a.length || lcs[i][j + 1] >= lcs[i + 1][j])) {\n added.push(b[j]);\n j += 1;\n } else {\n removed.push(a[i]);\n i += 1;\n }\n }\n flush();\n return rows;\n}\n","import React, { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport {\n Alert,\n Button,\n Checkbox,\n Chip,\n CircularProgress,\n cls,\n defaultBorderMixin,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n GitMergeIcon,\n IconButton,\n iconSize,\n Label,\n RadioGroup,\n RadioGroupItem,\n RefreshCwIcon,\n Tab,\n Table,\n TableBody,\n TableCell,\n TableHeader,\n TableRow,\n Tabs,\n Typography\n} from \"@rebasepro/ui\";\nimport type { ChipColorKey } from \"@rebasepro/ui\";\nimport { useApiBase, useApiConfig, useSnackbarController, useTranslation } from \"@rebasepro/app\";\nimport type { BranchDiff, BranchInfo, BranchMergeResult, BranchReferencingRows, BranchRowChange, BranchSchemaChange, BranchTableDataDiff } from \"@rebasepro/types\";\n\nimport { classifyLoadFailure, type LoadFailure } from \"../load-failure\";\nimport { LoadFailureView } from \"../load-failure-view\";\nimport { splitLineDiff } from \"./split-line-diff\";\n\n/**\n * What a database branch changed, the way a pull request shows it — and the\n * merge, behind a dialog that says what wins before anything is written.\n *\n * The diff is the server's (`GET /api/admin/branches/:name/diff`), computed\n * against the database the branch was made from: schema (tables, columns,\n * constraints, indexes, triggers, enums, views, functions) and RLS policies as\n * SQL, side by side, and the rows the branch inserted, updated and deleted.\n * Rows that database changed on its own since are counted apart and never\n * offered as the branch's — and a row the branch deleted that they still\n * reference is a conflict, since deleting it would reach them.\n *\n * The merge (`POST …/merge`) sends back the fingerprint of the diff on screen,\n * so a merge after either side moved writes nothing, and the pane reloads the\n * diff instead of applying one nobody reviewed.\n */\n\ntype DiffTab = \"schema\" | \"data\" | \"details\";\ntype ConflictRule = \"abort\" | \"branch\" | \"target\";\n\n/** A refusal from the review routes, with the status `classifyLoadFailure` reads. */\nclass BranchReviewError extends Error {\n constructor(message: string, readonly status: number, readonly code: string | undefined) {\n super(message);\n this.name = \"BranchReviewError\";\n }\n}\n\nfunction isBranchDiff(value: unknown): value is BranchDiff {\n return typeof value === \"object\" && value !== null\n && \"fingerprint\" in value && typeof value.fingerprint === \"string\"\n && \"schema\" in value && Array.isArray(value.schema)\n && \"data\" in value && Array.isArray(value.data);\n}\n\nfunction isMergeResult(value: unknown): value is BranchMergeResult {\n return typeof value === \"object\" && value !== null\n && \"tables\" in value && Array.isArray(value.tables)\n && \"targetDatabase\" in value && typeof value.targetDatabase === \"string\";\n}\n\nasync function requestJson(url: string, init: RequestInit, token: string | null): Promise<unknown> {\n const response = await fetch(url, {\n ...init,\n headers: {\n ...(init.body ? { \"Content-Type\": \"application/json\" } : {}),\n ...(token ? { Authorization: `Bearer ${token}` } : {})\n }\n });\n const body: unknown = await response.json().catch(() => null);\n if (!response.ok) {\n const error = typeof body === \"object\" && body !== null && \"error\" in body\n && typeof body.error === \"object\" && body.error !== null ? body.error : null;\n const message = error && \"message\" in error && typeof error.message === \"string\" ? error.message : `HTTP ${response.status}`;\n const code = error && \"code\" in error && typeof error.code === \"string\" ? error.code : undefined;\n throw new BranchReviewError(message, response.status, code);\n }\n return body;\n}\n\nconst CHANGE_COLOR: Record<BranchSchemaChange[\"change\"], ChipColorKey> = { added: \"green\", dropped: \"red\", altered: \"yellow\" };\nconst ROW_COLOR: Record<BranchRowChange[\"change\"], ChipColorKey> = { inserted: \"green\", updated: \"yellow\", deleted: \"red\", conflict: \"orange\" };\n\nexport interface BranchDiffViewProps {\n branch: BranchInfo;\n /** The branch's connection details: the third tab. */\n details: React.ReactNode;\n /** Called once a merge has written to the target. */\n onMerged?: () => void;\n}\n\nexport function BranchDiffView({ branch, details, onMerged }: BranchDiffViewProps) {\n const { t } = useTranslation();\n const apiBase = useApiBase();\n const apiConfig = useApiConfig();\n const snackbar = useSnackbarController();\n const snackbarRef = useRef(snackbar);\n snackbarRef.current = snackbar;\n\n const [tab, setTab] = useState<DiffTab>(\"schema\");\n const [diff, setDiff] = useState<BranchDiff | null>(null);\n const [loading, setLoading] = useState(true);\n const [failure, setFailure] = useState<LoadFailure | null>(null);\n const [mergeOpen, setMergeOpen] = useState(false);\n\n // Read through refs: the load below must run when the branch changes, not\n // whenever a context hands back a new object or function.\n const apiConfigRef = useRef(apiConfig);\n apiConfigRef.current = apiConfig;\n const tRef = useRef(t);\n tRef.current = t;\n const token = useCallback(async () => {\n const config = apiConfigRef.current;\n return config?.getAuthToken ? await config.getAuthToken() : null;\n }, []);\n\n const load = useCallback(async () => {\n if (!apiBase) {\n // Nothing to ask: say so rather than spin.\n setLoading(false);\n setFailure(classifyLoadFailure(new Error(tRef.current(\"studio_branch_diff_no_api\"))));\n return;\n }\n setLoading(true);\n try {\n const body = await requestJson(`${apiBase}/admin/branches/${encodeURIComponent(branch.name)}/diff`, { method: \"GET\" }, await token());\n if (!isBranchDiff(body)) throw new Error(tRef.current(\"studio_branch_diff_unreadable\"));\n setDiff(body);\n setFailure(null);\n } catch (e: unknown) {\n setDiff(null);\n setFailure(classifyLoadFailure(e));\n } finally {\n setLoading(false);\n }\n }, [apiBase, branch.name, token]);\n\n useEffect(() => {\n setDiff(null);\n void load();\n }, [load]);\n\n const branchChanges = diff?.data.filter((entry) => entry.inserted + entry.updated + entry.deleted + entry.conflicts > 0) ?? [];\n const canMerge = branchChanges.some((entry) => !entry.blocked);\n\n return (\n <div className=\"flex flex-col flex-1 min-h-0\">\n <div className=\"flex items-end justify-between gap-3 px-5 border-b border-hairline bg-surface-sheet shrink-0\">\n <Tabs value={tab} onValueChange={(value) => setTab(value === \"data\" || value === \"details\" ? value : \"schema\")} variant=\"boxy\" className=\"flex-1 min-w-0\">\n <Tab value=\"schema\" innerClassName=\"flex items-center gap-1.5\">\n {t(\"studio_branch_diff_tab_schema\")}\n {diff && diff.schema.length > 0 && <Chip size=\"smallest\">{diff.schema.length}</Chip>}\n </Tab>\n <Tab value=\"data\" innerClassName=\"flex items-center gap-1.5\">\n {t(\"studio_branch_diff_tab_data\")}\n {diff && diff.data.length > 0 && <Chip size=\"smallest\">{diff.data.length}</Chip>}\n </Tab>\n <Tab value=\"details\">{t(\"studio_branch_diff_tab_details\")}</Tab>\n </Tabs>\n <div className=\"flex items-center gap-2 pb-1.5 shrink-0\">\n <IconButton aria-label={t(\"refresh\")} title={t(\"refresh\")} size=\"small\" onClick={() => void load()} disabled={loading}>\n <RefreshCwIcon size={iconSize.smallest}/>\n </IconButton>\n <Button\n size=\"small\"\n color=\"primary\"\n disabled={!diff || !canMerge || loading}\n onClick={() => setMergeOpen(true)}\n startIcon={<GitMergeIcon size={iconSize.smallest}/>}\n >\n {t(\"studio_branch_diff_merge\", { target: branch.parentDatabase })}\n </Button>\n </div>\n </div>\n\n <div className=\"flex-1 overflow-y-auto px-5 py-4\">\n {tab === \"details\" ? details : loading && !diff ? (\n <div className=\"flex items-center justify-center h-full\"><CircularProgress/></div>\n ) : failure ? (\n <LoadFailureView\n failure={failure}\n title={t(\"studio_branch_diff_failed\")}\n deniedTitle={t(\"studio_branch_diff_denied_title\")}\n deniedHint={t(\"studio_branch_diff_denied_hint\")}\n onRetry={() => void load()}\n />\n ) : diff ? (\n <div className=\"space-y-4\">\n {!diff.forkPointKnown && (\n <Alert color=\"warning\">\n <Typography variant=\"body2\">{t(\"studio_branch_diff_fork_unknown\", { target: diff.targetDatabase })}</Typography>\n </Alert>\n )}\n {tab === \"schema\"\n ? <SchemaChanges diff={diff}/>\n : <DataChanges diff={diff}/>}\n </div>\n ) : null}\n </div>\n\n {diff && (\n <MergeDialog\n open={mergeOpen}\n diff={diff}\n onClose={() => setMergeOpen(false)}\n merge={async (rule, skipBlocked) => {\n if (!apiBase) return;\n try {\n const body = await requestJson(\n `${apiBase}/admin/branches/${encodeURIComponent(branch.name)}/merge`,\n { method: \"POST\", body: JSON.stringify({ expectedFingerprint: diff.fingerprint, onConflict: rule, skipBlocked }) },\n await token()\n );\n if (!isMergeResult(body)) throw new Error(t(\"studio_branch_diff_unreadable\"));\n const rows = body.tables.reduce((sum, table) => sum + table.inserted + table.updated + table.deleted, 0);\n snackbarRef.current.open({ type: \"success\", message: t(\"studio_branch_diff_merged\", { count: rows, target: body.targetDatabase }) });\n for (const warning of body.warnings) snackbarRef.current.open({ type: \"warning\", message: warning });\n setMergeOpen(false);\n onMerged?.();\n await load();\n } catch (e: unknown) {\n // A diff that went stale is answered by showing the\n // one that is true now, not by asking to merge again.\n if (e instanceof BranchReviewError && e.code === \"BRANCH_DIFF_STALE\") {\n snackbarRef.current.open({ type: \"warning\", message: e.message });\n setMergeOpen(false);\n await load();\n return;\n }\n throw e;\n }\n }}\n />\n )}\n </div>\n );\n}\n\n// ── Schema & RLS ─────────────────────────────────────────────────────────────\n\nfunction SchemaChanges({ diff }: { diff: BranchDiff }) {\n const { t } = useTranslation();\n if (diff.schema.length === 0) {\n return <EmptyState text={t(\"studio_branch_diff_schema_empty\", { target: diff.targetDatabase })}/>;\n }\n const objectLabel: Record<BranchSchemaChange[\"object\"], string> = {\n table: t(\"studio_branch_diff_object_table\"),\n column: t(\"studio_branch_diff_object_column\"),\n policy: t(\"studio_branch_diff_object_policy\"),\n rls: t(\"studio_branch_diff_object_rls\"),\n constraint: t(\"studio_branch_diff_object_constraint\"),\n index: t(\"studio_branch_diff_object_index\"),\n trigger: t(\"studio_branch_diff_object_trigger\"),\n enum: t(\"studio_branch_diff_object_enum\"),\n view: t(\"studio_branch_diff_object_view\"),\n function: t(\"studio_branch_diff_object_function\")\n };\n const changeLabel: Record<BranchSchemaChange[\"change\"], string> = {\n added: t(\"studio_branch_diff_change_added\"),\n dropped: t(\"studio_branch_diff_change_dropped\"),\n altered: t(\"studio_branch_diff_change_altered\")\n };\n return (\n <div className=\"space-y-3\">\n <Typography variant=\"body2\" color=\"secondary\">{t(\"studio_branch_diff_schema_not_merged\")}</Typography>\n {diff.schema.map((change, index) => (\n <div key={index} className={cls(\"rounded-xl border bg-surface-card overflow-hidden\", defaultBorderMixin)}>\n <div className=\"flex items-center gap-2 px-3 py-2 min-w-0\">\n <Chip size=\"smallest\" colorScheme={CHANGE_COLOR[change.change]}>{changeLabel[change.change]}</Chip>\n <Typography variant=\"caption\" color=\"secondary\" className=\"shrink-0\">{objectLabel[change.object]}</Typography>\n <Typography variant=\"body2\" className=\"font-mono text-[12px] truncate\">\n {`${change.schema}.${change.table}${change.name ? `.${change.name}` : \"\"}`}\n </Typography>\n </div>\n <SplitDiff before={change.before} after={change.after} targetLabel={diff.targetDatabase} branchLabel={diff.branchDatabase}/>\n </div>\n ))}\n </div>\n );\n}\n\nfunction SplitDiff({ before, after, targetLabel, branchLabel }: { before?: string; after?: string; targetLabel: string; branchLabel: string }) {\n const rows = useMemo(() => splitLineDiff(before, after), [before, after]);\n const line = \"font-mono text-[12px] leading-5 whitespace-pre-wrap break-all px-3 min-h-5\";\n return (\n <div className={cls(\"grid grid-cols-2 border-t\", defaultBorderMixin)}>\n <Typography variant=\"caption\" color=\"secondary\" className={cls(\"px-3 py-1 border-b border-r font-mono\", defaultBorderMixin)}>{targetLabel}</Typography>\n <Typography variant=\"caption\" color=\"secondary\" className={cls(\"px-3 py-1 border-b font-mono\", defaultBorderMixin)}>{branchLabel}</Typography>\n {rows.map((row, index) => (\n <React.Fragment key={index}>\n <Typography component=\"div\" variant=\"body2\" className={cls(line, \"border-r\", defaultBorderMixin,\n row.left === null ? \"bg-surface-field\" : !row.same && \"bg-red-500/10 text-red-700 dark:text-red-300\")}>\n {row.left ?? \"\"}\n </Typography>\n <Typography component=\"div\" variant=\"body2\" className={cls(line,\n row.right === null ? \"bg-surface-field\" : !row.same && \"bg-emerald-500/10 text-emerald-700 dark:text-emerald-300\")}>\n {row.right ?? \"\"}\n </Typography>\n </React.Fragment>\n ))}\n </div>\n );\n}\n\n// ── Data ─────────────────────────────────────────────────────────────────────\n\n/** `public.posts (ON DELETE CASCADE, 1)`, for each foreign key into a row the branch deleted. */\nfunction referencingText(found: readonly BranchReferencingRows[]): string {\n return found.map((entry) => `${entry.schema}.${entry.table} (ON DELETE ${entry.onDelete.toUpperCase()}, ${entry.rows})`).join(\", \");\n}\n\n/** Every foreign key, across the diff, through which the target's newer rows reference a row the branch deleted. */\nfunction referencingRows(entries: readonly BranchTableDataDiff[]): BranchReferencingRows[] {\n return entries.flatMap((entry) => entry.referencedBy ?? []);\n}\n\nfunction DataChanges({ diff }: { diff: BranchDiff }) {\n const { t } = useTranslation();\n if (diff.data.length === 0) {\n return <EmptyState text={t(\"studio_branch_diff_data_empty\", { target: diff.targetDatabase })}/>;\n }\n // The target's rows in each table that reference a row the branch deleted.\n const reached = new Map<string, number>();\n for (const found of referencingRows(diff.data)) {\n const key = `${found.schema}.${found.table}`;\n reached.set(key, (reached.get(key) ?? 0) + found.rows);\n }\n return (\n <div className=\"space-y-5\">\n {diff.data.map((entry) => (\n <TableChanges\n key={`${entry.schema}.${entry.table}`}\n entry={entry}\n target={diff.targetDatabase}\n reached={reached.get(`${entry.schema}.${entry.table}`) ?? 0}\n />\n ))}\n </div>\n );\n}\n\nfunction TableChanges({ entry, target, reached }: { entry: BranchTableDataDiff; target: string; reached: number }) {\n const { t } = useTranslation();\n const rowLabel: Record<BranchRowChange[\"change\"], string> = {\n inserted: t(\"studio_branch_diff_row_inserted\"),\n updated: t(\"studio_branch_diff_row_updated\"),\n deleted: t(\"studio_branch_diff_row_deleted\"),\n conflict: t(\"studio_branch_diff_row_conflict\")\n };\n const total = entry.inserted + entry.updated + entry.deleted + entry.conflicts;\n return (\n <section className=\"space-y-2\">\n <div className=\"flex flex-wrap items-center gap-2 min-w-0\">\n <Typography variant=\"subtitle2\" className=\"font-mono truncate\">{`${entry.schema}.${entry.table}`}</Typography>\n {entry.collection && <Chip size=\"smallest\">{entry.collection}</Chip>}\n {entry.inserted > 0 && <Chip size=\"smallest\" colorScheme=\"green\">{`+${entry.inserted} ${rowLabel.inserted}`}</Chip>}\n {entry.updated > 0 && <Chip size=\"smallest\" colorScheme=\"yellow\">{`~${entry.updated} ${rowLabel.updated}`}</Chip>}\n {entry.deleted > 0 && <Chip size=\"smallest\" colorScheme=\"red\">{`−${entry.deleted} ${rowLabel.deleted}`}</Chip>}\n {entry.conflicts > 0 && <Chip size=\"smallest\" colorScheme=\"orange\">{t(\"studio_branch_diff_conflicts\", { count: entry.conflicts })}</Chip>}\n </div>\n {entry.targetChanges > 0 && (\n <Typography variant=\"caption\" color=\"secondary\" className=\"block\">\n {reached > 0\n ? t(\"studio_branch_diff_target_changes_referencing\", { count: entry.targetChanges, reached: Math.min(reached, entry.targetChanges), target })\n : t(\"studio_branch_diff_target_changes\", { count: entry.targetChanges, target })}\n </Typography>\n )}\n {entry.referencedBy && entry.referencedBy.length > 0 && (\n <Typography variant=\"caption\" color=\"secondary\" className=\"block\">\n {t(\"studio_branch_diff_referenced_by\", { target, tables: referencingText(entry.referencedBy) })}\n </Typography>\n )}\n {entry.blocked && (\n <Alert color=\"warning\">\n <Typography variant=\"body2\">{entry.blocked.message}</Typography>\n {entry.rowCounts && (\n <Typography variant=\"caption\" color=\"secondary\" className=\"block mt-1\">\n {t(\"studio_branch_diff_row_counts\", { target, targetCount: entry.rowCounts.target, branchCount: entry.rowCounts.branch })}\n </Typography>\n )}\n </Alert>\n )}\n {entry.samples.length > 0 && (\n <div className={cls(\"rounded-xl border overflow-hidden\", defaultBorderMixin)}>\n <Table className=\"w-full\">\n <TableHeader>\n <TableCell header className=\"w-28\">{t(\"studio_branch_diff_column_change\")}</TableCell>\n <TableCell header className=\"w-32\">{t(\"studio_branch_diff_column_key\")}</TableCell>\n <TableCell header>{t(\"studio_branch_diff_column_values\")}</TableCell>\n </TableHeader>\n <TableBody>\n {entry.samples.map((sample) => (\n <TableRow key={`${sample.change}:${sample.key}`}>\n <TableCell><Chip size=\"smallest\" colorScheme={ROW_COLOR[sample.change]}>{rowLabel[sample.change]}</Chip></TableCell>\n <TableCell><Typography variant=\"body2\" className=\"font-mono text-[12px] break-all\">{keyText(sample.key)}</Typography></TableCell>\n <TableCell><RowValues sample={sample}/></TableCell>\n </TableRow>\n ))}\n </TableBody>\n </Table>\n </div>\n )}\n {total > entry.samples.length && entry.samples.length > 0 && (\n <Typography variant=\"caption\" color=\"disabled\" className=\"block\">\n {t(\"studio_branch_diff_samples_shown\", { shown: entry.samples.length, total })}\n </Typography>\n )}\n </section>\n );\n}\n\n/** `[42]` → `42`; a composite key keeps its commas. */\nfunction keyText(key: string): string {\n return key.startsWith(\"[\") && key.endsWith(\"]\") ? key.slice(1, -1) : key;\n}\n\nconst VALUES_SHOWN = 8;\n\nfunction RowValues({ sample }: { sample: BranchRowChange }) {\n const mono = \"font-mono text-[12px] break-all\";\n // A conflict with no branch side is a row the branch deleted that the\n // target's newer rows reference: shown as the row it would delete.\n if (sample.change === \"updated\" || (sample.change === \"conflict\" && sample.after)) {\n return (\n <div className=\"space-y-0.5\">\n {(sample.changedColumns ?? []).map((column) => (\n <Typography key={column} variant=\"body2\" className={mono}>\n <span className=\"text-text-secondary dark:text-text-secondary-dark\">{column}: </span>\n <span className=\"bg-red-500/10 text-red-700 dark:text-red-300 rounded-md px-1\">{display(sample.before?.[column])}</span>\n {\" → \"}\n <span className=\"bg-emerald-500/10 text-emerald-700 dark:text-emerald-300 rounded-md px-1\">{display(sample.after?.[column])}</span>\n </Typography>\n ))}\n </div>\n );\n }\n const values = Object.entries((sample.change === \"inserted\" ? sample.after : sample.before) ?? {});\n return (\n <Typography variant=\"body2\" className={cls(mono, \"text-text-secondary dark:text-text-secondary-dark\")}>\n {values.slice(0, VALUES_SHOWN).map(([column, value]) => `${column}=${display(value)}`).join(\" \")}\n {values.length > VALUES_SHOWN ? \" …\" : \"\"}\n </Typography>\n );\n}\n\nfunction display(value: string | null | undefined): string {\n if (value === null || value === undefined) return \"NULL\";\n return value.length > 80 ? `${value.slice(0, 80)}…` : value;\n}\n\nfunction EmptyState({ text }: { text: string }) {\n return (\n <div className=\"flex items-center justify-center py-16\">\n <Typography variant=\"body2\" color=\"disabled\">{text}</Typography>\n </div>\n );\n}\n\n// ── Merge ────────────────────────────────────────────────────────────────────\n\nfunction MergeDialog({ open, diff, onClose, merge }: {\n open: boolean;\n diff: BranchDiff;\n onClose: () => void;\n merge: (rule: ConflictRule, skipBlocked: boolean) => Promise<void>;\n}) {\n const { t } = useTranslation();\n const [rule, setRule] = useState<ConflictRule>(\"abort\");\n const [skipBlocked, setSkipBlocked] = useState(false);\n const [merging, setMerging] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n useEffect(() => {\n if (!open) return;\n setRule(\"abort\");\n setSkipBlocked(false);\n setError(null);\n }, [open, diff.fingerprint]);\n\n const mergeable = diff.data.filter((entry) => !entry.blocked);\n // Every blocked table: a zero count on one is \"not matched\", not \"unchanged\".\n const blocked = diff.data.filter((entry) => entry.blocked);\n const sum = (key: \"inserted\" | \"updated\" | \"deleted\" | \"conflicts\" | \"targetChanges\") =>\n mergeable.reduce((total, entry) => total + entry[key], 0);\n const conflicts = sum(\"conflicts\");\n const targetChanges = sum(\"targetChanges\");\n const target = diff.targetDatabase;\n // The target's rows that reference rows the branch deleted: kept unless\n // the branch wins, when the foreign keys reach them.\n const referencing = referencingRows(mergeable);\n const reached = referencing.reduce((total, found) => total + found.rows, 0);\n const referencingTables = referencingText(referencing);\n const ready = (conflicts === 0 || rule !== \"abort\") && (blocked.length === 0 || skipBlocked);\n\n return (\n <Dialog open={open} onOpenChange={(next) => { if (!next && !merging) onClose(); }}>\n <DialogTitle>{t(\"studio_branch_diff_merge_title\", { branch: diff.branch, target })}</DialogTitle>\n <DialogContent className=\"space-y-4 sm:min-w-[420px] max-w-[560px]\">\n <Typography variant=\"body2\">\n {t(\"studio_branch_diff_merge_writes\", { inserted: sum(\"inserted\"), updated: sum(\"updated\"), deleted: sum(\"deleted\"), target })}\n </Typography>\n {rule === \"branch\" && reached > 0 ? (\n <Alert color=\"warning\">\n <Typography variant=\"body2\">\n {t(\"studio_branch_diff_merge_referenced_reached\", { count: reached, target, tables: referencingTables })}\n </Typography>\n </Alert>\n ) : (\n <Typography variant=\"body2\" color=\"secondary\">\n {targetChanges > 0\n ? t(\"studio_branch_diff_merge_target_kept_count\", { count: targetChanges, target })\n : t(\"studio_branch_diff_merge_target_kept\", { target })}\n </Typography>\n )}\n {diff.schema.length > 0 && (\n <Typography variant=\"body2\" color=\"secondary\">{t(\"studio_branch_diff_merge_schema_skipped\", { count: diff.schema.length })}</Typography>\n )}\n {conflicts > 0 && (\n <div className=\"space-y-2\">\n <Typography variant=\"body2\" className=\"font-medium\">{t(\"studio_branch_diff_merge_conflicts\", { count: conflicts })}</Typography>\n {reached > 0 && (\n <Typography variant=\"body2\" color=\"secondary\">\n {t(\"studio_branch_diff_merge_referenced_conflicts\", { count: reached, target, tables: referencingTables })}\n </Typography>\n )}\n <RadioGroup value={rule} onValueChange={(value) => setRule(value === \"branch\" || value === \"target\" ? value : \"abort\")}>\n {([\n [\"abort\", t(\"studio_branch_diff_conflict_abort\")],\n [\"branch\", t(\"studio_branch_diff_conflict_branch\", { branch: diff.branch })],\n [\"target\", t(\"studio_branch_diff_conflict_target\", { target })]\n ] as const).map(([value, label]) => (\n <div key={value} className=\"flex items-center gap-2\">\n <RadioGroupItem id={`merge-conflict-${value}`} value={value}/>\n <Label htmlFor={`merge-conflict-${value}`}>{label}</Label>\n </div>\n ))}\n </RadioGroup>\n </div>\n )}\n {blocked.length > 0 && (\n <Alert color=\"warning\">\n <Typography variant=\"body2\">{t(\"studio_branch_diff_merge_blocked\", { count: blocked.length })}</Typography>\n <div className=\"mt-1 space-y-0.5\">\n {blocked.map((entry) => (\n <Typography key={`${entry.schema}.${entry.table}`} variant=\"caption\" className=\"block\">\n <span className=\"font-mono\">{`${entry.schema}.${entry.table}`}</span>\n {` — ${entry.blocked?.message ?? \"\"}`}\n </Typography>\n ))}\n </div>\n <div className=\"flex items-center gap-2 mt-2\">\n <Checkbox id=\"merge-skip-blocked\" checked={skipBlocked} onCheckedChange={setSkipBlocked} size=\"small\"/>\n <Label htmlFor=\"merge-skip-blocked\">{t(\"studio_branch_diff_merge_skip_blocked\")}</Label>\n </div>\n </Alert>\n )}\n <Typography variant=\"caption\" color=\"secondary\" className=\"block\">{t(\"studio_branch_diff_merge_atomic\", { target })}</Typography>\n {error && (\n <Alert color=\"error\"><Typography variant=\"body2\">{error}</Typography></Alert>\n )}\n </DialogContent>\n <DialogActions>\n <Button variant=\"text\" onClick={onClose} disabled={merging}>{t(\"cancel\")}</Button>\n <Button\n color=\"primary\"\n disabled={!ready || merging}\n startIcon={merging ? <CircularProgress size=\"smallest\"/> : <GitMergeIcon size={iconSize.smallest}/>}\n onClick={async () => {\n setMerging(true);\n setError(null);\n try {\n await merge(rule, skipBlocked);\n } catch (e: unknown) {\n setError(e instanceof Error ? e.message : String(e));\n } finally {\n setMerging(false);\n }\n }}\n >\n {t(\"studio_branch_diff_merge_confirm\")}\n </Button>\n </DialogActions>\n </Dialog>\n );\n}\n","\nimport React, { useState, useEffect, useRef, useCallback } from \"react\";\nimport {\n Alert,\n Button,\n Chip,\n CircularProgress,\n cls,\n CopyIcon,\n defaultBorderMixin,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n GitBranchIcon,\n IconButton,\n iconSize,\n Paper,\n PlusIcon,\n RefreshCwIcon,\n Select,\n SelectItem,\n TextField,\n Trash2Icon,\n Typography\n} from \"@rebasepro/ui\";\nimport { useRebaseContext, useSnackbarController, ConfirmationDialog, useTranslation } from \"@rebasepro/app\";\nimport { isBranchAdmin } from \"@rebasepro/types\";\nimport type { BranchInfo } from \"@rebasepro/types\";\nimport { formatRelativeTime } from \"@rebasepro/utils\";\n\nimport { classifyLoadFailure, type LoadFailure } from \"../load-failure\";\nimport { BranchDiffView } from \"./BranchDiffView\";\n\nimport { LoadFailureView } from \"../load-failure-view\";\n\nfunction formatSize(bytes: number | undefined): string {\n if (bytes === undefined || bytes === null) return \"—\";\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;\n}\n\nfunction formatRelative(date: Date | string | undefined): string {\n if (!date) return \"—\";\n const d = date instanceof Date ? date : new Date(date);\n if (isNaN(d.getTime())) return \"—\";\n return formatRelativeTime(d) ?? d.toLocaleDateString();\n}\n\nexport function BranchesView() {\n const { databaseAdmin } = useRebaseContext();\n const snackbar = useSnackbarController();\n const { t } = useTranslation();\n\n const [branches, setBranches] = useState<BranchInfo[]>([]);\n const [loading, setLoading] = useState(true);\n const [selectedBranch, setSelectedBranch] = useState<string | null>(null);\n\n // Create dialog\n const [createOpen, setCreateOpen] = useState(false);\n const [newBranchName, setNewBranchName] = useState(\"\");\n /**\n * The database to copy, when it is not the main one: a branch's own\n * database, which is not its name.\n */\n const [sourceDatabase, setSourceDatabase] = useState<string | undefined>(undefined);\n const [creating, setCreating] = useState(false);\n /**\n * Why the last create attempt was refused, kept on screen.\n *\n * The server refuses branching outright on the managed development\n * database — PGlite serves one database, so the \"branch\" would be the\n * parent. That refusal is the whole answer to what the reader just tried to\n * do, and a snackbar is gone in four seconds; the same argument\n * `load-failure.ts` makes for listings.\n */\n const [createError, setCreateError] = useState<string | null>(null);\n\n // Delete confirm\n const [deleteTarget, setDeleteTarget] = useState<string | null>(null);\n const [deleting, setDeleting] = useState(false);\n\n /** Why the branch listing failed, classified — see `load-failure.ts`. */\n const [failure, setFailure] = useState<LoadFailure | null>(null);\n\n // Refs\n const snackbarRef = useRef(snackbar);\n snackbarRef.current = snackbar;\n\n const branchAdmin = isBranchAdmin(databaseAdmin) ? databaseAdmin : undefined;\n\n const loadBranches = useCallback(async () => {\n if (!branchAdmin) {\n setLoading(false);\n return;\n }\n try {\n const result = await branchAdmin.listBranches();\n setBranches(result);\n setFailure(null);\n } catch (e: unknown) {\n // \"No branches yet. Create one…\" over a refused listing invites the\n // reader to create a branch they are not allowed to see, and then\n // hides the one they already have.\n setFailure(classifyLoadFailure(e));\n } finally {\n setLoading(false);\n }\n }, [branchAdmin]);\n\n useEffect(() => {\n loadBranches();\n }, [loadBranches]);\n\n const handleCreate = async () => {\n if (!branchAdmin || !newBranchName.trim()) return;\n setCreating(true);\n setCreateError(null);\n try {\n await branchAdmin.createBranch(newBranchName.trim(), sourceDatabase ? { source: sourceDatabase } : undefined);\n snackbarRef.current.open({\n type: \"success\",\n message: t(\"studio_branches_created_snackbar\", { name: newBranchName.trim() })\n });\n setCreateOpen(false);\n setNewBranchName(\"\");\n setSourceDatabase(undefined);\n await loadBranches();\n } catch (e: unknown) {\n const message = e instanceof Error ? e.message : String(e);\n setCreateError(message);\n snackbarRef.current.open({ type: \"error\",\n message });\n } finally {\n setCreating(false);\n }\n };\n\n const handleDelete = async () => {\n if (!branchAdmin || !deleteTarget) return;\n setDeleting(true);\n try {\n await branchAdmin.deleteBranch(deleteTarget);\n snackbarRef.current.open({\n type: \"success\",\n message: t(\"studio_branches_deleted_snackbar\", { name: deleteTarget })\n });\n if (selectedBranch === deleteTarget) setSelectedBranch(null);\n setDeleteTarget(null);\n await loadBranches();\n } catch (e: unknown) {\n snackbarRef.current.open({\n type: \"error\",\n message: e instanceof Error ? e.message : String(e)\n });\n } finally {\n setDeleting(false);\n }\n };\n\n // Not supported\n if (!branchAdmin) {\n return (\n <div className=\"flex flex-col items-center justify-center h-full gap-4 text-center p-8\">\n <GitBranchIcon size={iconSize.large} className=\"text-surface-300 dark:text-surface-600\"/>\n <Typography variant=\"h6\" color=\"secondary\">{t(\"studio_branches_unavailable_title\")}</Typography>\n <Typography variant=\"body2\" color=\"disabled\" className=\"max-w-md\">\n {t(\"studio_branches_unavailable_body\")}\n </Typography>\n <a\n href=\"https://rebase.pro/docs/backend/branching\"\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"text-primary text-sm underline\"\n >\n {t(\"studio_read_the_docs\")}\n </a>\n </div>\n );\n }\n\n if (loading) {\n return (\n <div className=\"flex items-center justify-center h-full\">\n <CircularProgress/>\n </div>\n );\n }\n\n const selected = branches.find(b => b.name === selectedBranch);\n\n return (\n <div className=\"flex h-full w-full overflow-hidden bg-surface-card\">\n {/* ── Branch List ── */}\n <div className={cls(\"flex flex-col w-[340px] min-w-[280px] border-r h-full\", defaultBorderMixin)}>\n <div className={cls(\"flex items-center justify-between px-4 h-14 shrink-0 border-b bg-surface-sheet\", defaultBorderMixin)}>\n <div className=\"flex items-center gap-2\">\n <GitBranchIcon size={iconSize.small} className=\"text-primary\"/>\n <Typography variant=\"subtitle2\" className=\"font-semibold\">{t(\"studio_tool_branches\")}</Typography>\n <Chip size=\"smallest\" className=\"bg-surface-raised text-surface-600 dark:text-surface-300\">{branches.length}</Chip>\n </div>\n <div className=\"flex items-center gap-1\">\n <IconButton aria-label={t(\"refresh\")} size=\"small\" onClick={loadBranches} title={t(\"refresh\")}>\n <RefreshCwIcon size={iconSize.smallest}/>\n </IconButton>\n <IconButton aria-label={t(\"create_branch\")} size=\"small\" onClick={() => setCreateOpen(true)} title={t(\"create_branch\")} className=\"text-primary\">\n <PlusIcon size={iconSize.smallest}/>\n </IconButton>\n </div>\n </div>\n <div className=\"flex-1 overflow-y-auto p-2 space-y-1\">\n {failure ? (\n <LoadFailureView\n failure={failure}\n title={t(\"studio_branches_read_failed\")}\n deniedTitle={t(\"studio_branches_denied_title\")}\n deniedHint={t(\"studio_branches_denied_hint\")}\n onRetry={loadBranches}\n />\n ) : branches.length === 0 ? (\n <div className=\"flex flex-col items-center justify-center h-full gap-3 text-center px-4\">\n <CopyIcon size={iconSize.small} className=\"text-surface-300 dark:text-surface-600\"/>\n <Typography variant=\"body2\" color=\"disabled\" className=\"text-[13px]\">\n {t(\"studio_branches_empty\")}\n </Typography>\n <Button\n size=\"small\"\n variant=\"outlined\"\n onClick={() => setCreateOpen(true)}\n startIcon={<PlusIcon size={iconSize.smallest}/>}\n >\n {t(\"studio_branches_create_action\")}\n </Button>\n </div>\n ) : (\n branches.map(branch => (\n <div\n key={branch.name}\n onClick={() => setSelectedBranch(branch.name)}\n className={cls(\n \"flex items-center gap-3 px-3 py-2.5 rounded-lg cursor-pointer transition-all\",\n selectedBranch === branch.name\n ? \"bg-primary/10 dark:bg-primary/15 ring-1 ring-primary/30\"\n : \"hover:bg-surface-hover\"\n )}\n >\n <div className=\"w-2 h-2 rounded-full shrink-0 bg-emerald-500\"/>\n <div className=\"flex-1 min-w-0\">\n <Typography variant=\"body2\" className=\"truncate font-medium text-[13px]\">{branch.name}</Typography>\n <Typography variant=\"caption\" color=\"secondary\" className=\"truncate text-xs\">\n {t(\"studio_branches_list_from\", { parent: branch.parentDatabase, when: formatRelative(branch.createdAt) })}\n </Typography>\n </div>\n {branch.sizeBytes !== undefined && (\n <Typography variant=\"caption\" color=\"disabled\" className=\"font-mono text-xs shrink-0\">\n {formatSize(branch.sizeBytes)}\n </Typography>\n )}\n </div>\n ))\n )}\n </div>\n </div>\n\n {/* ── Detail Panel ── */}\n <div className=\"flex-1 flex flex-col min-w-0 h-full overflow-hidden\">\n {!selected ? (\n <div className=\"flex flex-col items-center justify-center h-full gap-3\">\n <GitBranchIcon size={iconSize.large} className=\"text-surface-200 dark:text-surface-700\"/>\n <Typography variant=\"body2\" color=\"disabled\">\n {branches.length === 0 ? t(\"studio_branches_empty_detail\") : t(\"studio_branches_select_prompt\")}\n </Typography>\n </div>\n ) : (\n <>\n {/* Header */}\n <div className={cls(\"flex items-center justify-between px-5 h-14 shrink-0 border-b bg-surface-sheet\", defaultBorderMixin)}>\n <div className=\"flex items-center gap-3 min-w-0\">\n <div className=\"w-2.5 h-2.5 rounded-full bg-emerald-500\"/>\n <div className=\"min-w-0\">\n <Typography variant=\"subtitle1\" className=\"font-semibold truncate\">{selected.name}</Typography>\n <Typography variant=\"caption\" color=\"secondary\" className=\"truncate\">\n {t(\"studio_branches_created_from\")} <Typography variant=\"mono\" component=\"span\" className=\"text-xs\">{selected.parentDatabase}</Typography>\n </Typography>\n </div>\n </div>\n <div className=\"flex items-center gap-2 shrink-0\">\n <Button\n size=\"small\"\n color=\"error\"\n variant=\"outlined\"\n onClick={() => setDeleteTarget(selected.name)}\n startIcon={<Trash2Icon size={iconSize.smallest}/>}\n >\n {t(\"delete\")}\n </Button>\n </div>\n </div>\n\n {/* What the branch changed, and the merge; its connection details are the third tab. */}\n <BranchDiffView\n key={selected.name}\n branch={selected}\n onMerged={loadBranches}\n details={\n <div className=\"space-y-4\">\n <div className=\"grid grid-cols-2 md:grid-cols-4 gap-3\">\n <StatCard label={t(\"studio_branches_branch_name\")} value={selected.name} mono/>\n <StatCard label={t(\"studio_branches_source_database\")} value={selected.parentDatabase} mono/>\n <StatCard label={t(\"studio_branches_created\")} value={formatRelative(selected.createdAt)}/>\n <StatCard label={t(\"studio_branches_size\")} value={formatSize(selected.sizeBytes)}/>\n </div>\n <Alert color=\"info\">\n <div className=\"space-y-1.5\">\n <Typography variant=\"body2\" className=\"text-[13px] font-medium\">\n {t(\"studio_branches_usage_title\")}\n </Typography>\n <Typography variant=\"body2\" className=\"text-[13px]\">\n {t(\"studio_branches_usage_switch\")}\n </Typography>\n <UsageCommand command={`rebase db branch switch ${selected.name}`}/>\n <Typography variant=\"body2\" className=\"text-[13px]\">\n {t(\"studio_branches_usage_off\")}\n </Typography>\n <UsageCommand command=\"rebase db branch switch --off\"/>\n <Typography variant=\"body2\" className=\"text-[13px]\">\n {t(\"studio_branches_usage_isolated\")}\n </Typography>\n </div>\n </Alert>\n <div className=\"p-4 rounded-lg border bg-surface-sheet border-hairline-strong\">\n <Typography variant=\"caption\" className=\"text-[10px] uppercase tracking-wider text-surface-400 mb-2 block font-medium\">{t(\"studio_branches_connection_details\")}</Typography>\n <div className=\"space-y-2\">\n <div className=\"flex items-center gap-2\">\n {/* The *database*, as the branch's record names it — not\n built from the branch name. They are not the same\n string: the driver prefixes every branch database with\n `rb_`, and a branch recorded under an older naming\n scheme (`my-feature` in `rb_myfeature`) is not even\n that. */}\n <Typography variant=\"caption\" color=\"secondary\" className=\"w-24 shrink-0 text-xs\">{t(\"studio_branches_row_database\")}</Typography>\n <Typography variant=\"body2\" className=\"font-mono text-[12px]\">{selected.database}</Typography>\n </div>\n <div className=\"flex items-start gap-2\">\n <Typography variant=\"caption\" color=\"secondary\" className=\"w-24 shrink-0 text-xs\">{t(\"studio_branches_row_connect\")}</Typography>\n <Typography variant=\"body2\" className=\"font-mono text-[12px] break-all\">\n {`DATABASE_URL=…/${selected.database}`}\n </Typography>\n </div>\n <div className=\"flex items-center gap-2\">\n <Typography variant=\"caption\" color=\"secondary\" className=\"w-24 shrink-0 text-xs\">{t(\"studio_branches_row_branched_from\")}</Typography>\n <Typography variant=\"body2\" className=\"font-mono text-[12px]\">{selected.parentDatabase}</Typography>\n </div>\n <div className=\"flex items-center gap-2\">\n <Typography variant=\"caption\" color=\"secondary\" className=\"w-24 shrink-0 text-xs\">{t(\"studio_branches_row_created_at\")}</Typography>\n <Typography variant=\"body2\" className=\"font-mono text-[12px]\">\n {selected.createdAt instanceof Date\n ? selected.createdAt.toLocaleString()\n : new Date(selected.createdAt).toLocaleString()}\n </Typography>\n </div>\n </div>\n </div>\n </div>\n }\n />\n </>\n )}\n </div>\n\n {/* ── Create Dialog ── */}\n <Dialog open={createOpen} onOpenChange={(open) => {\n setCreateOpen(open);\n if (!open) setCreateError(null);\n }}>\n <DialogTitle>{t(\"studio_branches_create_title\")}</DialogTitle>\n <DialogContent className=\"space-y-4 sm:min-w-[400px]\">\n <Typography variant=\"body2\" color=\"secondary\" className=\"text-[13px]\">\n {t(\"studio_branches_create_body\")}\n </Typography>\n {createError && (\n <Alert color=\"error\">\n <Typography variant=\"body2\" className=\"text-[13px]\">{createError}</Typography>\n </Alert>\n )}\n <div>\n <TextField\n label={t(\"studio_branches_branch_name\")}\n value={newBranchName}\n onChange={(e) => setNewBranchName(e.target.value)}\n placeholder={t(\"studio_branches_name_placeholder\")}\n size=\"small\"\n autoFocus\n />\n </div>\n {branches.length > 0 && (\n <div>\n <Select\n label={t(\"studio_branches_source_database\")}\n value={sourceDatabase ?? \"__main__\"}\n onValueChange={(v) => setSourceDatabase(v === \"__main__\" ? undefined : v)}\n placeholder={t(\"studio_branches_source_main\")}\n size=\"small\"\n >\n <SelectItem value=\"__main__\">{t(\"studio_branches_source_main\")}</SelectItem>\n {branches.map(b => (\n <SelectItem key={b.name} value={b.database}>{b.name}</SelectItem>\n ))}\n </Select>\n </div>\n )}\n </DialogContent>\n <DialogActions>\n <Button variant=\"text\" onClick={() => setCreateOpen(false)} disabled={creating}>\n {t(\"cancel\")}\n </Button>\n <Button\n color=\"primary\"\n onClick={handleCreate}\n disabled={!newBranchName.trim() || creating}\n startIcon={creating ? <CircularProgress size=\"smallest\"/> : <PlusIcon size={iconSize.smallest}/>}\n >\n {creating ? t(\"studio_branches_creating\") : t(\"studio_branches_create_action\")}\n </Button>\n </DialogActions>\n </Dialog>\n\n {/* ── Delete Confirm ── */}\n <ConfirmationDialog\n open={!!deleteTarget}\n onAccept={handleDelete}\n onCancel={() => setDeleteTarget(null)}\n title={t(\"studio_branches_delete_title\")}\n body={\n <Typography variant=\"body2\">\n {t(\"studio_branches_delete_body\", { name: deleteTarget ?? \"\" })}\n </Typography>\n }\n loading={deleting}\n />\n </div>\n );\n}\n\n/** A command the usage alert tells the reader to run, set apart from the prose. */\nfunction UsageCommand({ command }: { command: string }) {\n return (\n <Typography\n variant=\"mono\"\n component=\"div\"\n className=\"px-2 py-1 rounded bg-surface-well text-[12px] break-all\"\n >\n {command}\n </Typography>\n );\n}\n\nfunction StatCard({ label, value, mono }: {\n label: string; value: string; mono?: boolean;\n}) {\n return (\n <div className={cls(\"px-3 py-2 rounded-lg border bg-surface-card\", defaultBorderMixin)}>\n <Typography variant=\"caption\" color=\"secondary\" className=\"text-[10px] uppercase tracking-wider font-medium\">{label}</Typography>\n <Typography variant=\"body2\" className={cls(\n \"mt-0.5 font-semibold text-[13px] truncate\",\n mono && \"font-mono\"\n )}>{value}</Typography>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAiBA,SAAgB,cAAc,QAA4B,OAA2C;CACjG,MAAM,IAAI,WAAW,KAAA,IAAY,CAAC,IAAI,OAAO,MAAM,IAAI;CACvD,MAAM,IAAI,UAAU,KAAA,IAAY,CAAC,IAAI,MAAM,MAAM,IAAI;CAGrD,MAAM,MAAkB,MAAM,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,IAAI,MAAc,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;CAC1G,KAAK,IAAI,IAAI,EAAE,SAAS,GAAG,KAAK,GAAG,KAAK,GACpC,KAAK,IAAI,IAAI,EAAE,SAAS,GAAG,KAAK,GAAG,KAAK,GACpC,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,IAAI,EAAE,CAAC,IAAI,KAAK,IAAI,KAAK,IAAI,IAAI,IAAI,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,IAAI,EAAE;CAIjG,MAAM,OAAuB,CAAC;CAC9B,IAAI,UAAoB,CAAC;CACzB,IAAI,QAAkB,CAAC;CAGvB,MAAM,cAAc;EAChB,KAAK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