@rebasepro/studio 0.34.1 → 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
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { a as asStringArray, i as asString, o as isRecord, r as asNumber, s as useAdminFetch, t as asBoolean } from "./adminFetch-BfOnfRgU.js";
|
|
1
2
|
import { t as classifyLoadFailure } from "./load-failure-Bd8lFIO7.js";
|
|
2
3
|
import { ErrorView, useApiBase, useApiConfig, useSnackbarController, useStorageSource, useStorageSources, useTranslation } from "@rebasepro/app";
|
|
3
4
|
import React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
4
|
-
import { ArrowLeftIcon, Button, CheckIcon, Checkbox, Chip, CircularProgress, CopyIcon, Dialog, DialogActions, DialogContent, DialogTitle, DownloadIcon, FileTextIcon, FileUpload, FolderIcon, FolderPlusIcon, IconButton, ImageIcon, LayoutGridIcon, ListIcon, LoadingButton, Music2Icon, PlusIcon, RefreshCwIcon, Select, SelectItem, Table, TableBody, TableCell, TableHeader, TableRow, TextField, Tooltip, Trash2Icon, Typography, UploadCloudIcon, VideoIcon, XIcon, cls, defaultBorderMixin, iconSize, isKeyHandled } from "@rebasepro/ui";
|
|
5
|
+
import { Alert, ArrowLeftIcon, BooleanSwitch, BooleanSwitchWithLabel, Button, Card, CheckIcon, Checkbox, Chip, CircularProgress, CopyIcon, Dialog, DialogActions, DialogContent, DialogTitle, DownloadIcon, FileTextIcon, FileUpload, FolderIcon, FolderPlusIcon, IconButton, ImageIcon, LayoutGridIcon, ListIcon, LoadingButton, Music2Icon, PencilIcon, PlusIcon, RefreshCwIcon, Select, SelectItem, ShieldIcon, Tab, Table, TableBody, TableCell, TableHeader, TableRow, Tabs, TextField, Tooltip, Trash2Icon, Typography, UploadCloudIcon, VideoIcon, XIcon, cls, defaultBorderMixin, iconSize, isKeyHandled } from "@rebasepro/ui";
|
|
5
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
import { useSearchParams } from "react-router";
|
|
7
8
|
import { DEFAULT_STORAGE_SOURCE_KEY, isPublicStorageKey } from "@rebasepro/types";
|
|
@@ -158,6 +159,473 @@ function useVisibleFileMetadata(source, files, wants = () => true) {
|
|
|
158
159
|
};
|
|
159
160
|
}
|
|
160
161
|
//#endregion
|
|
162
|
+
//#region src/components/StorageView/StoragePoliciesPanel.tsx
|
|
163
|
+
var OPERATIONS = [
|
|
164
|
+
"read",
|
|
165
|
+
"write",
|
|
166
|
+
"delete",
|
|
167
|
+
"list"
|
|
168
|
+
];
|
|
169
|
+
var RULE_KINDS = [
|
|
170
|
+
{
|
|
171
|
+
value: "public",
|
|
172
|
+
labelKey: "studio_storage_policies_rule_public"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
value: "authenticated",
|
|
176
|
+
labelKey: "studio_storage_policies_rule_authenticated"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
value: "owner",
|
|
180
|
+
labelKey: "studio_storage_policies_rule_owner"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
value: "roles",
|
|
184
|
+
labelKey: "studio_storage_policies_rule_roles"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
value: "claim",
|
|
188
|
+
labelKey: "studio_storage_policies_rule_claim"
|
|
189
|
+
}
|
|
190
|
+
];
|
|
191
|
+
function parsePolicy(raw) {
|
|
192
|
+
if (!isRecord(raw) || typeof raw.id !== "string") return null;
|
|
193
|
+
const pathPattern = asString(raw.pathPattern ?? raw.pathPrefix, "");
|
|
194
|
+
return {
|
|
195
|
+
id: raw.id,
|
|
196
|
+
name: asString(raw.name, pathPattern || raw.id),
|
|
197
|
+
bucket: asString(raw.bucket, "default"),
|
|
198
|
+
pathPattern,
|
|
199
|
+
operations: asStringArray(raw.operations),
|
|
200
|
+
rule: isRecord(raw.rule) ? raw.rule : { kind: "authenticated" },
|
|
201
|
+
priority: asNumber(raw.priority, 100),
|
|
202
|
+
enabled: asBoolean(raw.enabled, true)
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
/** A rule as the table shows it; `none` is the word for a roles rule that names no role. */
|
|
206
|
+
function describeRule(rule, none) {
|
|
207
|
+
const kind = asString(rule.kind, "authenticated");
|
|
208
|
+
if (kind === "roles") return `roles: ${asStringArray(rule.roles).join(", ") || `(${none})`}`;
|
|
209
|
+
if (kind === "claim") {
|
|
210
|
+
const target = typeof rule.param === "string" && rule.param ? `:${rule.param}` : String(rule.equals ?? "");
|
|
211
|
+
return `claim: ${asString(rule.claim)} == ${target}`;
|
|
212
|
+
}
|
|
213
|
+
if (kind === "owner") return `owner (:${asString(rule.param, "uid")})`;
|
|
214
|
+
return kind;
|
|
215
|
+
}
|
|
216
|
+
function StoragePoliciesPanel() {
|
|
217
|
+
const { requestJson } = useAdminFetch();
|
|
218
|
+
const snackbar = useSnackbarController();
|
|
219
|
+
const { t } = useTranslation();
|
|
220
|
+
const [policies, setPolicies] = useState([]);
|
|
221
|
+
const [loading, setLoading] = useState(true);
|
|
222
|
+
const [error, setError] = useState(null);
|
|
223
|
+
const [dialogOpen, setDialogOpen] = useState(false);
|
|
224
|
+
const [editing, setEditing] = useState(null);
|
|
225
|
+
const [policyName, setPolicyName] = useState("");
|
|
226
|
+
const [bucket, setBucket] = useState("default");
|
|
227
|
+
const [pathPattern, setPathPattern] = useState("public/**");
|
|
228
|
+
const [operations, setOperations] = useState(["read"]);
|
|
229
|
+
const [ruleKind, setRuleKind] = useState("public");
|
|
230
|
+
const [ruleRoles, setRuleRoles] = useState("admin");
|
|
231
|
+
const [ruleOwnerParam, setRuleOwnerParam] = useState("uid");
|
|
232
|
+
const [ruleClaim, setRuleClaim] = useState("org_id");
|
|
233
|
+
const [ruleClaimValue, setRuleClaimValue] = useState("");
|
|
234
|
+
const [priority, setPriority] = useState("100");
|
|
235
|
+
const [enabled, setEnabled] = useState(true);
|
|
236
|
+
const [saving, setSaving] = useState(false);
|
|
237
|
+
const load = useCallback(async () => {
|
|
238
|
+
setLoading(true);
|
|
239
|
+
setError(null);
|
|
240
|
+
try {
|
|
241
|
+
const raw = await requestJson("/admin/storage/policies");
|
|
242
|
+
const arr = isRecord(raw) && Array.isArray(raw.policies) ? raw.policies : [];
|
|
243
|
+
setPolicies(arr.map(parsePolicy).filter((p) => p !== null));
|
|
244
|
+
} catch (err) {
|
|
245
|
+
setError(err instanceof Error ? err.message : t("studio_storage_policies_load_failed"));
|
|
246
|
+
} finally {
|
|
247
|
+
setLoading(false);
|
|
248
|
+
}
|
|
249
|
+
}, [requestJson, t]);
|
|
250
|
+
useEffect(() => {
|
|
251
|
+
load();
|
|
252
|
+
}, [load]);
|
|
253
|
+
const openCreate = () => {
|
|
254
|
+
setEditing(null);
|
|
255
|
+
setPolicyName(t("studio_storage_policies_default_name"));
|
|
256
|
+
setBucket("default");
|
|
257
|
+
setPathPattern("public/**");
|
|
258
|
+
setOperations(["read"]);
|
|
259
|
+
setRuleKind("public");
|
|
260
|
+
setRuleRoles("admin");
|
|
261
|
+
setRuleOwnerParam("uid");
|
|
262
|
+
setRuleClaim("org_id");
|
|
263
|
+
setRuleClaimValue("");
|
|
264
|
+
setPriority("100");
|
|
265
|
+
setEnabled(true);
|
|
266
|
+
setDialogOpen(true);
|
|
267
|
+
};
|
|
268
|
+
const openEdit = (p) => {
|
|
269
|
+
setEditing(p);
|
|
270
|
+
setPolicyName(p.name);
|
|
271
|
+
setBucket(p.bucket);
|
|
272
|
+
setPathPattern(p.pathPattern);
|
|
273
|
+
setOperations([...p.operations]);
|
|
274
|
+
const kind = asString(p.rule.kind, "authenticated");
|
|
275
|
+
setRuleKind(kind);
|
|
276
|
+
setRuleRoles(asStringArray(p.rule.roles).join(", "));
|
|
277
|
+
setRuleOwnerParam(asString(p.rule.param, "uid"));
|
|
278
|
+
setRuleClaim(asString(p.rule.claim, "org_id"));
|
|
279
|
+
setRuleClaimValue(String(p.rule.equals ?? ""));
|
|
280
|
+
setPriority(String(p.priority));
|
|
281
|
+
setEnabled(p.enabled);
|
|
282
|
+
setDialogOpen(true);
|
|
283
|
+
};
|
|
284
|
+
const toggleOp = (op) => {
|
|
285
|
+
setOperations((prev) => prev.includes(op) ? prev.filter((o) => o !== op) : [...prev, op]);
|
|
286
|
+
};
|
|
287
|
+
const buildRule = () => {
|
|
288
|
+
if (ruleKind === "roles") return {
|
|
289
|
+
kind: "roles",
|
|
290
|
+
roles: ruleRoles.split(",").map((s) => s.trim()).filter(Boolean)
|
|
291
|
+
};
|
|
292
|
+
if (ruleKind === "owner") return {
|
|
293
|
+
kind: "owner",
|
|
294
|
+
param: ruleOwnerParam.trim() || "uid"
|
|
295
|
+
};
|
|
296
|
+
if (ruleKind === "claim") return {
|
|
297
|
+
kind: "claim",
|
|
298
|
+
claim: ruleClaim.trim(),
|
|
299
|
+
equals: ruleClaimValue
|
|
300
|
+
};
|
|
301
|
+
return { kind: ruleKind };
|
|
302
|
+
};
|
|
303
|
+
const handleSave = async () => {
|
|
304
|
+
setSaving(true);
|
|
305
|
+
try {
|
|
306
|
+
const trimmedPattern = pathPattern.trim();
|
|
307
|
+
const payload = {
|
|
308
|
+
name: policyName.trim() || `${bucket.trim() || "default"}:${trimmedPattern}`,
|
|
309
|
+
bucket: bucket.trim() || "default",
|
|
310
|
+
pathPattern: trimmedPattern,
|
|
311
|
+
operations,
|
|
312
|
+
rule: buildRule(),
|
|
313
|
+
priority: Number(priority) || 100,
|
|
314
|
+
enabled
|
|
315
|
+
};
|
|
316
|
+
if (editing) {
|
|
317
|
+
await requestJson(`/admin/storage/policies/${encodeURIComponent(editing.id)}`, {
|
|
318
|
+
method: "PATCH",
|
|
319
|
+
body: payload
|
|
320
|
+
});
|
|
321
|
+
snackbar.open({
|
|
322
|
+
type: "success",
|
|
323
|
+
message: t("studio_storage_policies_updated")
|
|
324
|
+
});
|
|
325
|
+
} else {
|
|
326
|
+
await requestJson("/admin/storage/policies", {
|
|
327
|
+
method: "POST",
|
|
328
|
+
body: payload
|
|
329
|
+
});
|
|
330
|
+
snackbar.open({
|
|
331
|
+
type: "success",
|
|
332
|
+
message: t("studio_storage_policies_created")
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
setDialogOpen(false);
|
|
336
|
+
await load();
|
|
337
|
+
} catch (err) {
|
|
338
|
+
snackbar.open({
|
|
339
|
+
type: "error",
|
|
340
|
+
message: err instanceof Error ? err.message : t("studio_storage_policies_save_failed")
|
|
341
|
+
});
|
|
342
|
+
} finally {
|
|
343
|
+
setSaving(false);
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
const handleToggle = async (p, next) => {
|
|
347
|
+
try {
|
|
348
|
+
await requestJson(`/admin/storage/policies/${encodeURIComponent(p.id)}`, {
|
|
349
|
+
method: "PATCH",
|
|
350
|
+
body: { enabled: next }
|
|
351
|
+
});
|
|
352
|
+
await load();
|
|
353
|
+
} catch (err) {
|
|
354
|
+
snackbar.open({
|
|
355
|
+
type: "error",
|
|
356
|
+
message: err instanceof Error ? err.message : t("studio_storage_policies_toggle_failed")
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
const handleDelete = async (p) => {
|
|
361
|
+
try {
|
|
362
|
+
await requestJson(`/admin/storage/policies/${encodeURIComponent(p.id)}`, { method: "DELETE" });
|
|
363
|
+
snackbar.open({
|
|
364
|
+
type: "success",
|
|
365
|
+
message: t("studio_storage_policies_deleted")
|
|
366
|
+
});
|
|
367
|
+
await load();
|
|
368
|
+
} catch (err) {
|
|
369
|
+
snackbar.open({
|
|
370
|
+
type: "error",
|
|
371
|
+
message: err instanceof Error ? err.message : t("studio_storage_policies_delete_failed")
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
376
|
+
className: "flex flex-col gap-4 p-5 h-full overflow-auto bg-surface-card",
|
|
377
|
+
children: [
|
|
378
|
+
/* @__PURE__ */ jsxs("div", {
|
|
379
|
+
className: "flex items-center justify-between gap-4",
|
|
380
|
+
children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Typography, {
|
|
381
|
+
variant: "subtitle1",
|
|
382
|
+
className: "font-semibold",
|
|
383
|
+
children: t("studio_storage_policies_title")
|
|
384
|
+
}), /* @__PURE__ */ jsx(Typography, {
|
|
385
|
+
variant: "caption",
|
|
386
|
+
color: "secondary",
|
|
387
|
+
children: t("studio_storage_policies_subtitle")
|
|
388
|
+
})] }), /* @__PURE__ */ jsxs("div", {
|
|
389
|
+
className: "flex items-center gap-2",
|
|
390
|
+
children: [/* @__PURE__ */ jsx(Tooltip, {
|
|
391
|
+
title: t("studio_storage_policies_refresh"),
|
|
392
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
393
|
+
size: "small",
|
|
394
|
+
"aria-label": t("studio_storage_policies_refresh_aria"),
|
|
395
|
+
onClick: () => void load(),
|
|
396
|
+
children: /* @__PURE__ */ jsx(RefreshCwIcon, { size: iconSize.small })
|
|
397
|
+
})
|
|
398
|
+
}), /* @__PURE__ */ jsxs(Button, {
|
|
399
|
+
size: "small",
|
|
400
|
+
color: "primary",
|
|
401
|
+
variant: "filled",
|
|
402
|
+
onClick: openCreate,
|
|
403
|
+
children: [/* @__PURE__ */ jsx(PlusIcon, { size: iconSize.small }), t("studio_new_policy")]
|
|
404
|
+
})]
|
|
405
|
+
})]
|
|
406
|
+
}),
|
|
407
|
+
error && /* @__PURE__ */ jsx(Alert, {
|
|
408
|
+
color: "error",
|
|
409
|
+
children: error
|
|
410
|
+
}),
|
|
411
|
+
loading ? /* @__PURE__ */ jsx("div", {
|
|
412
|
+
className: "flex justify-center py-12",
|
|
413
|
+
children: /* @__PURE__ */ jsx(CircularProgress, { size: "small" })
|
|
414
|
+
}) : policies.length === 0 ? /* @__PURE__ */ jsxs(Card, {
|
|
415
|
+
className: "p-8 text-center flex flex-col items-center gap-3",
|
|
416
|
+
children: [
|
|
417
|
+
/* @__PURE__ */ jsx(ShieldIcon, { className: "w-8 h-8 text-text-disabled" }),
|
|
418
|
+
/* @__PURE__ */ jsx(Typography, {
|
|
419
|
+
variant: "body2",
|
|
420
|
+
color: "secondary",
|
|
421
|
+
children: t("studio_storage_policies_empty")
|
|
422
|
+
}),
|
|
423
|
+
/* @__PURE__ */ jsxs(Button, {
|
|
424
|
+
size: "small",
|
|
425
|
+
variant: "filled",
|
|
426
|
+
onClick: openCreate,
|
|
427
|
+
children: [/* @__PURE__ */ jsx(PlusIcon, { size: iconSize.small }), t("studio_storage_policies_create_first")]
|
|
428
|
+
})
|
|
429
|
+
]
|
|
430
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
431
|
+
className: cls("overflow-x-auto rounded-lg border", defaultBorderMixin),
|
|
432
|
+
children: /* @__PURE__ */ jsxs(Table, {
|
|
433
|
+
className: "w-full",
|
|
434
|
+
children: [/* @__PURE__ */ jsxs(TableHeader, { children: [
|
|
435
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
436
|
+
header: true,
|
|
437
|
+
children: t("name")
|
|
438
|
+
}),
|
|
439
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
440
|
+
header: true,
|
|
441
|
+
children: t("studio_storage_policies_priority")
|
|
442
|
+
}),
|
|
443
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
444
|
+
header: true,
|
|
445
|
+
children: t("studio_storage_policies_bucket")
|
|
446
|
+
}),
|
|
447
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
448
|
+
header: true,
|
|
449
|
+
children: t("studio_storage_policies_path_pattern")
|
|
450
|
+
}),
|
|
451
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
452
|
+
header: true,
|
|
453
|
+
children: t("studio_storage_policies_operations")
|
|
454
|
+
}),
|
|
455
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
456
|
+
header: true,
|
|
457
|
+
children: t("studio_storage_policies_rule")
|
|
458
|
+
}),
|
|
459
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
460
|
+
header: true,
|
|
461
|
+
children: t("studio_enabled")
|
|
462
|
+
}),
|
|
463
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
464
|
+
header: true,
|
|
465
|
+
className: "text-right",
|
|
466
|
+
children: t("actions")
|
|
467
|
+
})
|
|
468
|
+
] }), /* @__PURE__ */ jsx(TableBody, { children: policies.map((p) => /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
469
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
470
|
+
className: "font-medium text-sm",
|
|
471
|
+
children: p.name
|
|
472
|
+
}),
|
|
473
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
474
|
+
className: "font-mono text-xs",
|
|
475
|
+
children: p.priority
|
|
476
|
+
}),
|
|
477
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
478
|
+
className: "font-mono text-xs",
|
|
479
|
+
children: p.bucket
|
|
480
|
+
}),
|
|
481
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
482
|
+
className: "font-mono text-sm",
|
|
483
|
+
children: p.pathPattern || "**"
|
|
484
|
+
}),
|
|
485
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx("div", {
|
|
486
|
+
className: "flex items-center gap-1 flex-wrap",
|
|
487
|
+
children: p.operations.map((op) => /* @__PURE__ */ jsx(Chip, {
|
|
488
|
+
size: "small",
|
|
489
|
+
colorScheme: "blueLight",
|
|
490
|
+
children: op
|
|
491
|
+
}, op))
|
|
492
|
+
}) }),
|
|
493
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
494
|
+
className: "font-mono text-xs",
|
|
495
|
+
children: describeRule(p.rule, t("studio_users_no_roles"))
|
|
496
|
+
}),
|
|
497
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(BooleanSwitch, {
|
|
498
|
+
size: "small",
|
|
499
|
+
value: p.enabled,
|
|
500
|
+
onValueChange: (v) => void handleToggle(p, v)
|
|
501
|
+
}) }),
|
|
502
|
+
/* @__PURE__ */ jsxs(TableCell, {
|
|
503
|
+
className: "text-right whitespace-nowrap",
|
|
504
|
+
children: [/* @__PURE__ */ jsx(IconButton, {
|
|
505
|
+
size: "small",
|
|
506
|
+
"aria-label": t("studio_storage_policies_edit_aria"),
|
|
507
|
+
onClick: () => openEdit(p),
|
|
508
|
+
children: /* @__PURE__ */ jsx(PencilIcon, { size: iconSize.small })
|
|
509
|
+
}), /* @__PURE__ */ jsx(IconButton, {
|
|
510
|
+
size: "small",
|
|
511
|
+
"aria-label": t("studio_storage_policies_delete_aria"),
|
|
512
|
+
onClick: () => void handleDelete(p),
|
|
513
|
+
children: /* @__PURE__ */ jsx(Trash2Icon, {
|
|
514
|
+
size: iconSize.small,
|
|
515
|
+
className: "text-red-500"
|
|
516
|
+
})
|
|
517
|
+
})]
|
|
518
|
+
})
|
|
519
|
+
] }, p.id)) })]
|
|
520
|
+
})
|
|
521
|
+
}),
|
|
522
|
+
/* @__PURE__ */ jsxs(Dialog, {
|
|
523
|
+
open: dialogOpen,
|
|
524
|
+
onOpenChange: setDialogOpen,
|
|
525
|
+
maxWidth: "md",
|
|
526
|
+
fullWidth: true,
|
|
527
|
+
children: [
|
|
528
|
+
/* @__PURE__ */ jsx(DialogTitle, { children: editing ? t("studio_storage_policies_edit_title") : t("studio_storage_policies_new_title") }),
|
|
529
|
+
/* @__PURE__ */ jsxs(DialogContent, {
|
|
530
|
+
className: "flex flex-col gap-3",
|
|
531
|
+
children: [
|
|
532
|
+
/* @__PURE__ */ jsx(TextField, {
|
|
533
|
+
label: t("studio_policy_name"),
|
|
534
|
+
value: policyName,
|
|
535
|
+
onChange: (e) => setPolicyName(e.target.value),
|
|
536
|
+
placeholder: t("studio_storage_policies_name_placeholder")
|
|
537
|
+
}),
|
|
538
|
+
/* @__PURE__ */ jsxs("div", {
|
|
539
|
+
className: "grid grid-cols-2 gap-3",
|
|
540
|
+
children: [/* @__PURE__ */ jsx(TextField, {
|
|
541
|
+
label: t("studio_storage_policies_bucket"),
|
|
542
|
+
value: bucket,
|
|
543
|
+
onChange: (e) => setBucket(e.target.value),
|
|
544
|
+
placeholder: "default"
|
|
545
|
+
}), /* @__PURE__ */ jsx(TextField, {
|
|
546
|
+
label: t("studio_storage_policies_priority_label"),
|
|
547
|
+
value: priority,
|
|
548
|
+
onChange: (e) => setPriority(e.target.value)
|
|
549
|
+
})]
|
|
550
|
+
}),
|
|
551
|
+
/* @__PURE__ */ jsx(TextField, {
|
|
552
|
+
label: t("studio_storage_policies_path_pattern"),
|
|
553
|
+
value: pathPattern,
|
|
554
|
+
onChange: (e) => setPathPattern(e.target.value),
|
|
555
|
+
placeholder: t("studio_storage_policies_path_placeholder")
|
|
556
|
+
}),
|
|
557
|
+
/* @__PURE__ */ jsxs("div", {
|
|
558
|
+
className: "flex flex-col gap-1.5",
|
|
559
|
+
children: [/* @__PURE__ */ jsx(Typography, {
|
|
560
|
+
variant: "subtitle2",
|
|
561
|
+
children: t("studio_storage_policies_allowed_operations")
|
|
562
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
563
|
+
className: "flex items-center gap-1.5 flex-wrap",
|
|
564
|
+
children: OPERATIONS.map((op) => /* @__PURE__ */ jsx(Chip, {
|
|
565
|
+
size: "small",
|
|
566
|
+
colorScheme: operations.includes(op) ? "blueLight" : "grayLight",
|
|
567
|
+
onClick: () => toggleOp(op),
|
|
568
|
+
children: op
|
|
569
|
+
}, op))
|
|
570
|
+
})]
|
|
571
|
+
}),
|
|
572
|
+
/* @__PURE__ */ jsx(Select, {
|
|
573
|
+
label: t("studio_storage_policies_access_rule"),
|
|
574
|
+
value: ruleKind,
|
|
575
|
+
onValueChange: (v) => setRuleKind(String(v)),
|
|
576
|
+
children: RULE_KINDS.map((k) => /* @__PURE__ */ jsx(SelectItem, {
|
|
577
|
+
value: k.value,
|
|
578
|
+
children: t(k.labelKey)
|
|
579
|
+
}, k.value))
|
|
580
|
+
}),
|
|
581
|
+
ruleKind === "roles" && /* @__PURE__ */ jsx(TextField, {
|
|
582
|
+
label: t("studio_roles_comma_separated"),
|
|
583
|
+
value: ruleRoles,
|
|
584
|
+
onChange: (e) => setRuleRoles(e.target.value),
|
|
585
|
+
placeholder: "admin, editor"
|
|
586
|
+
}),
|
|
587
|
+
ruleKind === "owner" && /* @__PURE__ */ jsx(TextField, {
|
|
588
|
+
label: t("studio_storage_policies_owner_param_label"),
|
|
589
|
+
value: ruleOwnerParam,
|
|
590
|
+
onChange: (e) => setRuleOwnerParam(e.target.value),
|
|
591
|
+
placeholder: "uid"
|
|
592
|
+
}),
|
|
593
|
+
ruleKind === "claim" && /* @__PURE__ */ jsxs("div", {
|
|
594
|
+
className: "grid grid-cols-2 gap-3",
|
|
595
|
+
children: [/* @__PURE__ */ jsx(TextField, {
|
|
596
|
+
label: t("studio_storage_policies_claim_key"),
|
|
597
|
+
value: ruleClaim,
|
|
598
|
+
onChange: (e) => setRuleClaim(e.target.value),
|
|
599
|
+
placeholder: "org_id"
|
|
600
|
+
}), /* @__PURE__ */ jsx(TextField, {
|
|
601
|
+
label: t("studio_storage_policies_claim_value"),
|
|
602
|
+
value: ruleClaimValue,
|
|
603
|
+
onChange: (e) => setRuleClaimValue(e.target.value)
|
|
604
|
+
})]
|
|
605
|
+
}),
|
|
606
|
+
/* @__PURE__ */ jsx(BooleanSwitchWithLabel, {
|
|
607
|
+
label: t("studio_enabled"),
|
|
608
|
+
value: enabled,
|
|
609
|
+
onValueChange: setEnabled
|
|
610
|
+
})
|
|
611
|
+
]
|
|
612
|
+
}),
|
|
613
|
+
/* @__PURE__ */ jsxs(DialogActions, { children: [/* @__PURE__ */ jsx(Button, {
|
|
614
|
+
variant: "text",
|
|
615
|
+
onClick: () => setDialogOpen(false),
|
|
616
|
+
children: t("cancel")
|
|
617
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
618
|
+
variant: "filled",
|
|
619
|
+
disabled: saving || operations.length === 0 || !pathPattern.trim(),
|
|
620
|
+
onClick: () => void handleSave(),
|
|
621
|
+
children: saving ? t("saving") : t("studio_policy_save")
|
|
622
|
+
})] })
|
|
623
|
+
]
|
|
624
|
+
})
|
|
625
|
+
]
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
//#endregion
|
|
161
629
|
//#region src/components/StorageView/StorageView.tsx
|
|
162
630
|
function fileLinkOf(config, fullPath) {
|
|
163
631
|
if (!config.url) return null;
|
|
@@ -480,7 +948,7 @@ function FilePreviewPanel({ file, onClose, onDelete, link, mintLink }) {
|
|
|
480
948
|
className: cls("flex flex-col h-full border-l", defaultBorderMixin, "bg-surface-card"),
|
|
481
949
|
children: [
|
|
482
950
|
/* @__PURE__ */ jsxs("div", {
|
|
483
|
-
className: cls("flex items-center justify-between
|
|
951
|
+
className: cls("flex items-center justify-between h-10 px-3 border-b bg-surface-sheet shrink-0", defaultBorderMixin),
|
|
484
952
|
children: [/* @__PURE__ */ jsx(Typography, {
|
|
485
953
|
variant: "body2",
|
|
486
954
|
className: "font-medium truncate flex-1 mr-2",
|
|
@@ -695,6 +1163,31 @@ function FilePreviewPanel({ file, onClose, onDelete, link, mintLink }) {
|
|
|
695
1163
|
})] });
|
|
696
1164
|
}
|
|
697
1165
|
var StorageView = () => {
|
|
1166
|
+
const [tab, setTab] = useState("files");
|
|
1167
|
+
const { t } = useTranslation();
|
|
1168
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1169
|
+
className: "flex flex-col h-full w-full overflow-hidden",
|
|
1170
|
+
children: [/* @__PURE__ */ jsxs(Tabs, {
|
|
1171
|
+
value: tab,
|
|
1172
|
+
onValueChange: (v) => {
|
|
1173
|
+
if (v === "files" || v === "policies") setTab(v);
|
|
1174
|
+
},
|
|
1175
|
+
variant: "boxy",
|
|
1176
|
+
className: "border-b border-hairline px-4 bg-surface-sheet shrink-0",
|
|
1177
|
+
children: [/* @__PURE__ */ jsx(Tab, {
|
|
1178
|
+
value: "files",
|
|
1179
|
+
children: t("studio_storage_tab_files")
|
|
1180
|
+
}), /* @__PURE__ */ jsx(Tab, {
|
|
1181
|
+
value: "policies",
|
|
1182
|
+
children: t("studio_storage_tab_policies")
|
|
1183
|
+
})]
|
|
1184
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
1185
|
+
className: "flex-1 min-h-0 overflow-hidden",
|
|
1186
|
+
children: tab === "files" ? /* @__PURE__ */ jsx(StorageFilesBrowser, {}) : /* @__PURE__ */ jsx(StoragePoliciesPanel, {})
|
|
1187
|
+
})]
|
|
1188
|
+
});
|
|
1189
|
+
};
|
|
1190
|
+
var StorageFilesBrowser = () => {
|
|
698
1191
|
const { t } = useTranslation();
|
|
699
1192
|
const defaultStorageSource = useStorageSource();
|
|
700
1193
|
const storageSources = useStorageSources();
|
|
@@ -1504,7 +1997,7 @@ var StorageView = () => {
|
|
|
1504
1997
|
className: "flex-grow flex flex-col min-w-0 h-full",
|
|
1505
1998
|
children: [
|
|
1506
1999
|
/* @__PURE__ */ jsxs("div", {
|
|
1507
|
-
className: cls("flex items-center justify-between pr-2 border-b bg-surface-
|
|
2000
|
+
className: cls("flex items-center justify-between pr-2 border-b bg-surface-sheet shrink-0 h-10", defaultBorderMixin),
|
|
1508
2001
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
1509
2002
|
className: "flex items-center gap-1.5 flex-grow overflow-hidden px-3 py-2",
|
|
1510
2003
|
children: [
|
|
@@ -1874,4 +2367,4 @@ var StorageView = () => {
|
|
|
1874
2367
|
//#endregion
|
|
1875
2368
|
export { StorageView };
|
|
1876
2369
|
|
|
1877
|
-
//# sourceMappingURL=StorageView-
|
|
2370
|
+
//# sourceMappingURL=StorageView-D0D8z4lI.js.map
|