@rebasepro/studio 0.25.1 → 0.27.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/dist/BranchesView-Df00LXAI.js +1269 -0
- package/dist/BranchesView-Df00LXAI.js.map +1 -0
- package/dist/components/Branches/BranchDiffView.d.ts +10 -0
- package/dist/components/Branches/split-line-diff.d.ts +17 -0
- package/dist/index.es.js +3 -2
- package/dist/index.es.js.map +1 -1
- package/package.json +9 -9
- package/dist/BranchesView-BHfwGTYc.js +0 -524
- package/dist/BranchesView-BHfwGTYc.js.map +0 -1
|
@@ -1,524 +0,0 @@
|
|
|
1
|
-
import { t as classifyLoadFailure } from "./load-failure-Bd8lFIO7.js";
|
|
2
|
-
import { t as LoadFailureView } from "./load-failure-view-CBTB_h-h.js";
|
|
3
|
-
import { ConfirmationDialog, useRebaseContext, useSnackbarController, useTranslation } from "@rebasepro/app";
|
|
4
|
-
import { useCallback, useEffect, useRef, useState } from "react";
|
|
5
|
-
import { Alert, Button, Chip, CircularProgress, CopyIcon, Dialog, DialogActions, DialogContent, DialogTitle, GitBranchIcon, IconButton, PlusIcon, RefreshCwIcon, Select, SelectItem, TextField, Trash2Icon, Typography, cls, defaultBorderMixin, iconSize } from "@rebasepro/ui";
|
|
6
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
import { isBranchAdmin } from "@rebasepro/types";
|
|
8
|
-
import { formatRelativeTime } from "@rebasepro/utils";
|
|
9
|
-
//#region src/components/Branches/BranchesView.tsx
|
|
10
|
-
/**
|
|
11
|
-
* The prefix the driver puts on every branch database.
|
|
12
|
-
*
|
|
13
|
-
* Stated here rather than derived from the row, because `BranchInfo` carries
|
|
14
|
-
* the *name* a person typed and not the database it became — and the detail
|
|
15
|
-
* pane used to print the name under "Database:", which is a connection string
|
|
16
|
-
* to nothing. Kept in step with `BranchService.BRANCH_DB_PREFIX` and the CLI's
|
|
17
|
-
* `branch-pointer.ts`, which say the same thing for the same reason.
|
|
18
|
-
*/
|
|
19
|
-
var BRANCH_DB_PREFIX = "rb_";
|
|
20
|
-
function formatSize(bytes) {
|
|
21
|
-
if (bytes === void 0 || bytes === null) return "—";
|
|
22
|
-
if (bytes < 1024) return `${bytes} B`;
|
|
23
|
-
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
24
|
-
if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
25
|
-
return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;
|
|
26
|
-
}
|
|
27
|
-
function formatRelative(date) {
|
|
28
|
-
if (!date) return "—";
|
|
29
|
-
const d = date instanceof Date ? date : new Date(date);
|
|
30
|
-
if (isNaN(d.getTime())) return "—";
|
|
31
|
-
return formatRelativeTime(d) ?? d.toLocaleDateString();
|
|
32
|
-
}
|
|
33
|
-
function BranchesView() {
|
|
34
|
-
const { databaseAdmin } = useRebaseContext();
|
|
35
|
-
const snackbar = useSnackbarController();
|
|
36
|
-
const { t } = useTranslation();
|
|
37
|
-
const [branches, setBranches] = useState([]);
|
|
38
|
-
const [loading, setLoading] = useState(true);
|
|
39
|
-
const [selectedBranch, setSelectedBranch] = useState(null);
|
|
40
|
-
const [createOpen, setCreateOpen] = useState(false);
|
|
41
|
-
const [newBranchName, setNewBranchName] = useState("");
|
|
42
|
-
/**
|
|
43
|
-
* The database to copy, when it is not the main one: a branch's own
|
|
44
|
-
* database, which is not its name.
|
|
45
|
-
*/
|
|
46
|
-
const [sourceDatabase, setSourceDatabase] = useState(void 0);
|
|
47
|
-
const [creating, setCreating] = useState(false);
|
|
48
|
-
/**
|
|
49
|
-
* Why the last create attempt was refused, kept on screen.
|
|
50
|
-
*
|
|
51
|
-
* The server refuses branching outright on the managed development
|
|
52
|
-
* database — PGlite serves one database, so the "branch" would be the
|
|
53
|
-
* parent. That refusal is the whole answer to what the reader just tried to
|
|
54
|
-
* do, and a snackbar is gone in four seconds; the same argument
|
|
55
|
-
* `load-failure.ts` makes for listings.
|
|
56
|
-
*/
|
|
57
|
-
const [createError, setCreateError] = useState(null);
|
|
58
|
-
const [deleteTarget, setDeleteTarget] = useState(null);
|
|
59
|
-
const [deleting, setDeleting] = useState(false);
|
|
60
|
-
/** Why the branch listing failed, classified — see `load-failure.ts`. */
|
|
61
|
-
const [failure, setFailure] = useState(null);
|
|
62
|
-
const snackbarRef = useRef(snackbar);
|
|
63
|
-
snackbarRef.current = snackbar;
|
|
64
|
-
const branchAdmin = isBranchAdmin(databaseAdmin) ? databaseAdmin : void 0;
|
|
65
|
-
const loadBranches = useCallback(async () => {
|
|
66
|
-
if (!branchAdmin) {
|
|
67
|
-
setLoading(false);
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
try {
|
|
71
|
-
const result = await branchAdmin.listBranches();
|
|
72
|
-
setBranches(result);
|
|
73
|
-
setFailure(null);
|
|
74
|
-
} catch (e) {
|
|
75
|
-
setFailure(classifyLoadFailure(e));
|
|
76
|
-
} finally {
|
|
77
|
-
setLoading(false);
|
|
78
|
-
}
|
|
79
|
-
}, [branchAdmin]);
|
|
80
|
-
useEffect(() => {
|
|
81
|
-
loadBranches();
|
|
82
|
-
}, [loadBranches]);
|
|
83
|
-
const handleCreate = async () => {
|
|
84
|
-
if (!branchAdmin || !newBranchName.trim()) return;
|
|
85
|
-
setCreating(true);
|
|
86
|
-
setCreateError(null);
|
|
87
|
-
try {
|
|
88
|
-
await branchAdmin.createBranch(newBranchName.trim(), sourceDatabase ? { source: sourceDatabase } : void 0);
|
|
89
|
-
snackbarRef.current.open({
|
|
90
|
-
type: "success",
|
|
91
|
-
message: `Branch "${newBranchName.trim()}" created successfully`
|
|
92
|
-
});
|
|
93
|
-
setCreateOpen(false);
|
|
94
|
-
setNewBranchName("");
|
|
95
|
-
setSourceDatabase(void 0);
|
|
96
|
-
await loadBranches();
|
|
97
|
-
} catch (e) {
|
|
98
|
-
const message = e instanceof Error ? e.message : String(e);
|
|
99
|
-
setCreateError(message);
|
|
100
|
-
snackbarRef.current.open({
|
|
101
|
-
type: "error",
|
|
102
|
-
message
|
|
103
|
-
});
|
|
104
|
-
} finally {
|
|
105
|
-
setCreating(false);
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
const handleDelete = async () => {
|
|
109
|
-
if (!branchAdmin || !deleteTarget) return;
|
|
110
|
-
setDeleting(true);
|
|
111
|
-
try {
|
|
112
|
-
await branchAdmin.deleteBranch(deleteTarget);
|
|
113
|
-
snackbarRef.current.open({
|
|
114
|
-
type: "success",
|
|
115
|
-
message: `Branch "${deleteTarget}" deleted`
|
|
116
|
-
});
|
|
117
|
-
if (selectedBranch === deleteTarget) setSelectedBranch(null);
|
|
118
|
-
setDeleteTarget(null);
|
|
119
|
-
await loadBranches();
|
|
120
|
-
} catch (e) {
|
|
121
|
-
snackbarRef.current.open({
|
|
122
|
-
type: "error",
|
|
123
|
-
message: e instanceof Error ? e.message : String(e)
|
|
124
|
-
});
|
|
125
|
-
} finally {
|
|
126
|
-
setDeleting(false);
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
if (!branchAdmin) return /* @__PURE__ */ jsxs("div", {
|
|
130
|
-
className: "flex flex-col items-center justify-center h-full gap-4 text-center p-8",
|
|
131
|
-
children: [
|
|
132
|
-
/* @__PURE__ */ jsx(GitBranchIcon, {
|
|
133
|
-
size: iconSize.large,
|
|
134
|
-
className: "text-surface-300 dark:text-surface-600"
|
|
135
|
-
}),
|
|
136
|
-
/* @__PURE__ */ jsx(Typography, {
|
|
137
|
-
variant: "h6",
|
|
138
|
-
color: "secondary",
|
|
139
|
-
children: t("studio_branches_unavailable_title")
|
|
140
|
-
}),
|
|
141
|
-
/* @__PURE__ */ jsx(Typography, {
|
|
142
|
-
variant: "body2",
|
|
143
|
-
color: "disabled",
|
|
144
|
-
className: "max-w-md",
|
|
145
|
-
children: t("studio_branches_unavailable_body")
|
|
146
|
-
}),
|
|
147
|
-
/* @__PURE__ */ jsx("a", {
|
|
148
|
-
href: "https://rebase.pro/docs/backend/branching",
|
|
149
|
-
target: "_blank",
|
|
150
|
-
rel: "noreferrer",
|
|
151
|
-
className: "text-primary text-sm underline",
|
|
152
|
-
children: t("studio_read_the_docs")
|
|
153
|
-
})
|
|
154
|
-
]
|
|
155
|
-
});
|
|
156
|
-
if (loading) return /* @__PURE__ */ jsx("div", {
|
|
157
|
-
className: "flex items-center justify-center h-full",
|
|
158
|
-
children: /* @__PURE__ */ jsx(CircularProgress, {})
|
|
159
|
-
});
|
|
160
|
-
const selected = branches.find((b) => b.name === selectedBranch);
|
|
161
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
162
|
-
className: "flex h-full w-full overflow-hidden bg-surface-card",
|
|
163
|
-
children: [
|
|
164
|
-
/* @__PURE__ */ jsxs("div", {
|
|
165
|
-
className: cls("flex flex-col w-[340px] min-w-[280px] border-r h-full", defaultBorderMixin),
|
|
166
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
167
|
-
className: cls("flex items-center justify-between px-4 py-2.5 border-b bg-surface-sheet min-h-[48px]", defaultBorderMixin),
|
|
168
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
169
|
-
className: "flex items-center gap-2",
|
|
170
|
-
children: [
|
|
171
|
-
/* @__PURE__ */ jsx(GitBranchIcon, {
|
|
172
|
-
size: iconSize.small,
|
|
173
|
-
className: "text-primary"
|
|
174
|
-
}),
|
|
175
|
-
/* @__PURE__ */ jsx(Typography, {
|
|
176
|
-
variant: "subtitle2",
|
|
177
|
-
className: "font-semibold",
|
|
178
|
-
children: t("studio_tool_branches")
|
|
179
|
-
}),
|
|
180
|
-
/* @__PURE__ */ jsx(Chip, {
|
|
181
|
-
size: "smallest",
|
|
182
|
-
className: "bg-surface-raised text-surface-600 dark:text-surface-300",
|
|
183
|
-
children: branches.length
|
|
184
|
-
})
|
|
185
|
-
]
|
|
186
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
187
|
-
className: "flex items-center gap-1",
|
|
188
|
-
children: [/* @__PURE__ */ jsx(IconButton, {
|
|
189
|
-
"aria-label": t("refresh"),
|
|
190
|
-
size: "small",
|
|
191
|
-
onClick: loadBranches,
|
|
192
|
-
title: t("refresh"),
|
|
193
|
-
children: /* @__PURE__ */ jsx(RefreshCwIcon, { size: iconSize.smallest })
|
|
194
|
-
}), /* @__PURE__ */ jsx(IconButton, {
|
|
195
|
-
"aria-label": t("create_branch"),
|
|
196
|
-
size: "small",
|
|
197
|
-
onClick: () => setCreateOpen(true),
|
|
198
|
-
title: t("create_branch"),
|
|
199
|
-
className: "text-primary",
|
|
200
|
-
children: /* @__PURE__ */ jsx(PlusIcon, { size: iconSize.smallest })
|
|
201
|
-
})]
|
|
202
|
-
})]
|
|
203
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
204
|
-
className: "flex-1 overflow-y-auto p-2 space-y-1",
|
|
205
|
-
children: failure ? /* @__PURE__ */ jsx(LoadFailureView, {
|
|
206
|
-
failure,
|
|
207
|
-
title: t("studio_branches_read_failed"),
|
|
208
|
-
deniedTitle: t("studio_branches_denied_title"),
|
|
209
|
-
deniedHint: t("studio_branches_denied_hint"),
|
|
210
|
-
onRetry: loadBranches
|
|
211
|
-
}) : branches.length === 0 ? /* @__PURE__ */ jsxs("div", {
|
|
212
|
-
className: "flex flex-col items-center justify-center h-full gap-3 text-center px-4",
|
|
213
|
-
children: [
|
|
214
|
-
/* @__PURE__ */ jsx(CopyIcon, {
|
|
215
|
-
size: iconSize.small,
|
|
216
|
-
className: "text-surface-300 dark:text-surface-600"
|
|
217
|
-
}),
|
|
218
|
-
/* @__PURE__ */ jsx(Typography, {
|
|
219
|
-
variant: "body2",
|
|
220
|
-
color: "disabled",
|
|
221
|
-
className: "text-[13px]",
|
|
222
|
-
children: "No branches yet. Create one to start working with an isolated database copy."
|
|
223
|
-
}),
|
|
224
|
-
/* @__PURE__ */ jsx(Button, {
|
|
225
|
-
size: "small",
|
|
226
|
-
variant: "outlined",
|
|
227
|
-
onClick: () => setCreateOpen(true),
|
|
228
|
-
startIcon: /* @__PURE__ */ jsx(PlusIcon, { size: iconSize.smallest }),
|
|
229
|
-
children: "Create Branch"
|
|
230
|
-
})
|
|
231
|
-
]
|
|
232
|
-
}) : branches.map((branch) => /* @__PURE__ */ jsxs("div", {
|
|
233
|
-
onClick: () => setSelectedBranch(branch.name),
|
|
234
|
-
className: cls("flex items-center gap-3 px-3 py-2.5 rounded-lg cursor-pointer transition-all", selectedBranch === branch.name ? "bg-primary/10 dark:bg-primary/15 ring-1 ring-primary/30" : "hover:bg-surface-hover"),
|
|
235
|
-
children: [
|
|
236
|
-
/* @__PURE__ */ jsx("div", { className: "w-2 h-2 rounded-full shrink-0 bg-emerald-500" }),
|
|
237
|
-
/* @__PURE__ */ jsxs("div", {
|
|
238
|
-
className: "flex-1 min-w-0",
|
|
239
|
-
children: [/* @__PURE__ */ jsx(Typography, {
|
|
240
|
-
variant: "body2",
|
|
241
|
-
className: "truncate font-medium text-[13px]",
|
|
242
|
-
children: branch.name
|
|
243
|
-
}), /* @__PURE__ */ jsxs(Typography, {
|
|
244
|
-
variant: "caption",
|
|
245
|
-
color: "secondary",
|
|
246
|
-
className: "truncate text-[11px]",
|
|
247
|
-
children: [
|
|
248
|
-
"from ",
|
|
249
|
-
branch.parentDatabase,
|
|
250
|
-
" · ",
|
|
251
|
-
formatRelative(branch.createdAt)
|
|
252
|
-
]
|
|
253
|
-
})]
|
|
254
|
-
}),
|
|
255
|
-
branch.sizeBytes !== void 0 && /* @__PURE__ */ jsx(Typography, {
|
|
256
|
-
variant: "caption",
|
|
257
|
-
color: "disabled",
|
|
258
|
-
className: "font-mono text-[10px] shrink-0",
|
|
259
|
-
children: formatSize(branch.sizeBytes)
|
|
260
|
-
})
|
|
261
|
-
]
|
|
262
|
-
}, branch.name))
|
|
263
|
-
})]
|
|
264
|
-
}),
|
|
265
|
-
/* @__PURE__ */ jsx("div", {
|
|
266
|
-
className: "flex-1 flex flex-col min-w-0 h-full overflow-hidden",
|
|
267
|
-
children: !selected ? /* @__PURE__ */ jsxs("div", {
|
|
268
|
-
className: "flex flex-col items-center justify-center h-full gap-3",
|
|
269
|
-
children: [/* @__PURE__ */ jsx(GitBranchIcon, {
|
|
270
|
-
size: iconSize.large,
|
|
271
|
-
className: "text-surface-200 dark:text-surface-700"
|
|
272
|
-
}), /* @__PURE__ */ jsx(Typography, {
|
|
273
|
-
variant: "body2",
|
|
274
|
-
color: "disabled",
|
|
275
|
-
children: branches.length === 0 ? "Create a branch to get started" : "Select a branch to view details"
|
|
276
|
-
})]
|
|
277
|
-
}) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
278
|
-
/* @__PURE__ */ jsxs("div", {
|
|
279
|
-
className: cls("flex items-center justify-between px-5 py-3 border-b bg-surface-card min-h-[56px]", defaultBorderMixin),
|
|
280
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
281
|
-
className: "flex items-center gap-3 min-w-0",
|
|
282
|
-
children: [/* @__PURE__ */ jsx("div", { className: "w-2.5 h-2.5 rounded-full bg-emerald-500" }), /* @__PURE__ */ jsxs("div", {
|
|
283
|
-
className: "min-w-0",
|
|
284
|
-
children: [/* @__PURE__ */ jsx(Typography, {
|
|
285
|
-
variant: "subtitle1",
|
|
286
|
-
className: "font-semibold truncate",
|
|
287
|
-
children: selected.name
|
|
288
|
-
}), /* @__PURE__ */ jsxs(Typography, {
|
|
289
|
-
variant: "caption",
|
|
290
|
-
color: "secondary",
|
|
291
|
-
className: "truncate",
|
|
292
|
-
children: ["Created from ", /* @__PURE__ */ jsx("span", {
|
|
293
|
-
className: "font-mono text-[11px]",
|
|
294
|
-
children: selected.parentDatabase
|
|
295
|
-
})]
|
|
296
|
-
})]
|
|
297
|
-
})]
|
|
298
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
299
|
-
className: "flex items-center gap-2 shrink-0",
|
|
300
|
-
children: /* @__PURE__ */ jsx(Button, {
|
|
301
|
-
size: "small",
|
|
302
|
-
color: "error",
|
|
303
|
-
variant: "outlined",
|
|
304
|
-
onClick: () => setDeleteTarget(selected.name),
|
|
305
|
-
startIcon: /* @__PURE__ */ jsx(Trash2Icon, { size: iconSize.smallest }),
|
|
306
|
-
children: "Delete"
|
|
307
|
-
})
|
|
308
|
-
})]
|
|
309
|
-
}),
|
|
310
|
-
/* @__PURE__ */ jsx("div", {
|
|
311
|
-
className: "px-5 py-4 bg-surface-sheet",
|
|
312
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
313
|
-
className: "grid grid-cols-2 md:grid-cols-4 gap-3",
|
|
314
|
-
children: [
|
|
315
|
-
/* @__PURE__ */ jsx(StatCard, {
|
|
316
|
-
label: "Branch Name",
|
|
317
|
-
value: selected.name,
|
|
318
|
-
mono: true
|
|
319
|
-
}),
|
|
320
|
-
/* @__PURE__ */ jsx(StatCard, {
|
|
321
|
-
label: "Source Database",
|
|
322
|
-
value: selected.parentDatabase,
|
|
323
|
-
mono: true
|
|
324
|
-
}),
|
|
325
|
-
/* @__PURE__ */ jsx(StatCard, {
|
|
326
|
-
label: "Created",
|
|
327
|
-
value: formatRelative(selected.createdAt)
|
|
328
|
-
}),
|
|
329
|
-
/* @__PURE__ */ jsx(StatCard, {
|
|
330
|
-
label: "Size",
|
|
331
|
-
value: formatSize(selected.sizeBytes)
|
|
332
|
-
})
|
|
333
|
-
]
|
|
334
|
-
})
|
|
335
|
-
}),
|
|
336
|
-
/* @__PURE__ */ jsxs("div", {
|
|
337
|
-
className: "flex-1 overflow-y-auto px-5 py-4",
|
|
338
|
-
children: [/* @__PURE__ */ jsx(Alert, {
|
|
339
|
-
color: "info",
|
|
340
|
-
children: /* @__PURE__ */ jsxs(Typography, {
|
|
341
|
-
variant: "body2",
|
|
342
|
-
className: "text-[13px]",
|
|
343
|
-
children: [
|
|
344
|
-
/* @__PURE__ */ jsx("strong", { children: "How to use this branch:" }),
|
|
345
|
-
" point this checkout at it with",
|
|
346
|
-
/* @__PURE__ */ jsxs("code", {
|
|
347
|
-
className: "mx-1 px-1.5 py-0.5 rounded bg-surface-well font-mono text-[12px]",
|
|
348
|
-
children: ["rebase db branch switch ", selected.name]
|
|
349
|
-
}),
|
|
350
|
-
"— every later command uses it, and",
|
|
351
|
-
/* @__PURE__ */ jsx("code", {
|
|
352
|
-
className: "mx-1 px-1.5 py-0.5 rounded bg-surface-well font-mono text-[12px]",
|
|
353
|
-
children: "rebase db branch switch --off"
|
|
354
|
-
}),
|
|
355
|
-
"goes back to the main database. Changes made here don't affect it."
|
|
356
|
-
]
|
|
357
|
-
})
|
|
358
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
359
|
-
className: "mt-4 p-4 rounded-lg border bg-surface-sheet border-hairline-strong",
|
|
360
|
-
children: [/* @__PURE__ */ jsx(Typography, {
|
|
361
|
-
variant: "caption",
|
|
362
|
-
className: "text-[10px] uppercase tracking-wider text-surface-400 mb-2 block font-medium",
|
|
363
|
-
children: "Connection Details"
|
|
364
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
365
|
-
className: "space-y-2",
|
|
366
|
-
children: [
|
|
367
|
-
/* @__PURE__ */ jsxs("div", {
|
|
368
|
-
className: "flex items-center gap-2",
|
|
369
|
-
children: [/* @__PURE__ */ jsx(Typography, {
|
|
370
|
-
variant: "caption",
|
|
371
|
-
color: "secondary",
|
|
372
|
-
className: "w-24 shrink-0 text-[11px]",
|
|
373
|
-
children: "Database:"
|
|
374
|
-
}), /* @__PURE__ */ jsx(Typography, {
|
|
375
|
-
variant: "body2",
|
|
376
|
-
className: "font-mono text-[12px]",
|
|
377
|
-
children: `${BRANCH_DB_PREFIX}${selected.name}`
|
|
378
|
-
})]
|
|
379
|
-
}),
|
|
380
|
-
/* @__PURE__ */ jsxs("div", {
|
|
381
|
-
className: "flex items-start gap-2",
|
|
382
|
-
children: [/* @__PURE__ */ jsx(Typography, {
|
|
383
|
-
variant: "caption",
|
|
384
|
-
color: "secondary",
|
|
385
|
-
className: "w-24 shrink-0 text-[11px]",
|
|
386
|
-
children: "Connect with:"
|
|
387
|
-
}), /* @__PURE__ */ jsx(Typography, {
|
|
388
|
-
variant: "body2",
|
|
389
|
-
className: "font-mono text-[12px] break-all",
|
|
390
|
-
children: `DATABASE_URL=…/${BRANCH_DB_PREFIX}${selected.name}`
|
|
391
|
-
})]
|
|
392
|
-
}),
|
|
393
|
-
/* @__PURE__ */ jsxs("div", {
|
|
394
|
-
className: "flex items-center gap-2",
|
|
395
|
-
children: [/* @__PURE__ */ jsx(Typography, {
|
|
396
|
-
variant: "caption",
|
|
397
|
-
color: "secondary",
|
|
398
|
-
className: "w-24 shrink-0 text-[11px]",
|
|
399
|
-
children: "Branched from:"
|
|
400
|
-
}), /* @__PURE__ */ jsx(Typography, {
|
|
401
|
-
variant: "body2",
|
|
402
|
-
className: "font-mono text-[12px]",
|
|
403
|
-
children: selected.parentDatabase
|
|
404
|
-
})]
|
|
405
|
-
}),
|
|
406
|
-
/* @__PURE__ */ jsxs("div", {
|
|
407
|
-
className: "flex items-center gap-2",
|
|
408
|
-
children: [/* @__PURE__ */ jsx(Typography, {
|
|
409
|
-
variant: "caption",
|
|
410
|
-
color: "secondary",
|
|
411
|
-
className: "w-24 shrink-0 text-[11px]",
|
|
412
|
-
children: "Created at:"
|
|
413
|
-
}), /* @__PURE__ */ jsx(Typography, {
|
|
414
|
-
variant: "body2",
|
|
415
|
-
className: "font-mono text-[12px]",
|
|
416
|
-
children: selected.createdAt instanceof Date ? selected.createdAt.toLocaleString() : new Date(selected.createdAt).toLocaleString()
|
|
417
|
-
})]
|
|
418
|
-
})
|
|
419
|
-
]
|
|
420
|
-
})]
|
|
421
|
-
})]
|
|
422
|
-
})
|
|
423
|
-
] })
|
|
424
|
-
}),
|
|
425
|
-
/* @__PURE__ */ jsxs(Dialog, {
|
|
426
|
-
open: createOpen,
|
|
427
|
-
onOpenChange: (open) => {
|
|
428
|
-
setCreateOpen(open);
|
|
429
|
-
if (!open) setCreateError(null);
|
|
430
|
-
},
|
|
431
|
-
children: [
|
|
432
|
-
/* @__PURE__ */ jsx(DialogTitle, { children: "Create New Branch" }),
|
|
433
|
-
/* @__PURE__ */ jsxs(DialogContent, {
|
|
434
|
-
className: "space-y-4 min-w-[400px]",
|
|
435
|
-
children: [
|
|
436
|
-
/* @__PURE__ */ jsx(Typography, {
|
|
437
|
-
variant: "body2",
|
|
438
|
-
color: "secondary",
|
|
439
|
-
className: "text-[13px]",
|
|
440
|
-
children: "Create an isolated database copy. The branch will be a full clone of the source database at this point in time."
|
|
441
|
-
}),
|
|
442
|
-
createError && /* @__PURE__ */ jsx(Alert, {
|
|
443
|
-
color: "error",
|
|
444
|
-
children: /* @__PURE__ */ jsx(Typography, {
|
|
445
|
-
variant: "body2",
|
|
446
|
-
className: "text-[13px]",
|
|
447
|
-
children: createError
|
|
448
|
-
})
|
|
449
|
-
}),
|
|
450
|
-
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(TextField, {
|
|
451
|
-
label: "Branch Name",
|
|
452
|
-
value: newBranchName,
|
|
453
|
-
onChange: (e) => setNewBranchName(e.target.value),
|
|
454
|
-
placeholder: "e.g. feature-auth, staging, preview-pr-42",
|
|
455
|
-
size: "small",
|
|
456
|
-
autoFocus: true
|
|
457
|
-
}) }),
|
|
458
|
-
branches.length > 0 && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(Select, {
|
|
459
|
-
label: "Source Database",
|
|
460
|
-
value: sourceDatabase ?? "__main__",
|
|
461
|
-
onValueChange: (v) => setSourceDatabase(v === "__main__" ? void 0 : v),
|
|
462
|
-
placeholder: "Default (main database)",
|
|
463
|
-
size: "small",
|
|
464
|
-
children: [/* @__PURE__ */ jsx(SelectItem, {
|
|
465
|
-
value: "__main__",
|
|
466
|
-
children: "Default (main database)"
|
|
467
|
-
}), branches.map((b) => /* @__PURE__ */ jsx(SelectItem, {
|
|
468
|
-
value: b.database,
|
|
469
|
-
children: b.name
|
|
470
|
-
}, b.name))]
|
|
471
|
-
}) })
|
|
472
|
-
]
|
|
473
|
-
}),
|
|
474
|
-
/* @__PURE__ */ jsxs(DialogActions, { children: [/* @__PURE__ */ jsx(Button, {
|
|
475
|
-
variant: "text",
|
|
476
|
-
onClick: () => setCreateOpen(false),
|
|
477
|
-
disabled: creating,
|
|
478
|
-
children: "Cancel"
|
|
479
|
-
}), /* @__PURE__ */ jsx(Button, {
|
|
480
|
-
color: "primary",
|
|
481
|
-
onClick: handleCreate,
|
|
482
|
-
disabled: !newBranchName.trim() || creating,
|
|
483
|
-
startIcon: creating ? /* @__PURE__ */ jsx(CircularProgress, { size: "smallest" }) : /* @__PURE__ */ jsx(PlusIcon, { size: iconSize.smallest }),
|
|
484
|
-
children: creating ? "Creating..." : "Create Branch"
|
|
485
|
-
})] })
|
|
486
|
-
]
|
|
487
|
-
}),
|
|
488
|
-
/* @__PURE__ */ jsx(ConfirmationDialog, {
|
|
489
|
-
open: !!deleteTarget,
|
|
490
|
-
onAccept: handleDelete,
|
|
491
|
-
onCancel: () => setDeleteTarget(null),
|
|
492
|
-
title: "Delete Branch",
|
|
493
|
-
body: /* @__PURE__ */ jsxs(Typography, {
|
|
494
|
-
variant: "body2",
|
|
495
|
-
children: [
|
|
496
|
-
"Are you sure you want to permanently delete the branch ",
|
|
497
|
-
/* @__PURE__ */ jsx("strong", { children: deleteTarget }),
|
|
498
|
-
"? This action cannot be undone and all data in this branch will be lost."
|
|
499
|
-
]
|
|
500
|
-
}),
|
|
501
|
-
loading: deleting
|
|
502
|
-
})
|
|
503
|
-
]
|
|
504
|
-
});
|
|
505
|
-
}
|
|
506
|
-
function StatCard({ label, value, mono }) {
|
|
507
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
508
|
-
className: cls("px-3 py-2 rounded-lg border bg-surface-card", defaultBorderMixin),
|
|
509
|
-
children: [/* @__PURE__ */ jsx(Typography, {
|
|
510
|
-
variant: "caption",
|
|
511
|
-
color: "secondary",
|
|
512
|
-
className: "text-[10px] uppercase tracking-wider font-medium",
|
|
513
|
-
children: label
|
|
514
|
-
}), /* @__PURE__ */ jsx(Typography, {
|
|
515
|
-
variant: "body2",
|
|
516
|
-
className: cls("mt-0.5 font-semibold text-[13px] truncate", mono && "font-mono"),
|
|
517
|
-
children: value
|
|
518
|
-
})]
|
|
519
|
-
});
|
|
520
|
-
}
|
|
521
|
-
//#endregion
|
|
522
|
-
export { BranchesView };
|
|
523
|
-
|
|
524
|
-
//# sourceMappingURL=BranchesView-BHfwGTYc.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BranchesView-BHfwGTYc.js","names":[],"sources":["../src/components/Branches/BranchesView.tsx"],"sourcesContent":["\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\";\n\n/**\n * The prefix the driver puts on every branch database.\n *\n * Stated here rather than derived from the row, because `BranchInfo` carries\n * the *name* a person typed and not the database it became — and the detail\n * pane used to print the name under \"Database:\", which is a connection string\n * to nothing. Kept in step with `BranchService.BRANCH_DB_PREFIX` and the CLI's\n * `branch-pointer.ts`, which say the same thing for the same reason.\n */\nconst BRANCH_DB_PREFIX = \"rb_\";\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: `Branch \"${newBranchName.trim()}\" created successfully`\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: `Branch \"${deleteTarget}\" deleted`\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 py-2.5 border-b bg-surface-sheet min-h-[48px]\", 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 No branches yet. Create one to start working with an isolated database copy.\n </Typography>\n <Button\n size=\"small\"\n variant=\"outlined\"\n onClick={() => setCreateOpen(true)}\n startIcon={<PlusIcon size={iconSize.smallest}/>}\n >\n Create Branch\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-[11px]\">\n from {branch.parentDatabase} · {formatRelative(branch.createdAt)}\n </Typography>\n </div>\n {branch.sizeBytes !== undefined && (\n <Typography variant=\"caption\" color=\"disabled\" className=\"font-mono text-[10px] 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 ? \"Create a branch to get started\" : \"Select a branch to view details\"}\n </Typography>\n </div>\n ) : (\n <>\n {/* Header */}\n <div className={cls(\"flex items-center justify-between px-5 py-3 border-b bg-surface-card min-h-[56px]\", 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 Created from <span className=\"font-mono text-[11px]\">{selected.parentDatabase}</span>\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 Delete\n </Button>\n </div>\n </div>\n\n {/* Info Cards */}\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=\"Branch Name\" value={selected.name} mono/>\n <StatCard label=\"Source Database\" value={selected.parentDatabase} mono/>\n <StatCard label=\"Created\" value={formatRelative(selected.createdAt)}/>\n <StatCard label=\"Size\" value={formatSize(selected.sizeBytes)}/>\n </div>\n </div>\n\n {/* Usage Info */}\n <div className=\"flex-1 overflow-y-auto px-5 py-4\">\n <Alert color=\"info\">\n <Typography variant=\"body2\" className=\"text-[13px]\">\n <strong>How to use this branch:</strong> point this checkout at it with\n <code className=\"mx-1 px-1.5 py-0.5 rounded bg-surface-well font-mono text-[12px]\">rebase db branch switch {selected.name}</code>\n — every later command uses it, and\n <code className=\"mx-1 px-1.5 py-0.5 rounded bg-surface-well font-mono text-[12px]\">rebase db branch switch --off</code>\n goes back to the main database. Changes made here don't affect it.\n </Typography>\n </Alert>\n <div className=\"mt-4 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\">Connection Details</Typography>\n <div className=\"space-y-2\">\n <div className=\"flex items-center gap-2\">\n {/* The *database*, not the branch name. They are not the\n same string — the driver prefixes every branch database\n with `rb_` — and a connection string built from the name\n on this pane pointed at a database that does not\n exist. */}\n <Typography variant=\"caption\" color=\"secondary\" className=\"w-24 shrink-0 text-[11px]\">Database:</Typography>\n <Typography variant=\"body2\" className=\"font-mono text-[12px]\">{`${BRANCH_DB_PREFIX}${selected.name}`}</Typography>\n </div>\n <div className=\"flex items-start gap-2\">\n <Typography variant=\"caption\" color=\"secondary\" className=\"w-24 shrink-0 text-[11px]\">Connect with:</Typography>\n <Typography variant=\"body2\" className=\"font-mono text-[12px] break-all\">\n {`DATABASE_URL=…/${BRANCH_DB_PREFIX}${selected.name}`}\n </Typography>\n </div>\n <div className=\"flex items-center gap-2\">\n <Typography variant=\"caption\" color=\"secondary\" className=\"w-24 shrink-0 text-[11px]\">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-[11px]\">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 </div>\n\n {/* ── Create Dialog ── */}\n <Dialog open={createOpen} onOpenChange={(open) => {\n setCreateOpen(open);\n if (!open) setCreateError(null);\n }}>\n <DialogTitle>Create New Branch</DialogTitle>\n <DialogContent className=\"space-y-4 min-w-[400px]\">\n <Typography variant=\"body2\" color=\"secondary\" className=\"text-[13px]\">\n Create an isolated database copy. The branch will be a full clone of the source database at this point in time.\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=\"Branch Name\"\n value={newBranchName}\n onChange={(e) => setNewBranchName(e.target.value)}\n placeholder=\"e.g. feature-auth, staging, preview-pr-42\"\n size=\"small\"\n autoFocus\n />\n </div>\n {branches.length > 0 && (\n <div>\n <Select\n label=\"Source Database\"\n value={sourceDatabase ?? \"__main__\"}\n onValueChange={(v) => setSourceDatabase(v === \"__main__\" ? undefined : v)}\n placeholder=\"Default (main database)\"\n size=\"small\"\n >\n <SelectItem value=\"__main__\">Default (main database)</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 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 ? \"Creating...\" : \"Create Branch\"}\n </Button>\n </DialogActions>\n </Dialog>\n\n {/* ── Delete Confirm ── */}\n <ConfirmationDialog\n open={!!deleteTarget}\n onAccept={handleDelete}\n onCancel={() => setDeleteTarget(null)}\n title=\"Delete Branch\"\n body={\n <Typography variant=\"body2\">\n Are you sure you want to permanently delete the branch <strong>{deleteTarget}</strong>?\n This action cannot be undone and all data in this branch will be lost.\n </Typography>\n }\n loading={deleting}\n />\n </div>\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":";;;;;;;;;;;;;;;;;;AA0CA,IAAM,mBAAmB;AAGzB,SAAS,WAAW,OAAmC;CACnD,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM,OAAO;CAClD,IAAI,QAAQ,MAAM,OAAO,GAAG,MAAM;CAClC,IAAI,QAAQ,OAAO,MAAM,OAAO,IAAI,QAAQ,KAAA,CAAM,QAAQ,CAAC,EAAE;CAC7D,IAAI,QAAQ,OAAO,OAAO,MAAM,OAAO,IAAI,SAAS,OAAO,MAAA,CAAO,QAAQ,CAAC,EAAE;CAC7E,OAAO,IAAI,SAAS,OAAO,OAAO,MAAA,CAAO,QAAQ,CAAC,EAAE;AACxD;AAEA,SAAS,eAAe,MAAyC;CAC7D,IAAI,CAAC,MAAM,OA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