@rebasepro/studio 0.23.0 → 0.24.1-canary.g56af4a4
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/{ApiExplorer-pYMZflL3.js → ApiExplorer-Bzt7Ye49.js} +18 -29
- package/dist/ApiExplorer-Bzt7Ye49.js.map +1 -0
- package/dist/ApiKeysView-Bqf6XYR1.js +1739 -0
- package/dist/ApiKeysView-Bqf6XYR1.js.map +1 -0
- package/dist/BackupsView-BhOHB6iP.js +354 -0
- package/dist/BackupsView-BhOHB6iP.js.map +1 -0
- package/dist/{BranchesView-D6Sz1a5f.js → BranchesView-BHfwGTYc.js} +16 -10
- package/dist/BranchesView-BHfwGTYc.js.map +1 -0
- package/dist/{CronJobsView-7hjgSYId.js → CronJobsView-CMNK7eWO.js} +175 -116
- package/dist/CronJobsView-CMNK7eWO.js.map +1 -0
- package/dist/{JSEditor-qiuwmcvk.js → JSEditor-DIO2Mw8q.js} +230 -165
- package/dist/JSEditor-DIO2Mw8q.js.map +1 -0
- package/dist/{LogsExplorer-Xq8K4oo6.js → LogsExplorer-C-bwDFIl.js} +66 -44
- package/dist/LogsExplorer-C-bwDFIl.js.map +1 -0
- package/dist/{RLSEditor-Djh43lBE.js → RLSEditor-jFD_d06f.js} +246 -84
- package/dist/RLSEditor-jFD_d06f.js.map +1 -0
- package/dist/{SQLEditor-TBw_K6CW.js → SQLEditor-D5Ci4pyW.js} +502 -600
- package/dist/SQLEditor-D5Ci4pyW.js.map +1 -0
- package/dist/{SchemaVisualizer-DtDzIUNy.js → SchemaVisualizer-D-rAqwul.js} +496 -227
- package/dist/SchemaVisualizer-D-rAqwul.js.map +1 -0
- package/dist/{StorageView-CMG1DOVX.js → StorageView-CPkDKbsX.js} +838 -451
- package/dist/StorageView-CPkDKbsX.js.map +1 -0
- package/dist/assets/dagre-layout.worker-BFnhAzuR.js.map +1 -0
- package/dist/components/ApiExplorer/TryItPanel.d.ts +6 -1
- package/dist/components/ApiKeys/CreateApiKeyDialog.d.ts +21 -2
- package/dist/components/ApiKeys/scope-words.d.ts +37 -0
- package/dist/components/ApiKeys/scopes.d.ts +113 -0
- package/dist/components/AuthSimulationSelector.d.ts +5 -1
- package/dist/components/LogsExplorer/useLogTail.d.ts +9 -0
- package/dist/components/RLSEditor/policyListing.d.ts +44 -0
- package/dist/components/SQLEditor/SQLEditor.d.ts +11 -0
- package/dist/components/SchemaVisualizer/dagre-layout.d.ts +32 -0
- package/dist/components/SchemaVisualizer/dagre-layout.worker.d.ts +13 -0
- package/dist/components/SchemaVisualizer/layout-runner.d.ts +23 -0
- package/dist/components/SchemaVisualizer/schema-visualizer.utils.d.ts +21 -11
- package/dist/components/SchemaVisualizer/useSchemaGraph.d.ts +44 -1
- package/dist/components/StorageView/useVisibleFileMetadata.d.ts +46 -0
- package/dist/components/load-failure.d.ts +1 -1
- package/dist/components/useRunAsUsers.d.ts +25 -0
- package/dist/dagre-layout.worker-j9NbH9Gb.js +27 -0
- package/dist/dagre-layout.worker-j9NbH9Gb.js.map +1 -0
- package/dist/index.es.js +16 -14
- package/dist/index.es.js.map +1 -1
- package/dist/{load-failure-C6OMJSGC.js → load-failure-Bd8lFIO7.js} +2 -2
- package/dist/load-failure-Bd8lFIO7.js.map +1 -0
- package/dist/sql_utils-BZD31xE3.js +478 -0
- package/dist/sql_utils-BZD31xE3.js.map +1 -0
- package/dist/useRunAsUsers-CLaAtXt6.js +122 -0
- package/dist/useRunAsUsers-CLaAtXt6.js.map +1 -0
- package/dist/utils/sql_utils.d.ts +150 -49
- package/package.json +9 -9
- package/dist/ApiExplorer-pYMZflL3.js.map +0 -1
- package/dist/ApiKeysView-qLSs47tw.js +0 -1239
- package/dist/ApiKeysView-qLSs47tw.js.map +0 -1
- package/dist/AuthSimulationSelector-BewmhMBw.js +0 -56
- package/dist/AuthSimulationSelector-BewmhMBw.js.map +0 -1
- package/dist/BackupsView-DYTAD6aW.js +0 -253
- package/dist/BackupsView-DYTAD6aW.js.map +0 -1
- package/dist/BranchesView-D6Sz1a5f.js.map +0 -1
- package/dist/CronJobsView-7hjgSYId.js.map +0 -1
- package/dist/JSEditor-qiuwmcvk.js.map +0 -1
- package/dist/LogsExplorer-Xq8K4oo6.js.map +0 -1
- package/dist/RLSEditor-Djh43lBE.js.map +0 -1
- package/dist/SQLEditor-TBw_K6CW.js.map +0 -1
- package/dist/SchemaVisualizer-DtDzIUNy.js.map +0 -1
- package/dist/StorageView-CMG1DOVX.js.map +0 -1
- package/dist/components/ApiKeys/permissions.d.ts +0 -66
- package/dist/load-failure-C6OMJSGC.js.map +0 -1
|
@@ -1,12 +1,187 @@
|
|
|
1
|
-
import { t as classifyLoadFailure } from "./load-failure-
|
|
2
|
-
import { ErrorView, useApiBase, useApiConfig, useSnackbarController, useStorageSource, useStorageSources } from "@rebasepro/app";
|
|
3
|
-
import React, { useCallback, useEffect, 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, TextField, Tooltip, Trash2Icon, Typography, UploadCloudIcon, VideoIcon, XIcon, cls, defaultBorderMixin, iconSize } from "@rebasepro/ui";
|
|
1
|
+
import { t as classifyLoadFailure } from "./load-failure-Bd8lFIO7.js";
|
|
2
|
+
import { ErrorView, useApiBase, useApiConfig, useSnackbarController, useStorageSource, useStorageSources, useTranslation } from "@rebasepro/app";
|
|
3
|
+
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
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { useSearchParams } from "react-router";
|
|
7
|
-
import { DEFAULT_STORAGE_SOURCE_KEY } from "@rebasepro/types";
|
|
7
|
+
import { DEFAULT_STORAGE_SOURCE_KEY, isPublicStorageKey } from "@rebasepro/types";
|
|
8
8
|
import { useDropzone } from "react-dropzone";
|
|
9
|
+
//#region src/components/StorageView/useVisibleFileMetadata.ts
|
|
10
|
+
function fileMetadataOf(config) {
|
|
11
|
+
return {
|
|
12
|
+
size: config.metadata?.size,
|
|
13
|
+
contentType: config.metadata?.contentType,
|
|
14
|
+
downloadUrl: config.url ?? void 0
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
var NO_METADATA = /* @__PURE__ */ new Map();
|
|
18
|
+
/**
|
|
19
|
+
* The metadata asked for one listing: each path once, {@link METADATA_CONCURRENCY}
|
|
20
|
+
* at a time, through the source that listed it. Cancelled when the listing is
|
|
21
|
+
* replaced, so an answer for a folder or source the view has left is dropped.
|
|
22
|
+
*/
|
|
23
|
+
var MetadataRun = class {
|
|
24
|
+
source;
|
|
25
|
+
files;
|
|
26
|
+
publish;
|
|
27
|
+
wants;
|
|
28
|
+
known;
|
|
29
|
+
requested = /* @__PURE__ */ new Set();
|
|
30
|
+
queue = [];
|
|
31
|
+
inFlight = 0;
|
|
32
|
+
cancelled = false;
|
|
33
|
+
answered = [];
|
|
34
|
+
flushQueued = false;
|
|
35
|
+
constructor(source, files, publish, wants, known) {
|
|
36
|
+
this.source = source;
|
|
37
|
+
this.files = files;
|
|
38
|
+
this.publish = publish;
|
|
39
|
+
this.wants = wants;
|
|
40
|
+
this.known = known;
|
|
41
|
+
}
|
|
42
|
+
want(path) {
|
|
43
|
+
if (this.cancelled || !this.source || !path || this.requested.has(path) || this.known.has(path)) return;
|
|
44
|
+
const file = this.files.get(path);
|
|
45
|
+
if (!file || !this.wants(file)) return;
|
|
46
|
+
this.requested.add(path);
|
|
47
|
+
this.queue.push(path);
|
|
48
|
+
this.pump();
|
|
49
|
+
}
|
|
50
|
+
cancel() {
|
|
51
|
+
this.cancelled = true;
|
|
52
|
+
this.queue = [];
|
|
53
|
+
this.answered = [];
|
|
54
|
+
}
|
|
55
|
+
pump() {
|
|
56
|
+
const source = this.source;
|
|
57
|
+
if (!source) return;
|
|
58
|
+
while (!this.cancelled && this.inFlight < 6 && this.queue.length > 0) {
|
|
59
|
+
const path = this.queue.shift();
|
|
60
|
+
if (path === void 0) break;
|
|
61
|
+
this.inFlight++;
|
|
62
|
+
source.getSignedUrl(path).then((config) => this.deliver(path, fileMetadataOf(config))).catch(() => this.deliver(path, {})).finally(() => {
|
|
63
|
+
this.inFlight--;
|
|
64
|
+
this.pump();
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/** Answers that arrive together are published as one update. */
|
|
69
|
+
deliver(path, metadata) {
|
|
70
|
+
if (this.cancelled) return;
|
|
71
|
+
this.answered.push([path, metadata]);
|
|
72
|
+
if (this.flushQueued) return;
|
|
73
|
+
this.flushQueued = true;
|
|
74
|
+
queueMicrotask(() => {
|
|
75
|
+
this.flushQueued = false;
|
|
76
|
+
if (this.cancelled || this.answered.length === 0) return;
|
|
77
|
+
const answered = this.answered;
|
|
78
|
+
this.answered = [];
|
|
79
|
+
this.publish(answered);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Metadata for the files of a listing, asked for as each comes on screen —
|
|
85
|
+
* and only for those `wants` says need it: the listing already describes most
|
|
86
|
+
* files (see `StorageReference.size`), so what is left is a file a source
|
|
87
|
+
* listed bare, and the link an image's thumbnail is drawn from.
|
|
88
|
+
*
|
|
89
|
+
* The browser used to ask for every file's metadata before it showed any of
|
|
90
|
+
* them: a folder of 1,000 files was 1,001 requests and seconds of a spinner.
|
|
91
|
+
* The listing is shown as it comes back; a file's metadata is asked for when
|
|
92
|
+
* its element — given {@link observe} as its `ref`, and its path as
|
|
93
|
+
* `data-storage-path` — scrolls into view, a few requests at a time.
|
|
94
|
+
*
|
|
95
|
+
* Kept per listing: keyed by path, and dropped when `files` or `source`
|
|
96
|
+
* changes — another folder, another source, or the same folder read again
|
|
97
|
+
* after an upload or a delete, whose files may have changed. Without an
|
|
98
|
+
* `IntersectionObserver` every file of the listing is asked for, still a few
|
|
99
|
+
* at a time and still after the listing is shown.
|
|
100
|
+
*/
|
|
101
|
+
function useVisibleFileMetadata(source, files, wants = () => true) {
|
|
102
|
+
const [store, setStore] = useState(() => ({
|
|
103
|
+
files,
|
|
104
|
+
entries: NO_METADATA
|
|
105
|
+
}));
|
|
106
|
+
const storeRef = useRef(store);
|
|
107
|
+
useLayoutEffect(() => {
|
|
108
|
+
storeRef.current = store;
|
|
109
|
+
});
|
|
110
|
+
const runRef = useRef(null);
|
|
111
|
+
const elementsRef = useRef(/* @__PURE__ */ new Set());
|
|
112
|
+
const observerRef = useRef(null);
|
|
113
|
+
const observer = useCallback(() => {
|
|
114
|
+
if (observerRef.current) return observerRef.current;
|
|
115
|
+
if (typeof IntersectionObserver !== "function") return null;
|
|
116
|
+
observerRef.current = new IntersectionObserver((entries) => {
|
|
117
|
+
for (const entry of entries) if (entry.isIntersecting && entry.target instanceof HTMLElement) runRef.current?.want(entry.target.dataset.storagePath);
|
|
118
|
+
}, { rootMargin: "200px" });
|
|
119
|
+
return observerRef.current;
|
|
120
|
+
}, []);
|
|
121
|
+
useLayoutEffect(() => {
|
|
122
|
+
const known = storeRef.current.files === files ? storeRef.current.entries : NO_METADATA;
|
|
123
|
+
const run = new MetadataRun(source, new Map(files.map((file) => [file.fullPath, file])), (answered) => setStore((previous) => ({
|
|
124
|
+
files,
|
|
125
|
+
entries: new Map([...previous.files === files ? previous.entries : NO_METADATA, ...answered])
|
|
126
|
+
})), wants, known);
|
|
127
|
+
runRef.current = run;
|
|
128
|
+
const io = observer();
|
|
129
|
+
for (const element of elementsRef.current) if (io) {
|
|
130
|
+
io.unobserve(element);
|
|
131
|
+
io.observe(element);
|
|
132
|
+
} else run.want(element.dataset.storagePath);
|
|
133
|
+
return () => run.cancel();
|
|
134
|
+
}, [
|
|
135
|
+
source,
|
|
136
|
+
files,
|
|
137
|
+
wants,
|
|
138
|
+
observer
|
|
139
|
+
]);
|
|
140
|
+
useEffect(() => () => {
|
|
141
|
+
observerRef.current?.disconnect();
|
|
142
|
+
observerRef.current = null;
|
|
143
|
+
}, []);
|
|
144
|
+
const observe = useCallback((element) => {
|
|
145
|
+
if (!element) return void 0;
|
|
146
|
+
elementsRef.current.add(element);
|
|
147
|
+
const io = observer();
|
|
148
|
+
if (io) io.observe(element);
|
|
149
|
+
else runRef.current?.want(element.dataset.storagePath);
|
|
150
|
+
return () => {
|
|
151
|
+
elementsRef.current.delete(element);
|
|
152
|
+
io?.unobserve(element);
|
|
153
|
+
};
|
|
154
|
+
}, [observer]);
|
|
155
|
+
return {
|
|
156
|
+
metadata: store.files === files ? store.entries : NO_METADATA,
|
|
157
|
+
observe
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
9
161
|
//#region src/components/StorageView/StorageView.tsx
|
|
162
|
+
function fileLinkOf(config, fullPath) {
|
|
163
|
+
if (!config.url) return null;
|
|
164
|
+
const metadata = config.metadata;
|
|
165
|
+
return {
|
|
166
|
+
url: config.url,
|
|
167
|
+
expiresInSeconds: metadata?.token && typeof metadata.tokenExpiresIn === "number" ? metadata.tokenExpiresIn : void 0,
|
|
168
|
+
isPublic: metadata ? metadata.public === true : isPublicStorageKey(fullPath),
|
|
169
|
+
size: metadata?.size,
|
|
170
|
+
contentType: metadata?.contentType
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
/** `file`, with what the link minted for it says where the listing did not. */
|
|
174
|
+
function withLinkFacts(file, link) {
|
|
175
|
+
return {
|
|
176
|
+
...file,
|
|
177
|
+
size: file.size ?? link?.size,
|
|
178
|
+
contentType: file.contentType ?? link?.contentType
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
/** A URL the browser can open from anywhere: relative ones are this page's origin's. */
|
|
182
|
+
function absoluteUrl(url) {
|
|
183
|
+
return url.startsWith("http") ? url : `${window.location.origin}${url.startsWith("/") ? "" : "/"}${url}`;
|
|
184
|
+
}
|
|
10
185
|
/**
|
|
11
186
|
* The query parameter holding the folder being browsed.
|
|
12
187
|
*
|
|
@@ -21,25 +196,53 @@ function formatFileSize(bytes) {
|
|
|
21
196
|
if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
22
197
|
return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;
|
|
23
198
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
199
|
+
var IMAGE_EXTENSIONS = [
|
|
200
|
+
"jpg",
|
|
201
|
+
"jpeg",
|
|
202
|
+
"png",
|
|
203
|
+
"gif",
|
|
204
|
+
"webp",
|
|
205
|
+
"svg"
|
|
206
|
+
];
|
|
207
|
+
var VIDEO_EXTENSIONS = [
|
|
208
|
+
"mp4",
|
|
209
|
+
"webm",
|
|
210
|
+
"ogg",
|
|
211
|
+
"mov"
|
|
212
|
+
];
|
|
213
|
+
var AUDIO_EXTENSIONS = [
|
|
214
|
+
"mp3",
|
|
215
|
+
"wav",
|
|
216
|
+
"ogg",
|
|
217
|
+
"m4a"
|
|
218
|
+
];
|
|
219
|
+
/**
|
|
220
|
+
* The icon for a file: by its stored type, or — where the listing carried
|
|
221
|
+
* none, as an S3 listing does not — by its extension.
|
|
222
|
+
*/
|
|
223
|
+
function getFileIcon(contentType, name) {
|
|
224
|
+
const ext = getExtension(name).toLowerCase();
|
|
225
|
+
if (contentType ? contentType.startsWith("image/") : IMAGE_EXTENSIONS.includes(ext)) return ImageIcon;
|
|
226
|
+
if (contentType ? contentType.startsWith("video/") : VIDEO_EXTENSIONS.includes(ext)) return VideoIcon;
|
|
227
|
+
if (contentType ? contentType.startsWith("audio/") : AUDIO_EXTENSIONS.includes(ext)) return Music2Icon;
|
|
29
228
|
return FileTextIcon;
|
|
30
229
|
}
|
|
31
230
|
function getExtension(name) {
|
|
32
231
|
const parts = name.split(".");
|
|
33
232
|
return parts.length > 1 ? parts[parts.length - 1].toUpperCase() : "";
|
|
34
233
|
}
|
|
35
|
-
|
|
234
|
+
/** Whether the grid draws `file` as a thumbnail — which needs a link to it. */
|
|
235
|
+
function isImageFile(file) {
|
|
236
|
+
return file.contentType?.startsWith("image/") === true || IMAGE_EXTENSIONS.includes(getExtension(file.name).toLowerCase());
|
|
237
|
+
}
|
|
238
|
+
function breadcrumbSegments(path, rootLabel) {
|
|
36
239
|
if (!path || path === "/") return [{
|
|
37
|
-
label:
|
|
240
|
+
label: rootLabel,
|
|
38
241
|
path: ""
|
|
39
242
|
}];
|
|
40
243
|
const parts = path.split("/").filter(Boolean);
|
|
41
244
|
const segments = [{
|
|
42
|
-
label:
|
|
245
|
+
label: rootLabel,
|
|
43
246
|
path: ""
|
|
44
247
|
}];
|
|
45
248
|
let accumulated = "";
|
|
@@ -52,7 +255,68 @@ function breadcrumbSegments(path) {
|
|
|
52
255
|
}
|
|
53
256
|
return segments;
|
|
54
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* Everything directly under `prefix`, across every page.
|
|
260
|
+
*
|
|
261
|
+
* A listing answers a page at a time — a thousand entries on the built-in
|
|
262
|
+
* controllers — and hands back a token for the next. Reading only the first
|
|
263
|
+
* showed a large folder cut short, and deleted the first page of it.
|
|
264
|
+
*/
|
|
265
|
+
async function listAllPages(source, prefix) {
|
|
266
|
+
const items = [];
|
|
267
|
+
const prefixes = [];
|
|
268
|
+
let pageToken;
|
|
269
|
+
do {
|
|
270
|
+
const page = pageToken ? await source.listObjects(prefix, { pageToken }) : await source.listObjects(prefix);
|
|
271
|
+
items.push(...page.items ?? []);
|
|
272
|
+
prefixes.push(...page.prefixes ?? []);
|
|
273
|
+
pageToken = page.nextPageToken;
|
|
274
|
+
} while (pageToken);
|
|
275
|
+
return {
|
|
276
|
+
items,
|
|
277
|
+
prefixes
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
/** How many deletes run at once: one at a time, a folder of 1,000 files took a minute. */
|
|
281
|
+
var DELETE_CONCURRENCY = 8;
|
|
282
|
+
/**
|
|
283
|
+
* `work` for each of `items`, at most `limit` at once. The first failure stops
|
|
284
|
+
* what has not started; what has started is let finish, then it is thrown.
|
|
285
|
+
*/
|
|
286
|
+
async function forEachBounded(items, limit, work) {
|
|
287
|
+
const run = { next: 0 };
|
|
288
|
+
const lane = async () => {
|
|
289
|
+
while (!run.failure && run.next < items.length) {
|
|
290
|
+
const item = items[run.next++];
|
|
291
|
+
try {
|
|
292
|
+
await work(item);
|
|
293
|
+
} catch (error) {
|
|
294
|
+
run.failure ??= { error };
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, lane));
|
|
299
|
+
if (run.failure) throw run.failure.error;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Delete a folder: every file in it, every folder below it, and the folder
|
|
303
|
+
* itself — the directory on local disk, or the zero-byte `name/` marker that
|
|
304
|
+
* "New folder" writes on S3 and GCS, which no listing shows as an entry.
|
|
305
|
+
*
|
|
306
|
+
* The files of a level go {@link DELETE_CONCURRENCY} at a time; the folders
|
|
307
|
+
* below it one after another, so no more than that are ever in flight, and a
|
|
308
|
+
* folder's own marker goes last, once everything in it has.
|
|
309
|
+
*/
|
|
310
|
+
async function deleteFolderRecursive(source, prefix) {
|
|
311
|
+
const { items, prefixes } = await listAllPages(source, prefix);
|
|
312
|
+
await forEachBounded(items, DELETE_CONCURRENCY, (item) => source.deleteObject(item.fullPath));
|
|
313
|
+
for (const sub of prefixes) await deleteFolderRecursive(source, sub.fullPath);
|
|
314
|
+
try {
|
|
315
|
+
await source.deleteObject(prefix.endsWith("/") ? prefix : `${prefix}/`);
|
|
316
|
+
} catch {}
|
|
317
|
+
}
|
|
55
318
|
function UploadDialog({ open, currentPath, onClose, onUpload }) {
|
|
319
|
+
const { t } = useTranslation();
|
|
56
320
|
const [uploading, setUploading] = useState(false);
|
|
57
321
|
const [selectedFiles, setSelectedFiles] = useState([]);
|
|
58
322
|
const [error, setError] = useState(null);
|
|
@@ -67,18 +331,20 @@ function UploadDialog({ open, currentPath, onClose, onUpload }) {
|
|
|
67
331
|
setUploading(true);
|
|
68
332
|
setError(null);
|
|
69
333
|
try {
|
|
70
|
-
await onUpload(selectedFiles)
|
|
71
|
-
|
|
72
|
-
|
|
334
|
+
if (await onUpload(selectedFiles)) {
|
|
335
|
+
setSelectedFiles([]);
|
|
336
|
+
onClose();
|
|
337
|
+
}
|
|
73
338
|
} catch (err) {
|
|
74
|
-
setError(err instanceof Error ? err.message : "
|
|
339
|
+
setError(err instanceof Error ? err.message : t("studio_storage_upload_failed"));
|
|
75
340
|
} finally {
|
|
76
341
|
setUploading(false);
|
|
77
342
|
}
|
|
78
343
|
}, [
|
|
79
344
|
selectedFiles,
|
|
80
345
|
onUpload,
|
|
81
|
-
onClose
|
|
346
|
+
onClose,
|
|
347
|
+
t
|
|
82
348
|
]);
|
|
83
349
|
const handleClose = useCallback(() => {
|
|
84
350
|
if (!uploading) {
|
|
@@ -92,13 +358,17 @@ function UploadDialog({ open, currentPath, onClose, onUpload }) {
|
|
|
92
358
|
onOpenChange: (o) => !o && handleClose(),
|
|
93
359
|
maxWidth: "md",
|
|
94
360
|
children: [
|
|
95
|
-
/* @__PURE__ */ jsxs(DialogTitle, { children: ["
|
|
361
|
+
/* @__PURE__ */ jsxs(DialogTitle, { children: [t("studio_storage_upload_dialog_title"), /* @__PURE__ */ jsxs(Typography, {
|
|
96
362
|
variant: "caption",
|
|
97
363
|
className: "text-text-secondary dark:text-text-secondary-dark mt-0.5 block",
|
|
98
|
-
children: [
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
364
|
+
children: [
|
|
365
|
+
t("studio_storage_upload_to"),
|
|
366
|
+
" ",
|
|
367
|
+
/* @__PURE__ */ jsxs("span", {
|
|
368
|
+
className: "font-mono text-primary",
|
|
369
|
+
children: ["/", currentPath || t("studio_storage_root_folder")]
|
|
370
|
+
})
|
|
371
|
+
]
|
|
102
372
|
})] }),
|
|
103
373
|
/* @__PURE__ */ jsxs(DialogContent, {
|
|
104
374
|
className: "space-y-4",
|
|
@@ -112,12 +382,12 @@ function UploadDialog({ open, currentPath, onClose, onUpload }) {
|
|
|
112
382
|
/* @__PURE__ */ jsx(UploadCloudIcon, { className: "text-surface-accent-400 mb-2 w-8 h-8" }),
|
|
113
383
|
/* @__PURE__ */ jsx(Typography, {
|
|
114
384
|
variant: "label",
|
|
115
|
-
children: "
|
|
385
|
+
children: t("studio_storage_drop_or_browse")
|
|
116
386
|
}),
|
|
117
387
|
/* @__PURE__ */ jsx(Typography, {
|
|
118
388
|
variant: "caption",
|
|
119
389
|
color: "secondary",
|
|
120
|
-
children: "
|
|
390
|
+
children: t("studio_storage_any_file_type")
|
|
121
391
|
})
|
|
122
392
|
]
|
|
123
393
|
})
|
|
@@ -129,14 +399,10 @@ function UploadDialog({ open, currentPath, onClose, onUpload }) {
|
|
|
129
399
|
}),
|
|
130
400
|
selectedFiles.length > 0 && /* @__PURE__ */ jsxs("div", {
|
|
131
401
|
className: "space-y-2",
|
|
132
|
-
children: [/* @__PURE__ */
|
|
402
|
+
children: [/* @__PURE__ */ jsx(Typography, {
|
|
133
403
|
variant: "caption",
|
|
134
404
|
color: "secondary",
|
|
135
|
-
children:
|
|
136
|
-
"Selected files (",
|
|
137
|
-
selectedFiles.length,
|
|
138
|
-
")"
|
|
139
|
-
]
|
|
405
|
+
children: t("studio_storage_selected_files", { count: selectedFiles.length })
|
|
140
406
|
}), /* @__PURE__ */ jsx("div", {
|
|
141
407
|
className: "max-h-40 overflow-auto space-y-1",
|
|
142
408
|
children: selectedFiles.map((file, index) => /* @__PURE__ */ jsxs("div", {
|
|
@@ -153,6 +419,7 @@ function UploadDialog({ open, currentPath, onClose, onUpload }) {
|
|
|
153
419
|
children: formatFileSize(file.size)
|
|
154
420
|
})]
|
|
155
421
|
}), /* @__PURE__ */ jsx(IconButton, {
|
|
422
|
+
"aria-label": t("remove"),
|
|
156
423
|
size: "small",
|
|
157
424
|
onClick: (e) => {
|
|
158
425
|
e.stopPropagation();
|
|
@@ -170,24 +437,45 @@ function UploadDialog({ open, currentPath, onClose, onUpload }) {
|
|
|
170
437
|
variant: "text",
|
|
171
438
|
onClick: handleClose,
|
|
172
439
|
disabled: uploading,
|
|
173
|
-
children: "
|
|
440
|
+
children: t("studio_storage_cancel")
|
|
174
441
|
}), /* @__PURE__ */ jsx(Button, {
|
|
175
442
|
variant: "filled",
|
|
176
443
|
onClick: handleUpload,
|
|
177
444
|
disabled: selectedFiles.length === 0 || uploading,
|
|
178
445
|
startIcon: uploading ? /* @__PURE__ */ jsx(CircularProgress, { size: "smallest" }) : /* @__PURE__ */ jsx(UploadCloudIcon, { size: 14 }),
|
|
179
|
-
children: uploading ? "
|
|
446
|
+
children: uploading ? t("studio_storage_uploading") : selectedFiles.length > 0 ? t("studio_storage_upload_count", { count: selectedFiles.length }) : t("studio_storage_upload")
|
|
180
447
|
})] })
|
|
181
448
|
]
|
|
182
449
|
});
|
|
183
450
|
}
|
|
184
|
-
function FilePreviewPanel({ file, onClose, onDelete,
|
|
451
|
+
function FilePreviewPanel({ file, onClose, onDelete, link, mintLink }) {
|
|
452
|
+
const { t } = useTranslation();
|
|
453
|
+
const snackbarController = useSnackbarController();
|
|
185
454
|
file.contentType?.startsWith("image/");
|
|
186
455
|
file.contentType?.startsWith("video/");
|
|
187
456
|
file.contentType?.startsWith("audio/");
|
|
188
|
-
const FileIconComponent = getFileIcon(file.contentType);
|
|
457
|
+
const FileIconComponent = getFileIcon(file.contentType, file.name);
|
|
189
458
|
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
|
|
190
459
|
const [urlCopied, setUrlCopied] = useState(false);
|
|
460
|
+
const reportLinkError = (e) => {
|
|
461
|
+
snackbarController.open({
|
|
462
|
+
type: "error",
|
|
463
|
+
message: e instanceof Error ? e.message : String(e)
|
|
464
|
+
});
|
|
465
|
+
};
|
|
466
|
+
const handleDownload = () => {
|
|
467
|
+
mintLink().then((fresh) => {
|
|
468
|
+
if (fresh) window.open(fresh.url, "_blank");
|
|
469
|
+
}).catch(reportLinkError);
|
|
470
|
+
};
|
|
471
|
+
const handleCopy = () => {
|
|
472
|
+
mintLink().then(async (fresh) => {
|
|
473
|
+
if (!fresh) return;
|
|
474
|
+
await navigator.clipboard.writeText(absoluteUrl(fresh.url));
|
|
475
|
+
setUrlCopied(true);
|
|
476
|
+
setTimeout(() => setUrlCopied(false), 2e3);
|
|
477
|
+
}).catch(reportLinkError);
|
|
478
|
+
};
|
|
191
479
|
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
|
|
192
480
|
className: cls("flex flex-col h-full border-l", defaultBorderMixin, "bg-surface-card"),
|
|
193
481
|
children: [
|
|
@@ -200,17 +488,19 @@ function FilePreviewPanel({ file, onClose, onDelete, downloadUrl }) {
|
|
|
200
488
|
}), /* @__PURE__ */ jsxs("div", {
|
|
201
489
|
className: "flex items-center gap-0.5",
|
|
202
490
|
children: [
|
|
203
|
-
|
|
204
|
-
title: "
|
|
491
|
+
link && /* @__PURE__ */ jsx(Tooltip, {
|
|
492
|
+
title: t("studio_storage_download"),
|
|
205
493
|
children: /* @__PURE__ */ jsx(IconButton, {
|
|
494
|
+
"aria-label": t("studio_storage_download"),
|
|
206
495
|
size: "small",
|
|
207
|
-
onClick:
|
|
496
|
+
onClick: handleDownload,
|
|
208
497
|
children: /* @__PURE__ */ jsx(DownloadIcon, { size: iconSize.smallest })
|
|
209
498
|
})
|
|
210
499
|
}),
|
|
211
500
|
/* @__PURE__ */ jsx(Tooltip, {
|
|
212
|
-
title: "
|
|
501
|
+
title: t("studio_storage_delete"),
|
|
213
502
|
children: /* @__PURE__ */ jsx(IconButton, {
|
|
503
|
+
"aria-label": t("studio_storage_delete"),
|
|
214
504
|
size: "small",
|
|
215
505
|
onClick: () => setDeleteDialogOpen(true),
|
|
216
506
|
className: "text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20",
|
|
@@ -218,6 +508,7 @@ function FilePreviewPanel({ file, onClose, onDelete, downloadUrl }) {
|
|
|
218
508
|
})
|
|
219
509
|
}),
|
|
220
510
|
/* @__PURE__ */ jsx(IconButton, {
|
|
511
|
+
"aria-label": t("close"),
|
|
221
512
|
size: "small",
|
|
222
513
|
onClick: onClose,
|
|
223
514
|
children: /* @__PURE__ */ jsx(XIcon, { size: iconSize.smallest })
|
|
@@ -231,41 +522,24 @@ function FilePreviewPanel({ file, onClose, onDelete, downloadUrl }) {
|
|
|
231
522
|
className: cls("flex flex-col items-center justify-center min-h-[200px] p-4 bg-surface-sheet border-b", defaultBorderMixin),
|
|
232
523
|
children: (() => {
|
|
233
524
|
const ext = getExtension(file.name)?.toLowerCase() || "";
|
|
234
|
-
const isImage = file.contentType?.startsWith("image/") ||
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
"svg"
|
|
241
|
-
].includes(ext);
|
|
242
|
-
const isVideo = file.contentType?.startsWith("video/") || [
|
|
243
|
-
"mp4",
|
|
244
|
-
"webm",
|
|
245
|
-
"ogg",
|
|
246
|
-
"mov"
|
|
247
|
-
].includes(ext);
|
|
248
|
-
const isAudio = file.contentType?.startsWith("audio/") || [
|
|
249
|
-
"mp3",
|
|
250
|
-
"wav",
|
|
251
|
-
"ogg",
|
|
252
|
-
"m4a"
|
|
253
|
-
].includes(ext);
|
|
254
|
-
const downloadUrl = file.downloadUrl;
|
|
255
|
-
if (isImage && downloadUrl) return /* @__PURE__ */ jsx("img", {
|
|
256
|
-
src: downloadUrl,
|
|
525
|
+
const isImage = file.contentType?.startsWith("image/") || IMAGE_EXTENSIONS.includes(ext);
|
|
526
|
+
const isVideo = file.contentType?.startsWith("video/") || VIDEO_EXTENSIONS.includes(ext);
|
|
527
|
+
const isAudio = file.contentType?.startsWith("audio/") || AUDIO_EXTENSIONS.includes(ext);
|
|
528
|
+
const previewUrl = link?.url;
|
|
529
|
+
if (isImage && previewUrl) return /* @__PURE__ */ jsx("img", {
|
|
530
|
+
src: previewUrl,
|
|
257
531
|
alt: file.name,
|
|
258
532
|
className: "max-w-full max-h-[400px] object-contain rounded-md shadow-sm"
|
|
259
533
|
});
|
|
260
|
-
else if (isVideo &&
|
|
261
|
-
src:
|
|
534
|
+
else if (isVideo && previewUrl) return /* @__PURE__ */ jsx("video", {
|
|
535
|
+
src: previewUrl,
|
|
262
536
|
className: "max-w-full max-h-[400px] rounded-md",
|
|
263
537
|
controls: true
|
|
264
538
|
});
|
|
265
|
-
else if (isAudio &&
|
|
539
|
+
else if (isAudio && previewUrl) return /* @__PURE__ */ jsxs("div", {
|
|
266
540
|
className: "flex flex-col items-center gap-4",
|
|
267
541
|
children: [/* @__PURE__ */ jsx(Music2Icon, { className: "text-surface-accent-400 w-10 h-10" }), /* @__PURE__ */ jsx("audio", {
|
|
268
|
-
src:
|
|
542
|
+
src: previewUrl,
|
|
269
543
|
controls: true,
|
|
270
544
|
className: "w-full max-w-xs"
|
|
271
545
|
})]
|
|
@@ -275,7 +549,7 @@ function FilePreviewPanel({ file, onClose, onDelete, downloadUrl }) {
|
|
|
275
549
|
children: [/* @__PURE__ */ jsx(FileIconComponent, { className: "w-10 h-10" }), /* @__PURE__ */ jsx(Typography, {
|
|
276
550
|
variant: "caption",
|
|
277
551
|
className: "text-text-disabled dark:text-text-disabled-dark",
|
|
278
|
-
children: "
|
|
552
|
+
children: t("studio_storage_no_preview")
|
|
279
553
|
})]
|
|
280
554
|
});
|
|
281
555
|
})()
|
|
@@ -285,9 +559,10 @@ function FilePreviewPanel({ file, onClose, onDelete, downloadUrl }) {
|
|
|
285
559
|
className: "p-4 space-y-3",
|
|
286
560
|
children: [
|
|
287
561
|
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Typography, {
|
|
288
|
-
variant: "
|
|
289
|
-
|
|
290
|
-
|
|
562
|
+
variant: "label",
|
|
563
|
+
color: "secondary",
|
|
564
|
+
className: "mb-1 block",
|
|
565
|
+
children: t("studio_storage_file_info")
|
|
291
566
|
}) }),
|
|
292
567
|
/* @__PURE__ */ jsxs("div", {
|
|
293
568
|
className: "grid grid-cols-2 gap-3",
|
|
@@ -295,7 +570,7 @@ function FilePreviewPanel({ file, onClose, onDelete, downloadUrl }) {
|
|
|
295
570
|
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Typography, {
|
|
296
571
|
variant: "caption",
|
|
297
572
|
className: "text-surface-accent-500 text-[11px]",
|
|
298
|
-
children: "
|
|
573
|
+
children: t("studio_storage_name")
|
|
299
574
|
}), /* @__PURE__ */ jsx(Typography, {
|
|
300
575
|
variant: "body2",
|
|
301
576
|
className: "text-[13px] break-all",
|
|
@@ -304,16 +579,16 @@ function FilePreviewPanel({ file, onClose, onDelete, downloadUrl }) {
|
|
|
304
579
|
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Typography, {
|
|
305
580
|
variant: "caption",
|
|
306
581
|
className: "text-surface-accent-500 text-[11px]",
|
|
307
|
-
children: "
|
|
582
|
+
children: t("studio_storage_type")
|
|
308
583
|
}), /* @__PURE__ */ jsx(Typography, {
|
|
309
584
|
variant: "body2",
|
|
310
585
|
className: "text-[13px]",
|
|
311
|
-
children: file.contentType || "
|
|
586
|
+
children: file.contentType || t("studio_storage_type_unknown")
|
|
312
587
|
})] }),
|
|
313
588
|
file.size !== void 0 && /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Typography, {
|
|
314
589
|
variant: "caption",
|
|
315
590
|
className: "text-surface-accent-500 text-[11px]",
|
|
316
|
-
children: "
|
|
591
|
+
children: t("studio_storage_size")
|
|
317
592
|
}), /* @__PURE__ */ jsx(Typography, {
|
|
318
593
|
variant: "body2",
|
|
319
594
|
className: "text-[13px]",
|
|
@@ -322,7 +597,7 @@ function FilePreviewPanel({ file, onClose, onDelete, downloadUrl }) {
|
|
|
322
597
|
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Typography, {
|
|
323
598
|
variant: "caption",
|
|
324
599
|
className: "text-surface-accent-500 text-[11px]",
|
|
325
|
-
children: "
|
|
600
|
+
children: t("studio_storage_extension")
|
|
326
601
|
}), /* @__PURE__ */ jsx(Typography, {
|
|
327
602
|
variant: "body2",
|
|
328
603
|
className: "text-[13px] font-mono",
|
|
@@ -333,7 +608,7 @@ function FilePreviewPanel({ file, onClose, onDelete, downloadUrl }) {
|
|
|
333
608
|
children: [/* @__PURE__ */ jsx(Typography, {
|
|
334
609
|
variant: "caption",
|
|
335
610
|
className: "text-surface-accent-500 text-[11px]",
|
|
336
|
-
children: "
|
|
611
|
+
children: t("studio_storage_path")
|
|
337
612
|
}), /* @__PURE__ */ jsx(Typography, {
|
|
338
613
|
variant: "body2",
|
|
339
614
|
className: "text-[13px] font-mono break-all",
|
|
@@ -342,41 +617,47 @@ function FilePreviewPanel({ file, onClose, onDelete, downloadUrl }) {
|
|
|
342
617
|
})
|
|
343
618
|
]
|
|
344
619
|
}),
|
|
345
|
-
|
|
620
|
+
link && /* @__PURE__ */ jsxs("div", {
|
|
346
621
|
className: "pt-2",
|
|
347
|
-
children: [
|
|
348
|
-
|
|
349
|
-
className: "text-surface-accent-500 text-[11px] block mb-1",
|
|
350
|
-
children: "URL"
|
|
351
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
352
|
-
className: cls("flex items-center gap-2 p-2 rounded cursor-pointer transition-colors", "bg-surface-raised hover:bg-surface-raised-hover"),
|
|
353
|
-
onClick: () => {
|
|
354
|
-
const fullUrl = downloadUrl.startsWith("http") ? downloadUrl : `${window.location.origin}${downloadUrl.startsWith("/") ? "" : "/"}${downloadUrl}`;
|
|
355
|
-
navigator.clipboard.writeText(fullUrl).then(() => {
|
|
356
|
-
setUrlCopied(true);
|
|
357
|
-
setTimeout(() => setUrlCopied(false), 2e3);
|
|
358
|
-
});
|
|
359
|
-
},
|
|
360
|
-
children: [/* @__PURE__ */ jsx(Typography, {
|
|
622
|
+
children: [
|
|
623
|
+
/* @__PURE__ */ jsx(Typography, {
|
|
361
624
|
variant: "caption",
|
|
362
|
-
className: "
|
|
363
|
-
children: (
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
children: /* @__PURE__ */ jsx(
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
className: "
|
|
625
|
+
className: "text-surface-accent-500 text-[11px] block mb-1",
|
|
626
|
+
children: t("studio_storage_url")
|
|
627
|
+
}),
|
|
628
|
+
/* @__PURE__ */ jsxs("div", {
|
|
629
|
+
className: cls("flex items-center gap-2 p-2 rounded cursor-pointer transition-colors", "bg-surface-raised hover:bg-surface-raised-hover"),
|
|
630
|
+
onClick: handleCopy,
|
|
631
|
+
children: [/* @__PURE__ */ jsx(Typography, {
|
|
632
|
+
variant: "caption",
|
|
633
|
+
className: "font-mono text-[11px] truncate flex-1 min-w-0 text-primary",
|
|
634
|
+
children: absoluteUrl(link.url)
|
|
635
|
+
}), /* @__PURE__ */ jsx(Tooltip, {
|
|
636
|
+
title: urlCopied ? t("studio_storage_url_copied") : t("studio_storage_copy_url"),
|
|
637
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
638
|
+
className: "shrink-0",
|
|
639
|
+
children: urlCopied ? /* @__PURE__ */ jsx(CheckIcon, {
|
|
640
|
+
size: 14,
|
|
641
|
+
className: "text-green-500"
|
|
642
|
+
}) : /* @__PURE__ */ jsx(CopyIcon, {
|
|
643
|
+
size: 14,
|
|
644
|
+
className: "text-surface-accent-400"
|
|
645
|
+
})
|
|
376
646
|
})
|
|
377
|
-
})
|
|
378
|
-
})
|
|
379
|
-
|
|
647
|
+
})]
|
|
648
|
+
}),
|
|
649
|
+
link.isPublic ? /* @__PURE__ */ jsx(Typography, {
|
|
650
|
+
variant: "caption",
|
|
651
|
+
color: "secondary",
|
|
652
|
+
className: "block mt-1 text-[11px]",
|
|
653
|
+
children: t("studio_storage_url_public")
|
|
654
|
+
}) : link.expiresInSeconds !== void 0 ? /* @__PURE__ */ jsx(Typography, {
|
|
655
|
+
variant: "caption",
|
|
656
|
+
color: "secondary",
|
|
657
|
+
className: "block mt-1 text-[11px]",
|
|
658
|
+
children: t("studio_storage_url_temporary", { minutes: Math.max(1, Math.round(link.expiresInSeconds / 60)) })
|
|
659
|
+
}) : null
|
|
660
|
+
]
|
|
380
661
|
})
|
|
381
662
|
]
|
|
382
663
|
})
|
|
@@ -387,24 +668,20 @@ function FilePreviewPanel({ file, onClose, onDelete, downloadUrl }) {
|
|
|
387
668
|
children: [
|
|
388
669
|
/* @__PURE__ */ jsx(DialogTitle, {
|
|
389
670
|
hidden: true,
|
|
390
|
-
children: "
|
|
671
|
+
children: t("studio_storage_delete_file_title")
|
|
391
672
|
}),
|
|
392
673
|
/* @__PURE__ */ jsxs(DialogContent, { children: [/* @__PURE__ */ jsx(Typography, {
|
|
393
674
|
variant: "subtitle1",
|
|
394
675
|
className: "mb-2",
|
|
395
|
-
children: "
|
|
396
|
-
}), /* @__PURE__ */
|
|
676
|
+
children: t("studio_storage_delete_file_question")
|
|
677
|
+
}), /* @__PURE__ */ jsx(Typography, {
|
|
397
678
|
className: "text-surface-accent-600 dark:text-surface-accent-400",
|
|
398
|
-
children:
|
|
399
|
-
"Are you sure you want to delete \"",
|
|
400
|
-
file.name,
|
|
401
|
-
"\"? This action cannot be undone."
|
|
402
|
-
]
|
|
679
|
+
children: t("studio_storage_delete_file_body", { name: file.name })
|
|
403
680
|
})] }),
|
|
404
681
|
/* @__PURE__ */ jsxs(DialogActions, { children: [/* @__PURE__ */ jsx(Button, {
|
|
405
682
|
variant: "text",
|
|
406
683
|
onClick: () => setDeleteDialogOpen(false),
|
|
407
|
-
children: "
|
|
684
|
+
children: t("studio_storage_cancel")
|
|
408
685
|
}), /* @__PURE__ */ jsx(Button, {
|
|
409
686
|
variant: "filled",
|
|
410
687
|
color: "error",
|
|
@@ -412,12 +689,13 @@ function FilePreviewPanel({ file, onClose, onDelete, downloadUrl }) {
|
|
|
412
689
|
setDeleteDialogOpen(false);
|
|
413
690
|
onDelete();
|
|
414
691
|
},
|
|
415
|
-
children: "
|
|
692
|
+
children: t("studio_storage_delete")
|
|
416
693
|
})] })
|
|
417
694
|
]
|
|
418
695
|
})] });
|
|
419
696
|
}
|
|
420
697
|
var StorageView = () => {
|
|
698
|
+
const { t } = useTranslation();
|
|
421
699
|
const defaultStorageSource = useStorageSource();
|
|
422
700
|
const storageSources = useStorageSources();
|
|
423
701
|
const snackbarController = useSnackbarController();
|
|
@@ -435,10 +713,26 @@ var StorageView = () => {
|
|
|
435
713
|
const [failure, setFailure] = useState(null);
|
|
436
714
|
const [folders, setFolders] = useState([]);
|
|
437
715
|
const [files, setFiles] = useState([]);
|
|
716
|
+
/** The source `files` were listed from: their metadata is read through it, whatever is selected since. */
|
|
717
|
+
const [listedFrom, setListedFrom] = useState(null);
|
|
718
|
+
const [viewMode, setViewMode] = useState("grid");
|
|
719
|
+
const { metadata, observe: observeFile } = useVisibleFileMetadata(listedFrom, files, useCallback((file) => file.size === void 0 || viewMode === "grid" && isImageFile(file), [viewMode]));
|
|
720
|
+
/** `file` with what its metadata has said so far, over what the listing said. */
|
|
721
|
+
const withMetadata = useCallback((file) => {
|
|
722
|
+
const read = metadata.get(file.fullPath);
|
|
723
|
+
if (!read) return file;
|
|
724
|
+
return {
|
|
725
|
+
...file,
|
|
726
|
+
size: read.size ?? file.size,
|
|
727
|
+
contentType: read.contentType ?? file.contentType,
|
|
728
|
+
downloadUrl: read.downloadUrl ?? file.downloadUrl
|
|
729
|
+
};
|
|
730
|
+
}, [metadata]);
|
|
438
731
|
const [selectedFile, setSelectedFile] = useState(null);
|
|
439
|
-
const [
|
|
732
|
+
const [selectedLink, setSelectedLink] = useState(null);
|
|
733
|
+
/** The latest link asked for the preview: an earlier one answering later is dropped. */
|
|
734
|
+
const linkRequestRef = useRef(0);
|
|
440
735
|
const [uploadDialogOpen, setUploadDialogOpen] = useState(false);
|
|
441
|
-
const [viewMode, setViewMode] = useState("grid");
|
|
442
736
|
const [selectedPaths, setSelectedPaths] = useState(/* @__PURE__ */ new Set());
|
|
443
737
|
const lastClickedRef = useRef(null);
|
|
444
738
|
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
|
|
@@ -453,42 +747,44 @@ var StorageView = () => {
|
|
|
453
747
|
useEffect(() => {
|
|
454
748
|
storageSourceRef.current = storageSource;
|
|
455
749
|
}, [storageSource]);
|
|
750
|
+
/**
|
|
751
|
+
* The latest listing asked for. Only its answer is shown: a listing of a
|
|
752
|
+
* large folder takes several pages, so an earlier one — of the source or
|
|
753
|
+
* folder the view has since left — can answer after a later one, and
|
|
754
|
+
* showed that source's files under the one selected, where their actions
|
|
755
|
+
* ran.
|
|
756
|
+
*/
|
|
757
|
+
const listingRequestRef = useRef(0);
|
|
456
758
|
const fetchContents = useCallback(async (path) => {
|
|
759
|
+
const request = ++listingRequestRef.current;
|
|
760
|
+
const isCurrent = () => request === listingRequestRef.current;
|
|
761
|
+
const source = storageSourceRef.current;
|
|
457
762
|
setLoading(true);
|
|
458
763
|
setFailure(null);
|
|
459
764
|
try {
|
|
460
|
-
const result = await
|
|
461
|
-
const folderItems =
|
|
765
|
+
const result = await listAllPages(source, path);
|
|
766
|
+
const folderItems = result.prefixes.map((ref) => ({
|
|
462
767
|
name: ref.name,
|
|
463
768
|
fullPath: ref.fullPath,
|
|
464
769
|
isFolder: true
|
|
465
770
|
}));
|
|
466
|
-
const fileItems =
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
isFolder: false,
|
|
473
|
-
size: downloadConfig.metadata?.size,
|
|
474
|
-
contentType: downloadConfig.metadata?.contentType,
|
|
475
|
-
downloadUrl: downloadConfig.url ?? void 0
|
|
476
|
-
};
|
|
477
|
-
} catch {
|
|
478
|
-
return {
|
|
479
|
-
name: ref.name,
|
|
480
|
-
fullPath: ref.fullPath,
|
|
481
|
-
isFolder: false
|
|
482
|
-
};
|
|
483
|
-
}
|
|
771
|
+
const fileItems = result.items.map((ref) => ({
|
|
772
|
+
name: ref.name,
|
|
773
|
+
fullPath: ref.fullPath,
|
|
774
|
+
isFolder: false,
|
|
775
|
+
size: ref.size,
|
|
776
|
+
contentType: ref.contentType
|
|
484
777
|
}));
|
|
778
|
+
if (!isCurrent()) return;
|
|
485
779
|
setFolders(folderItems);
|
|
486
780
|
setFiles(fileItems);
|
|
781
|
+
setListedFrom(source);
|
|
487
782
|
} catch (e) {
|
|
783
|
+
if (!isCurrent()) return;
|
|
488
784
|
console.error("Storage list error:", e);
|
|
489
785
|
setFailure(classifyLoadFailure(e));
|
|
490
786
|
} finally {
|
|
491
|
-
setLoading(false);
|
|
787
|
+
if (isCurrent()) setLoading(false);
|
|
492
788
|
}
|
|
493
789
|
}, []);
|
|
494
790
|
useEffect(() => {
|
|
@@ -498,9 +794,30 @@ var StorageView = () => {
|
|
|
498
794
|
fetchContents,
|
|
499
795
|
selectedSourceKey
|
|
500
796
|
]);
|
|
797
|
+
/** A link to `file`, minted now through the source being browsed — see {@link FileLink}. */
|
|
798
|
+
const mintFileLink = useCallback(async (file) => fileLinkOf(await storageSourceRef.current.getSignedUrl(file.fullPath), file.fullPath), []);
|
|
799
|
+
/** Open `file` in the preview, with a link minted for it now. */
|
|
800
|
+
const openPreview = useCallback((file) => {
|
|
801
|
+
const request = ++linkRequestRef.current;
|
|
802
|
+
setSelectedFile(file);
|
|
803
|
+
setSelectedLink(null);
|
|
804
|
+
mintFileLink(file).then((link) => {
|
|
805
|
+
if (request === linkRequestRef.current) setSelectedLink(link);
|
|
806
|
+
}).catch(() => {
|
|
807
|
+
if (request === linkRequestRef.current) setSelectedLink(null);
|
|
808
|
+
});
|
|
809
|
+
}, [mintFileLink]);
|
|
810
|
+
/** A fresh link to the previewed file, for a download or a copy. It replaces the one shown. */
|
|
811
|
+
const refreshPreviewLink = useCallback(async () => {
|
|
812
|
+
if (!selectedFile) return null;
|
|
813
|
+
const request = ++linkRequestRef.current;
|
|
814
|
+
const link = await mintFileLink(selectedFile);
|
|
815
|
+
if (request === linkRequestRef.current) setSelectedLink(link);
|
|
816
|
+
return link;
|
|
817
|
+
}, [selectedFile, mintFileLink]);
|
|
501
818
|
const clearSelection = useCallback(() => {
|
|
502
819
|
setSelectedFile(null);
|
|
503
|
-
|
|
820
|
+
setSelectedLink(null);
|
|
504
821
|
setSelectedPaths(/* @__PURE__ */ new Set());
|
|
505
822
|
lastClickedRef.current = null;
|
|
506
823
|
}, []);
|
|
@@ -548,41 +865,64 @@ var StorageView = () => {
|
|
|
548
865
|
} else {
|
|
549
866
|
setSelectedPaths(/* @__PURE__ */ new Set([path]));
|
|
550
867
|
lastClickedRef.current = path;
|
|
551
|
-
if (!item.isFolder)
|
|
552
|
-
|
|
553
|
-
if (item.downloadUrl) setSelectedDownloadUrl(item.downloadUrl);
|
|
554
|
-
else storageSourceRef.current.getSignedUrl(item.fullPath).then((config) => setSelectedDownloadUrl(config.url)).catch(() => setSelectedDownloadUrl(null));
|
|
555
|
-
} else {
|
|
868
|
+
if (!item.isFolder) openPreview(item);
|
|
869
|
+
else {
|
|
556
870
|
setSelectedFile(null);
|
|
557
|
-
|
|
871
|
+
setSelectedLink(null);
|
|
558
872
|
}
|
|
559
873
|
}
|
|
560
|
-
}, [allItems]);
|
|
874
|
+
}, [allItems, openPreview]);
|
|
561
875
|
const handleItemDoubleClick = useCallback((item) => {
|
|
562
876
|
if (item.isFolder) handleNavigate(item.fullPath);
|
|
563
|
-
else
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
877
|
+
else openPreview(item);
|
|
878
|
+
}, [handleNavigate, openPreview]);
|
|
879
|
+
/**
|
|
880
|
+
* Files an upload would write over, waiting for the person to say whether
|
|
881
|
+
* it should. `answer` settles the upload that asked.
|
|
882
|
+
*/
|
|
883
|
+
const [replacePrompt, setReplacePrompt] = useState(null);
|
|
884
|
+
/**
|
|
885
|
+
* Whether `uploadFiles` may go ahead: at once when none of them has the
|
|
886
|
+
* name of a file in the folder, and otherwise once the person says to
|
|
887
|
+
* replace those. An upload is a put, and a put over an existing key
|
|
888
|
+
* replaces the file without a trace.
|
|
889
|
+
*/
|
|
890
|
+
const mayReplace = useCallback((uploadFiles) => {
|
|
891
|
+
const listed = new Set(files.map((file) => file.name));
|
|
892
|
+
const names = [...new Set(uploadFiles.map((file) => file.name))].filter((name) => listed.has(name));
|
|
893
|
+
if (names.length === 0) return Promise.resolve(true);
|
|
894
|
+
return new Promise((resolve) => setReplacePrompt({
|
|
895
|
+
names,
|
|
896
|
+
answer: (replace) => {
|
|
897
|
+
setReplacePrompt(null);
|
|
898
|
+
resolve(replace);
|
|
899
|
+
}
|
|
900
|
+
}));
|
|
901
|
+
}, [files]);
|
|
569
902
|
const handleUpload = useCallback(async (uploadFiles) => {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
file
|
|
574
|
-
|
|
575
|
-
|
|
903
|
+
if (!await mayReplace(uploadFiles)) return false;
|
|
904
|
+
try {
|
|
905
|
+
for (const file of uploadFiles) {
|
|
906
|
+
const key = currentPath ? `${currentPath}/${file.name}` : file.name;
|
|
907
|
+
await storageSourceRef.current.putObject({
|
|
908
|
+
file,
|
|
909
|
+
key
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
} finally {
|
|
913
|
+
await fetchContents(currentPath);
|
|
576
914
|
}
|
|
577
915
|
snackbarController.open({
|
|
578
916
|
type: "success",
|
|
579
|
-
message:
|
|
917
|
+
message: t("studio_storage_files_uploaded", { count: uploadFiles.length })
|
|
580
918
|
});
|
|
581
|
-
|
|
919
|
+
return true;
|
|
582
920
|
}, [
|
|
583
921
|
currentPath,
|
|
584
922
|
snackbarController,
|
|
585
|
-
fetchContents
|
|
923
|
+
fetchContents,
|
|
924
|
+
mayReplace,
|
|
925
|
+
t
|
|
586
926
|
]);
|
|
587
927
|
const handleCreateFolder = useCallback(async () => {
|
|
588
928
|
if (!newFolderName.trim() || !apiConfig?.apiUrl) return;
|
|
@@ -590,14 +930,14 @@ var StorageView = () => {
|
|
|
590
930
|
if (name.includes("/") || name.includes("\\")) {
|
|
591
931
|
snackbarController.open({
|
|
592
932
|
type: "error",
|
|
593
|
-
message: "
|
|
933
|
+
message: t("studio_storage_folder_name_has_slash")
|
|
594
934
|
});
|
|
595
935
|
return;
|
|
596
936
|
}
|
|
597
937
|
if (folders.find((f) => f.name === name)) {
|
|
598
938
|
snackbarController.open({
|
|
599
939
|
type: "error",
|
|
600
|
-
message:
|
|
940
|
+
message: t("studio_storage_folder_exists", { name })
|
|
601
941
|
});
|
|
602
942
|
return;
|
|
603
943
|
}
|
|
@@ -617,12 +957,12 @@ var StorageView = () => {
|
|
|
617
957
|
})
|
|
618
958
|
});
|
|
619
959
|
if (!response.ok) {
|
|
620
|
-
const err = await response.json().catch(() => ({ error: "
|
|
621
|
-
throw new Error(err.error || "
|
|
960
|
+
const err = await response.json().catch(() => ({ error: t("studio_storage_create_folder_failed") }));
|
|
961
|
+
throw new Error(err.error || t("studio_storage_create_folder_failed"));
|
|
622
962
|
}
|
|
623
963
|
snackbarController.open({
|
|
624
964
|
type: "success",
|
|
625
|
-
message:
|
|
965
|
+
message: t("studio_storage_folder_created", { name })
|
|
626
966
|
});
|
|
627
967
|
setNewFolderDialogOpen(false);
|
|
628
968
|
setNewFolderName("");
|
|
@@ -643,95 +983,104 @@ var StorageView = () => {
|
|
|
643
983
|
snackbarController,
|
|
644
984
|
fetchContents,
|
|
645
985
|
folders,
|
|
646
|
-
selectedSourceKey
|
|
986
|
+
selectedSourceKey,
|
|
987
|
+
t
|
|
647
988
|
]);
|
|
648
989
|
const { getRootProps: getDropRootProps, getInputProps: getDropInputProps, isDragActive } = useDropzone({
|
|
649
990
|
onDrop: useCallback(async (droppedFiles) => {
|
|
650
991
|
if (droppedFiles.length === 0) return;
|
|
651
992
|
try {
|
|
652
|
-
|
|
653
|
-
const key = currentPath ? `${currentPath}/${file.name}` : file.name;
|
|
654
|
-
await storageSourceRef.current.putObject({
|
|
655
|
-
file,
|
|
656
|
-
key
|
|
657
|
-
});
|
|
658
|
-
}
|
|
659
|
-
snackbarController.open({
|
|
660
|
-
type: "success",
|
|
661
|
-
message: `${droppedFiles.length} file${droppedFiles.length > 1 ? "s" : ""} uploaded successfully`
|
|
662
|
-
});
|
|
663
|
-
await fetchContents(currentPath);
|
|
993
|
+
await handleUpload(droppedFiles);
|
|
664
994
|
} catch (e) {
|
|
665
995
|
snackbarController.open({
|
|
666
996
|
type: "error",
|
|
667
997
|
message: e instanceof Error ? e.message : String(e)
|
|
668
998
|
});
|
|
669
999
|
}
|
|
670
|
-
}, [
|
|
671
|
-
currentPath,
|
|
672
|
-
snackbarController,
|
|
673
|
-
fetchContents
|
|
674
|
-
]),
|
|
1000
|
+
}, [handleUpload, snackbarController]),
|
|
675
1001
|
noClick: true,
|
|
676
1002
|
noKeyboard: true,
|
|
677
1003
|
noDragEventsBubbling: true
|
|
678
1004
|
});
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
1005
|
+
/**
|
|
1006
|
+
* Delete files and folders from the source being browsed, then read back
|
|
1007
|
+
* the folder they were listed in and return the ones still there.
|
|
1008
|
+
*
|
|
1009
|
+
* Nothing is reported deleted on the strength of the requests alone: a
|
|
1010
|
+
* delete can answer success and leave the object behind — a directory that
|
|
1011
|
+
* is not empty yet, a folder marker, a hook — and the folder listing is
|
|
1012
|
+
* what the user sees next. One source for the whole operation, taken when
|
|
1013
|
+
* it starts.
|
|
1014
|
+
*/
|
|
1015
|
+
const deleteItems = useCallback(async (items, folder) => {
|
|
1016
|
+
const source = storageSourceRef.current;
|
|
1017
|
+
await forEachBounded(items.filter((item) => !item.isFolder), DELETE_CONCURRENCY, (item) => source.deleteObject(item.fullPath));
|
|
1018
|
+
for (const item of items) if (item.isFolder) await deleteFolderRecursive(source, item.fullPath);
|
|
1019
|
+
const listed = await listAllPages(source, folder);
|
|
1020
|
+
const stillListed = new Set([...listed.items, ...listed.prefixes].map((ref) => ref.fullPath));
|
|
1021
|
+
return items.filter((item) => stillListed.has(item.fullPath));
|
|
686
1022
|
}, []);
|
|
1023
|
+
/** What a delete left behind, said as the error it is rather than a success. */
|
|
1024
|
+
const reportStillThere = useCallback((remaining) => {
|
|
1025
|
+
snackbarController.open({
|
|
1026
|
+
type: "error",
|
|
1027
|
+
message: t("studio_storage_delete_incomplete", {
|
|
1028
|
+
count: remaining.length,
|
|
1029
|
+
names: remaining.map((item) => item.name).join(", ")
|
|
1030
|
+
})
|
|
1031
|
+
});
|
|
1032
|
+
}, [snackbarController, t]);
|
|
687
1033
|
const handleDeleteFile = useCallback(async (file) => {
|
|
688
1034
|
try {
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
snackbarController.open({
|
|
1035
|
+
const remaining = await deleteItems([file], currentPath);
|
|
1036
|
+
if (remaining.length > 0) reportStillThere(remaining);
|
|
1037
|
+
else snackbarController.open({
|
|
692
1038
|
type: "success",
|
|
693
|
-
message:
|
|
1039
|
+
message: t("studio_storage_file_deleted", { name: file.name })
|
|
694
1040
|
});
|
|
695
1041
|
setSelectedFile(null);
|
|
696
|
-
|
|
1042
|
+
setSelectedLink(null);
|
|
697
1043
|
setSelectedPaths((prev) => {
|
|
698
1044
|
const next = new Set(prev);
|
|
699
1045
|
next.delete(file.fullPath);
|
|
700
1046
|
return next;
|
|
701
1047
|
});
|
|
702
|
-
fetchContents(currentPath);
|
|
703
1048
|
} catch (e) {
|
|
704
1049
|
snackbarController.open({
|
|
705
1050
|
type: "error",
|
|
706
1051
|
message: e instanceof Error ? e.message : String(e)
|
|
707
1052
|
});
|
|
1053
|
+
} finally {
|
|
1054
|
+
fetchContents(currentPath);
|
|
708
1055
|
}
|
|
709
1056
|
}, [
|
|
710
1057
|
currentPath,
|
|
711
1058
|
snackbarController,
|
|
712
1059
|
fetchContents,
|
|
713
|
-
|
|
1060
|
+
deleteItems,
|
|
1061
|
+
reportStillThere,
|
|
1062
|
+
t
|
|
714
1063
|
]);
|
|
715
1064
|
const handleBulkDelete = useCallback(async () => {
|
|
716
1065
|
setDeleting(true);
|
|
717
1066
|
try {
|
|
718
1067
|
const items = allItems.filter((i) => selectedPaths.has(i.fullPath));
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
snackbarController.open({
|
|
1068
|
+
const remaining = await deleteItems(items, currentPath);
|
|
1069
|
+
if (remaining.length > 0) reportStillThere(remaining);
|
|
1070
|
+
else snackbarController.open({
|
|
722
1071
|
type: "success",
|
|
723
|
-
message:
|
|
1072
|
+
message: t("studio_storage_items_deleted", { count: items.length })
|
|
724
1073
|
});
|
|
725
1074
|
setSelectedPaths(/* @__PURE__ */ new Set());
|
|
726
1075
|
setSelectedFile(null);
|
|
727
|
-
|
|
728
|
-
await fetchContents(currentPath);
|
|
1076
|
+
setSelectedLink(null);
|
|
729
1077
|
} catch (e) {
|
|
730
1078
|
snackbarController.open({
|
|
731
1079
|
type: "error",
|
|
732
1080
|
message: e instanceof Error ? e.message : String(e)
|
|
733
1081
|
});
|
|
734
1082
|
} finally {
|
|
1083
|
+
await fetchContents(currentPath);
|
|
735
1084
|
setDeleting(false);
|
|
736
1085
|
setDeleteDialogOpen(false);
|
|
737
1086
|
setDeleteDialogTarget(null);
|
|
@@ -742,34 +1091,36 @@ var StorageView = () => {
|
|
|
742
1091
|
currentPath,
|
|
743
1092
|
snackbarController,
|
|
744
1093
|
fetchContents,
|
|
745
|
-
|
|
1094
|
+
deleteItems,
|
|
1095
|
+
reportStillThere,
|
|
1096
|
+
t
|
|
746
1097
|
]);
|
|
747
1098
|
const handleConfirmDeleteItem = useCallback(async () => {
|
|
748
1099
|
if (!deleteDialogTarget || deleteDialogTarget === "selection") return;
|
|
749
1100
|
setDeleting(true);
|
|
750
1101
|
try {
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
snackbarController.open({
|
|
1102
|
+
const remaining = await deleteItems([deleteDialogTarget], currentPath);
|
|
1103
|
+
if (remaining.length > 0) reportStillThere(remaining);
|
|
1104
|
+
else snackbarController.open({
|
|
754
1105
|
type: "success",
|
|
755
|
-
message: deleteDialogTarget.isFolder ?
|
|
1106
|
+
message: deleteDialogTarget.isFolder ? t("studio_storage_folder_deleted", { name: deleteDialogTarget.name }) : t("studio_storage_file_deleted", { name: deleteDialogTarget.name })
|
|
756
1107
|
});
|
|
757
1108
|
if (!deleteDialogTarget.isFolder && selectedFile?.fullPath === deleteDialogTarget.fullPath) {
|
|
758
1109
|
setSelectedFile(null);
|
|
759
|
-
|
|
1110
|
+
setSelectedLink(null);
|
|
760
1111
|
}
|
|
761
1112
|
setSelectedPaths((prev) => {
|
|
762
1113
|
const next = new Set(prev);
|
|
763
1114
|
next.delete(deleteDialogTarget.fullPath);
|
|
764
1115
|
return next;
|
|
765
1116
|
});
|
|
766
|
-
await fetchContents(currentPath);
|
|
767
1117
|
} catch (e) {
|
|
768
1118
|
snackbarController.open({
|
|
769
1119
|
type: "error",
|
|
770
1120
|
message: e instanceof Error ? e.message : String(e)
|
|
771
1121
|
});
|
|
772
1122
|
} finally {
|
|
1123
|
+
await fetchContents(currentPath);
|
|
773
1124
|
setDeleting(false);
|
|
774
1125
|
setDeleteDialogOpen(false);
|
|
775
1126
|
setDeleteDialogTarget(null);
|
|
@@ -780,7 +1131,9 @@ var StorageView = () => {
|
|
|
780
1131
|
currentPath,
|
|
781
1132
|
snackbarController,
|
|
782
1133
|
fetchContents,
|
|
783
|
-
|
|
1134
|
+
deleteItems,
|
|
1135
|
+
reportStillThere,
|
|
1136
|
+
t
|
|
784
1137
|
]);
|
|
785
1138
|
const handleSelectAll = useCallback(() => {
|
|
786
1139
|
if (selectedPaths.size === allItems.length) setSelectedPaths(/* @__PURE__ */ new Set());
|
|
@@ -788,7 +1141,8 @@ var StorageView = () => {
|
|
|
788
1141
|
}, [allItems, selectedPaths]);
|
|
789
1142
|
useEffect(() => {
|
|
790
1143
|
const handler = (e) => {
|
|
791
|
-
if (deleteDialogOpen || uploadDialogOpen || newFolderDialogOpen) return;
|
|
1144
|
+
if (deleteDialogOpen || uploadDialogOpen || newFolderDialogOpen || replacePrompt) return;
|
|
1145
|
+
if (isKeyHandled(e)) return;
|
|
792
1146
|
if ((e.metaKey || e.ctrlKey) && e.key === "a") {
|
|
793
1147
|
e.preventDefault();
|
|
794
1148
|
handleSelectAll();
|
|
@@ -796,7 +1150,7 @@ var StorageView = () => {
|
|
|
796
1150
|
if (e.key === "Escape") {
|
|
797
1151
|
setSelectedPaths(/* @__PURE__ */ new Set());
|
|
798
1152
|
setSelectedFile(null);
|
|
799
|
-
|
|
1153
|
+
setSelectedLink(null);
|
|
800
1154
|
}
|
|
801
1155
|
if ((e.key === "Delete" || e.key === "Backspace") && selectedPaths.size > 0 && !e.metaKey && !e.ctrlKey) {
|
|
802
1156
|
if (e.target?.tagName === "INPUT" || e.target?.tagName === "TEXTAREA") return;
|
|
@@ -812,12 +1166,13 @@ var StorageView = () => {
|
|
|
812
1166
|
selectedPaths,
|
|
813
1167
|
deleteDialogOpen,
|
|
814
1168
|
uploadDialogOpen,
|
|
815
|
-
newFolderDialogOpen
|
|
1169
|
+
newFolderDialogOpen,
|
|
1170
|
+
replacePrompt
|
|
816
1171
|
]);
|
|
817
1172
|
const handleRefresh = useCallback(() => {
|
|
818
1173
|
fetchContents(currentPath);
|
|
819
1174
|
}, [currentPath, fetchContents]);
|
|
820
|
-
const segments = breadcrumbSegments(currentPath);
|
|
1175
|
+
const segments = breadcrumbSegments(currentPath, t("studio_storage_root"));
|
|
821
1176
|
const renderContents = () => {
|
|
822
1177
|
if (loading) return /* @__PURE__ */ jsx("div", {
|
|
823
1178
|
className: "flex-grow flex items-center justify-center",
|
|
@@ -826,7 +1181,7 @@ var StorageView = () => {
|
|
|
826
1181
|
children: [/* @__PURE__ */ jsx(CircularProgress, { size: "medium" }), /* @__PURE__ */ jsx(Typography, {
|
|
827
1182
|
variant: "body2",
|
|
828
1183
|
className: "mt-4 text-text-secondary dark:text-text-secondary-dark font-mono tracking-tight animate-pulse",
|
|
829
|
-
children: "
|
|
1184
|
+
children: t("studio_storage_loading")
|
|
830
1185
|
})]
|
|
831
1186
|
})
|
|
832
1187
|
});
|
|
@@ -838,16 +1193,12 @@ var StorageView = () => {
|
|
|
838
1193
|
/* @__PURE__ */ jsx(Typography, {
|
|
839
1194
|
variant: "subtitle2",
|
|
840
1195
|
className: "block",
|
|
841
|
-
children: "
|
|
1196
|
+
children: t("studio_storage_denied_title")
|
|
842
1197
|
}),
|
|
843
|
-
/* @__PURE__ */
|
|
1198
|
+
/* @__PURE__ */ jsx(Typography, {
|
|
844
1199
|
variant: "body2",
|
|
845
1200
|
className: "text-text-secondary dark:text-text-secondary-dark block mt-2",
|
|
846
|
-
children:
|
|
847
|
-
"Nothing is wrong with the project. Its ",
|
|
848
|
-
/* @__PURE__ */ jsx("code", { children: "storageAuthorize" }),
|
|
849
|
-
" hook decides who may read which keys, and it declined this path for the signed-in account — commonly because a listing must name a prefix the rule recognises rather than the bucket root."
|
|
850
|
-
]
|
|
1201
|
+
children: t("studio_storage_denied_hint")
|
|
851
1202
|
}),
|
|
852
1203
|
/* @__PURE__ */ jsx(Typography, {
|
|
853
1204
|
variant: "caption",
|
|
@@ -860,7 +1211,7 @@ var StorageView = () => {
|
|
|
860
1211
|
if (failure) return /* @__PURE__ */ jsx("div", {
|
|
861
1212
|
className: "flex-grow flex items-center justify-center p-6 overflow-auto",
|
|
862
1213
|
children: /* @__PURE__ */ jsx(ErrorView, {
|
|
863
|
-
title: "
|
|
1214
|
+
title: t("studio_storage_read_failed"),
|
|
864
1215
|
error: failure.detail,
|
|
865
1216
|
onRetry: failure.retryable ? handleRefresh : void 0
|
|
866
1217
|
})
|
|
@@ -884,7 +1235,7 @@ var StorageView = () => {
|
|
|
884
1235
|
}),
|
|
885
1236
|
/* @__PURE__ */ jsx(Typography, {
|
|
886
1237
|
variant: "body2",
|
|
887
|
-
children: "
|
|
1238
|
+
children: t("studio_storage_empty")
|
|
888
1239
|
}),
|
|
889
1240
|
/* @__PURE__ */ jsxs("div", {
|
|
890
1241
|
className: "flex items-center gap-2 mt-3",
|
|
@@ -894,10 +1245,10 @@ var StorageView = () => {
|
|
|
894
1245
|
setNewFolderName("");
|
|
895
1246
|
setNewFolderDialogOpen(true);
|
|
896
1247
|
},
|
|
897
|
-
children: [/* @__PURE__ */ jsx(FolderPlusIcon, { size: iconSize.smallest }), "
|
|
1248
|
+
children: [/* @__PURE__ */ jsx(FolderPlusIcon, { size: iconSize.smallest }), t("studio_storage_new_folder")]
|
|
898
1249
|
}), /* @__PURE__ */ jsxs(Button, {
|
|
899
1250
|
onClick: () => setUploadDialogOpen(true),
|
|
900
|
-
children: [/* @__PURE__ */ jsx(PlusIcon, { size: iconSize.smallest }), "
|
|
1251
|
+
children: [/* @__PURE__ */ jsx(PlusIcon, { size: iconSize.smallest }), t("studio_storage_upload_files")]
|
|
901
1252
|
})]
|
|
902
1253
|
})
|
|
903
1254
|
]
|
|
@@ -905,12 +1256,12 @@ var StorageView = () => {
|
|
|
905
1256
|
});
|
|
906
1257
|
if (viewMode === "list") return /* @__PURE__ */ jsx("div", {
|
|
907
1258
|
className: "flex-grow overflow-auto",
|
|
908
|
-
children: /* @__PURE__ */ jsxs(
|
|
1259
|
+
children: /* @__PURE__ */ jsxs(Table, {
|
|
909
1260
|
className: "w-full",
|
|
910
|
-
children: [/* @__PURE__ */
|
|
911
|
-
className:
|
|
1261
|
+
children: [/* @__PURE__ */ jsxs(TableHeader, {
|
|
1262
|
+
className: "text-xs font-normal text-text-secondary dark:text-text-secondary-dark",
|
|
912
1263
|
children: [
|
|
913
|
-
/* @__PURE__ */ jsx(
|
|
1264
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
914
1265
|
className: "pl-3 pr-0 py-2 w-8",
|
|
915
1266
|
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
916
1267
|
size: "small",
|
|
@@ -919,148 +1270,155 @@ var StorageView = () => {
|
|
|
919
1270
|
onCheckedChange: handleSelectAll
|
|
920
1271
|
})
|
|
921
1272
|
}),
|
|
922
|
-
/* @__PURE__ */ jsx(
|
|
923
|
-
className: "px-2 py-2 font-
|
|
924
|
-
children: "
|
|
1273
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1274
|
+
className: "px-2 py-2 font-medium",
|
|
1275
|
+
children: t("studio_storage_name")
|
|
925
1276
|
}),
|
|
926
|
-
/* @__PURE__ */ jsx(
|
|
927
|
-
className: "px-4 py-2 font-
|
|
928
|
-
children: "
|
|
1277
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1278
|
+
className: "px-4 py-2 font-medium w-24",
|
|
1279
|
+
children: t("studio_storage_type")
|
|
929
1280
|
}),
|
|
930
|
-
/* @__PURE__ */ jsx(
|
|
931
|
-
className: "px-4 py-2 font-
|
|
932
|
-
children: "
|
|
1281
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1282
|
+
className: "px-4 py-2 font-medium w-24 text-right",
|
|
1283
|
+
children: t("studio_storage_size")
|
|
933
1284
|
}),
|
|
934
|
-
/* @__PURE__ */ jsx(
|
|
1285
|
+
/* @__PURE__ */ jsx(TableCell, { className: "px-2 py-2 w-10" })
|
|
935
1286
|
]
|
|
936
|
-
})
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
className: "
|
|
964
|
-
children:
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1287
|
+
}), /* @__PURE__ */ jsxs(TableBody, {
|
|
1288
|
+
variant: "list",
|
|
1289
|
+
children: [folders.map((folder) => {
|
|
1290
|
+
const isChecked = selectedPaths.has(folder.fullPath);
|
|
1291
|
+
return /* @__PURE__ */ jsxs(TableRow, {
|
|
1292
|
+
"data-storage-item": true,
|
|
1293
|
+
className: cls("group", isChecked && "bg-primary/5 dark:bg-primary/10"),
|
|
1294
|
+
onClick: (e) => handleItemClick(folder, e),
|
|
1295
|
+
onDoubleClick: () => handleItemDoubleClick(folder),
|
|
1296
|
+
children: [
|
|
1297
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1298
|
+
className: "pl-3 pr-0 py-2.5",
|
|
1299
|
+
onClick: (e) => e.stopPropagation(),
|
|
1300
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
1301
|
+
size: "small",
|
|
1302
|
+
checked: isChecked,
|
|
1303
|
+
onCheckedChange: () => {
|
|
1304
|
+
setSelectedPaths((prev) => {
|
|
1305
|
+
const next = new Set(prev);
|
|
1306
|
+
if (next.has(folder.fullPath)) next.delete(folder.fullPath);
|
|
1307
|
+
else next.add(folder.fullPath);
|
|
1308
|
+
return next;
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1311
|
+
})
|
|
1312
|
+
}),
|
|
1313
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1314
|
+
className: "px-2 py-2.5",
|
|
1315
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
1316
|
+
className: "flex items-center gap-2",
|
|
1317
|
+
children: [/* @__PURE__ */ jsx(FolderIcon, {
|
|
1318
|
+
size: iconSize.smallest,
|
|
1319
|
+
className: "text-amber-500 dark:text-amber-400 shrink-0"
|
|
1320
|
+
}), /* @__PURE__ */ jsx(Typography, {
|
|
1321
|
+
variant: "body2",
|
|
1322
|
+
className: "text-[13px] font-medium truncate",
|
|
1323
|
+
children: folder.name
|
|
1324
|
+
})]
|
|
1325
|
+
})
|
|
1326
|
+
}),
|
|
1327
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1328
|
+
className: "px-4 py-2.5",
|
|
1329
|
+
children: /* @__PURE__ */ jsx(Typography, {
|
|
1330
|
+
variant: "caption",
|
|
1331
|
+
className: "text-text-secondary dark:text-text-secondary-dark",
|
|
1332
|
+
children: t("studio_storage_folder")
|
|
1333
|
+
})
|
|
1334
|
+
}),
|
|
1335
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1336
|
+
className: "px-4 py-2.5 text-right",
|
|
1337
|
+
children: /* @__PURE__ */ jsx(Typography, {
|
|
1338
|
+
variant: "caption",
|
|
1339
|
+
className: "text-text-disabled dark:text-text-disabled-dark",
|
|
1340
|
+
children: "—"
|
|
1341
|
+
})
|
|
1342
|
+
}),
|
|
1343
|
+
/* @__PURE__ */ jsx(TableCell, { className: "px-2 py-2.5" })
|
|
1344
|
+
]
|
|
1345
|
+
}, folder.fullPath);
|
|
1346
|
+
}), files.map((listed) => {
|
|
1347
|
+
const file = withMetadata(listed);
|
|
1348
|
+
const FileIconComp = getFileIcon(file.contentType, file.name);
|
|
1349
|
+
const isChecked = selectedPaths.has(file.fullPath);
|
|
1350
|
+
return /* @__PURE__ */ jsxs(TableRow, {
|
|
1351
|
+
ref: observeFile,
|
|
1352
|
+
"data-storage-path": file.fullPath,
|
|
1353
|
+
"data-storage-item": true,
|
|
1354
|
+
className: cls("group", isChecked && "bg-primary/5 dark:bg-primary/10"),
|
|
1355
|
+
onClick: (e) => handleItemClick(file, e),
|
|
1356
|
+
onDoubleClick: () => handleItemDoubleClick(file),
|
|
1357
|
+
children: [
|
|
1358
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1359
|
+
className: "pl-3 pr-0 py-2.5",
|
|
1360
|
+
onClick: (e) => e.stopPropagation(),
|
|
1361
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
1362
|
+
size: "small",
|
|
1363
|
+
checked: isChecked,
|
|
1364
|
+
onCheckedChange: () => {
|
|
1365
|
+
setSelectedPaths((prev) => {
|
|
1366
|
+
const next = new Set(prev);
|
|
1367
|
+
if (next.has(file.fullPath)) next.delete(file.fullPath);
|
|
1368
|
+
else next.add(file.fullPath);
|
|
1369
|
+
return next;
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1372
|
+
})
|
|
1373
|
+
}),
|
|
1374
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1375
|
+
className: "px-2 py-2.5",
|
|
1376
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
1377
|
+
className: "flex items-center gap-2",
|
|
1378
|
+
children: [/* @__PURE__ */ jsx(FileIconComp, {
|
|
1379
|
+
size: iconSize.smallest,
|
|
1380
|
+
className: "text-surface-accent-400 shrink-0"
|
|
1381
|
+
}), /* @__PURE__ */ jsx(Typography, {
|
|
1382
|
+
variant: "body2",
|
|
1383
|
+
className: "text-[13px] truncate",
|
|
1384
|
+
children: file.name
|
|
1385
|
+
})]
|
|
1386
|
+
})
|
|
1387
|
+
}),
|
|
1388
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1389
|
+
className: "px-4 py-2.5",
|
|
1390
|
+
children: /* @__PURE__ */ jsx(Typography, {
|
|
1391
|
+
variant: "caption",
|
|
1392
|
+
className: "text-text-secondary dark:text-text-secondary-dark",
|
|
1393
|
+
children: getExtension(file.name) || file.contentType?.split("/")[1]?.toUpperCase() || "—"
|
|
1394
|
+
})
|
|
1395
|
+
}),
|
|
1396
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1397
|
+
className: "px-4 py-2.5 text-right",
|
|
1398
|
+
children: /* @__PURE__ */ jsx(Typography, {
|
|
1399
|
+
variant: "caption",
|
|
1400
|
+
className: "text-text-secondary dark:text-text-secondary-dark font-mono text-[11px]",
|
|
1401
|
+
children: file.size !== void 0 ? formatFileSize(file.size) : "—"
|
|
1402
|
+
})
|
|
1403
|
+
}),
|
|
1404
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1405
|
+
className: "px-2 py-2.5",
|
|
1406
|
+
onClick: (e) => e.stopPropagation(),
|
|
1407
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
1408
|
+
"aria-label": t("studio_storage_delete"),
|
|
1409
|
+
size: "smallest",
|
|
1410
|
+
className: "opacity-0 group-hover:opacity-100 transition-opacity",
|
|
1411
|
+
onClick: () => {
|
|
1412
|
+
setDeleteDialogTarget(file);
|
|
1413
|
+
setDeleteDialogOpen(true);
|
|
1414
|
+
},
|
|
1415
|
+
children: /* @__PURE__ */ jsx(Trash2Icon, { size: 14 })
|
|
1416
|
+
})
|
|
1059
1417
|
})
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
}
|
|
1063
|
-
})]
|
|
1418
|
+
]
|
|
1419
|
+
}, file.fullPath);
|
|
1420
|
+
})]
|
|
1421
|
+
})]
|
|
1064
1422
|
})
|
|
1065
1423
|
});
|
|
1066
1424
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -1070,7 +1428,7 @@ var StorageView = () => {
|
|
|
1070
1428
|
children: [/* @__PURE__ */ jsx(Typography, {
|
|
1071
1429
|
variant: "caption",
|
|
1072
1430
|
className: "text-[10px] uppercase tracking-wider font-semibold text-text-disabled dark:text-text-disabled-dark mb-2 block",
|
|
1073
|
-
children: "
|
|
1431
|
+
children: t("studio_storage_folders")
|
|
1074
1432
|
}), /* @__PURE__ */ jsx("div", {
|
|
1075
1433
|
className: "grid gap-3 grid-cols-[repeat(auto-fill,minmax(140px,1fr))]",
|
|
1076
1434
|
children: folders.map((folder) => {
|
|
@@ -1090,30 +1448,22 @@ var StorageView = () => {
|
|
|
1090
1448
|
}, folder.fullPath);
|
|
1091
1449
|
})
|
|
1092
1450
|
})]
|
|
1093
|
-
}), files.length > 0 && /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */
|
|
1451
|
+
}), files.length > 0 && /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Typography, {
|
|
1094
1452
|
variant: "caption",
|
|
1095
1453
|
className: "text-[10px] uppercase tracking-wider font-semibold text-text-disabled dark:text-text-disabled-dark mb-2 block",
|
|
1096
|
-
children:
|
|
1097
|
-
"Files (",
|
|
1098
|
-
files.length,
|
|
1099
|
-
")"
|
|
1100
|
-
]
|
|
1454
|
+
children: t("studio_storage_files_heading", { count: files.length })
|
|
1101
1455
|
}), /* @__PURE__ */ jsx("div", {
|
|
1102
1456
|
className: "grid gap-3 grid-cols-[repeat(auto-fill,minmax(140px,1fr))]",
|
|
1103
|
-
children: files.map((
|
|
1104
|
-
const
|
|
1105
|
-
const
|
|
1106
|
-
const isImage = file
|
|
1107
|
-
|
|
1108
|
-
"jpeg",
|
|
1109
|
-
"png",
|
|
1110
|
-
"gif",
|
|
1111
|
-
"webp",
|
|
1112
|
-
"svg"
|
|
1113
|
-
].includes(ext);
|
|
1457
|
+
children: files.map((listed) => {
|
|
1458
|
+
const file = withMetadata(listed);
|
|
1459
|
+
const FileIconComp = getFileIcon(file.contentType, file.name);
|
|
1460
|
+
const isImage = isImageFile(file);
|
|
1461
|
+
const isChecked = selectedPaths.has(file.fullPath);
|
|
1114
1462
|
return /* @__PURE__ */ jsxs("div", {
|
|
1463
|
+
ref: observeFile,
|
|
1464
|
+
"data-storage-path": file.fullPath,
|
|
1115
1465
|
"data-storage-item": true,
|
|
1116
|
-
className: cls("rounded-lg overflow-hidden cursor-pointer border", "transition-shadow duration-150", defaultBorderMixin, "hover:shadow-md",
|
|
1466
|
+
className: cls("rounded-lg overflow-hidden cursor-pointer border", "transition-shadow duration-150", defaultBorderMixin, "hover:shadow-md", isChecked && "ring-2 ring-primary"),
|
|
1117
1467
|
onClick: (e) => handleItemClick(file, e),
|
|
1118
1468
|
onDoubleClick: () => handleItemDoubleClick(file),
|
|
1119
1469
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
@@ -1159,8 +1509,9 @@ var StorageView = () => {
|
|
|
1159
1509
|
className: "flex items-center gap-1.5 flex-grow overflow-hidden px-3 py-2",
|
|
1160
1510
|
children: [
|
|
1161
1511
|
currentPath && /* @__PURE__ */ jsx(Tooltip, {
|
|
1162
|
-
title: "
|
|
1512
|
+
title: t("studio_storage_go_up"),
|
|
1163
1513
|
children: /* @__PURE__ */ jsx(IconButton, {
|
|
1514
|
+
"aria-label": t("studio_storage_go_up"),
|
|
1164
1515
|
size: "small",
|
|
1165
1516
|
onClick: handleNavigateUp,
|
|
1166
1517
|
children: /* @__PURE__ */ jsx(ArrowLeftIcon, { size: iconSize.smallest })
|
|
@@ -1184,10 +1535,10 @@ var StorageView = () => {
|
|
|
1184
1535
|
selectedPaths.size > 0 ? /* @__PURE__ */ jsxs("div", {
|
|
1185
1536
|
className: "flex items-center gap-1.5 shrink-0",
|
|
1186
1537
|
children: [
|
|
1187
|
-
/* @__PURE__ */
|
|
1538
|
+
/* @__PURE__ */ jsx(Typography, {
|
|
1188
1539
|
variant: "body2",
|
|
1189
1540
|
className: "text-[13px] font-medium whitespace-nowrap",
|
|
1190
|
-
children:
|
|
1541
|
+
children: t("studio_storage_selected_count", { count: selectedPaths.size })
|
|
1191
1542
|
}),
|
|
1192
1543
|
/* @__PURE__ */ jsxs(Button, {
|
|
1193
1544
|
size: "small",
|
|
@@ -1199,7 +1550,7 @@ var StorageView = () => {
|
|
|
1199
1550
|
children: [/* @__PURE__ */ jsx(Trash2Icon, {
|
|
1200
1551
|
size: 14,
|
|
1201
1552
|
className: "mr-1"
|
|
1202
|
-
}), "
|
|
1553
|
+
}), t("studio_storage_delete")]
|
|
1203
1554
|
}),
|
|
1204
1555
|
/* @__PURE__ */ jsxs(Button, {
|
|
1205
1556
|
size: "small",
|
|
@@ -1207,23 +1558,18 @@ var StorageView = () => {
|
|
|
1207
1558
|
onClick: () => {
|
|
1208
1559
|
setSelectedPaths(/* @__PURE__ */ new Set());
|
|
1209
1560
|
setSelectedFile(null);
|
|
1210
|
-
|
|
1561
|
+
setSelectedLink(null);
|
|
1211
1562
|
},
|
|
1212
1563
|
children: [/* @__PURE__ */ jsx(XIcon, {
|
|
1213
1564
|
size: 14,
|
|
1214
1565
|
className: "mr-1"
|
|
1215
|
-
}), "
|
|
1566
|
+
}), t("studio_storage_deselect")]
|
|
1216
1567
|
})
|
|
1217
1568
|
]
|
|
1218
1569
|
}) : !loading ? /* @__PURE__ */ jsxs(Chip, {
|
|
1219
1570
|
size: "small",
|
|
1220
1571
|
className: "shrink-0 text-[10px]",
|
|
1221
|
-
children: [
|
|
1222
|
-
files.length,
|
|
1223
|
-
" file",
|
|
1224
|
-
files.length !== 1 ? "s" : "",
|
|
1225
|
-
folders.length > 0 ? `, ${folders.length} folder${folders.length !== 1 ? "s" : ""}` : ""
|
|
1226
|
-
]
|
|
1572
|
+
children: [t("studio_storage_file_count", { count: files.length }), folders.length > 0 ? `, ${t("studio_storage_folder_count", { count: folders.length })}` : ""]
|
|
1227
1573
|
}) : null
|
|
1228
1574
|
]
|
|
1229
1575
|
}), /* @__PURE__ */ jsxs("div", {
|
|
@@ -1237,16 +1583,17 @@ var StorageView = () => {
|
|
|
1237
1583
|
if (value && value !== selectedSourceKey) handleSourceChange(value);
|
|
1238
1584
|
},
|
|
1239
1585
|
renderValue: (key) => {
|
|
1240
|
-
return storageSources.registry[key]?.label ?? (key === DEFAULT_STORAGE_SOURCE_KEY ? "
|
|
1586
|
+
return storageSources.registry[key]?.label ?? (key === DEFAULT_STORAGE_SOURCE_KEY ? t("studio_storage_default_source") : key);
|
|
1241
1587
|
},
|
|
1242
1588
|
children: sourceKeys.map((key) => /* @__PURE__ */ jsx(SelectItem, {
|
|
1243
1589
|
value: key,
|
|
1244
|
-
children: storageSources.registry[key]?.label ?? (key === DEFAULT_STORAGE_SOURCE_KEY ? "
|
|
1590
|
+
children: storageSources.registry[key]?.label ?? (key === DEFAULT_STORAGE_SOURCE_KEY ? t("studio_storage_default_source") : key)
|
|
1245
1591
|
}, key))
|
|
1246
1592
|
}),
|
|
1247
1593
|
/* @__PURE__ */ jsx(Tooltip, {
|
|
1248
|
-
title: "
|
|
1594
|
+
title: t("studio_storage_grid_view"),
|
|
1249
1595
|
children: /* @__PURE__ */ jsx(IconButton, {
|
|
1596
|
+
"aria-label": t("studio_storage_grid_view"),
|
|
1250
1597
|
size: "small",
|
|
1251
1598
|
onClick: () => setViewMode("grid"),
|
|
1252
1599
|
className: cls(viewMode === "grid" && "bg-surface-raised"),
|
|
@@ -1254,8 +1601,9 @@ var StorageView = () => {
|
|
|
1254
1601
|
})
|
|
1255
1602
|
}),
|
|
1256
1603
|
/* @__PURE__ */ jsx(Tooltip, {
|
|
1257
|
-
title: "
|
|
1604
|
+
title: t("studio_storage_list_view"),
|
|
1258
1605
|
children: /* @__PURE__ */ jsx(IconButton, {
|
|
1606
|
+
"aria-label": t("studio_storage_list_view"),
|
|
1259
1607
|
size: "small",
|
|
1260
1608
|
onClick: () => setViewMode("list"),
|
|
1261
1609
|
className: cls(viewMode === "list" && "bg-surface-raised"),
|
|
@@ -1264,8 +1612,9 @@ var StorageView = () => {
|
|
|
1264
1612
|
}),
|
|
1265
1613
|
/* @__PURE__ */ jsx("div", { className: cls("h-4 w-px mx-0.5", defaultBorderMixin, "bg-surface-raised") }),
|
|
1266
1614
|
/* @__PURE__ */ jsx(Tooltip, {
|
|
1267
|
-
title: "
|
|
1615
|
+
title: t("studio_storage_refresh"),
|
|
1268
1616
|
children: /* @__PURE__ */ jsx(IconButton, {
|
|
1617
|
+
"aria-label": t("studio_storage_refresh"),
|
|
1269
1618
|
size: "small",
|
|
1270
1619
|
onClick: handleRefresh,
|
|
1271
1620
|
disabled: loading,
|
|
@@ -1273,8 +1622,9 @@ var StorageView = () => {
|
|
|
1273
1622
|
})
|
|
1274
1623
|
}),
|
|
1275
1624
|
/* @__PURE__ */ jsx(Tooltip, {
|
|
1276
|
-
title: "
|
|
1625
|
+
title: t("studio_storage_new_folder"),
|
|
1277
1626
|
children: /* @__PURE__ */ jsx(IconButton, {
|
|
1627
|
+
"aria-label": t("studio_storage_new_folder"),
|
|
1278
1628
|
size: "small",
|
|
1279
1629
|
onClick: () => {
|
|
1280
1630
|
setNewFolderName("");
|
|
@@ -1290,7 +1640,7 @@ var StorageView = () => {
|
|
|
1290
1640
|
children: [/* @__PURE__ */ jsx(UploadCloudIcon, {
|
|
1291
1641
|
size: iconSize.smallest,
|
|
1292
1642
|
className: "mr-1"
|
|
1293
|
-
}), "
|
|
1643
|
+
}), t("studio_storage_upload")]
|
|
1294
1644
|
})
|
|
1295
1645
|
]
|
|
1296
1646
|
})]
|
|
@@ -1302,7 +1652,7 @@ var StorageView = () => {
|
|
|
1302
1652
|
if (!e.target.closest("[data-storage-item]") && selectedPaths.size > 0) {
|
|
1303
1653
|
setSelectedPaths(/* @__PURE__ */ new Set());
|
|
1304
1654
|
setSelectedFile(null);
|
|
1305
|
-
|
|
1655
|
+
setSelectedLink(null);
|
|
1306
1656
|
}
|
|
1307
1657
|
},
|
|
1308
1658
|
children: [
|
|
@@ -1317,12 +1667,16 @@ var StorageView = () => {
|
|
|
1317
1667
|
/* @__PURE__ */ jsx(Typography, {
|
|
1318
1668
|
variant: "subtitle2",
|
|
1319
1669
|
className: "text-primary font-semibold",
|
|
1320
|
-
children: "
|
|
1670
|
+
children: t("studio_storage_drop_to_upload")
|
|
1321
1671
|
}),
|
|
1322
1672
|
/* @__PURE__ */ jsxs(Typography, {
|
|
1323
1673
|
variant: "caption",
|
|
1324
1674
|
color: "secondary",
|
|
1325
|
-
children: [
|
|
1675
|
+
children: [
|
|
1676
|
+
t("studio_storage_upload_to"),
|
|
1677
|
+
" /",
|
|
1678
|
+
currentPath || t("studio_storage_root_folder")
|
|
1679
|
+
]
|
|
1326
1680
|
})
|
|
1327
1681
|
]
|
|
1328
1682
|
})
|
|
@@ -1335,36 +1689,36 @@ var StorageView = () => {
|
|
|
1335
1689
|
className: "flex items-center gap-4 text-[11px]",
|
|
1336
1690
|
children: [/* @__PURE__ */ jsx("span", {
|
|
1337
1691
|
className: "text-text-disabled dark:text-text-disabled-dark font-semibold uppercase tracking-tighter",
|
|
1338
|
-
children: "
|
|
1692
|
+
children: t("studio_storage_path")
|
|
1339
1693
|
}), /* @__PURE__ */ jsxs("span", {
|
|
1340
1694
|
className: "font-mono text-text-secondary dark:text-text-secondary-dark",
|
|
1341
1695
|
children: ["/", currentPath || ""]
|
|
1342
1696
|
})]
|
|
1343
|
-
}), selectedPaths.size > 0 ? /* @__PURE__ */
|
|
1697
|
+
}), selectedPaths.size > 0 ? /* @__PURE__ */ jsx("div", {
|
|
1344
1698
|
className: "text-[11px] text-text-secondary dark:text-text-secondary-dark",
|
|
1345
|
-
children:
|
|
1346
|
-
selectedPaths.size,
|
|
1347
|
-
" item",
|
|
1348
|
-
selectedPaths.size !== 1 ? "s" : "",
|
|
1349
|
-
" selected"
|
|
1350
|
-
]
|
|
1699
|
+
children: t("studio_storage_items_selected", { count: selectedPaths.size })
|
|
1351
1700
|
}) : selectedFile ? /* @__PURE__ */ jsxs("div", {
|
|
1352
1701
|
className: "text-[11px] text-text-secondary dark:text-text-secondary-dark",
|
|
1353
|
-
children: [
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1702
|
+
children: [
|
|
1703
|
+
t("studio_storage_selected_label"),
|
|
1704
|
+
" ",
|
|
1705
|
+
/* @__PURE__ */ jsx("span", {
|
|
1706
|
+
className: "font-mono",
|
|
1707
|
+
children: selectedFile.name
|
|
1708
|
+
})
|
|
1709
|
+
]
|
|
1357
1710
|
}) : null]
|
|
1358
1711
|
})
|
|
1359
1712
|
]
|
|
1360
1713
|
}), selectedFile && /* @__PURE__ */ jsx("div", {
|
|
1361
1714
|
className: "w-80 lg:w-96 shrink-0",
|
|
1362
1715
|
children: /* @__PURE__ */ jsx(FilePreviewPanel, {
|
|
1363
|
-
file: selectedFile,
|
|
1364
|
-
|
|
1716
|
+
file: withLinkFacts(withMetadata(selectedFile), selectedLink),
|
|
1717
|
+
link: selectedLink,
|
|
1718
|
+
mintLink: refreshPreviewLink,
|
|
1365
1719
|
onClose: () => {
|
|
1366
1720
|
setSelectedFile(null);
|
|
1367
|
-
|
|
1721
|
+
setSelectedLink(null);
|
|
1368
1722
|
},
|
|
1369
1723
|
onDelete: () => handleDeleteFile(selectedFile)
|
|
1370
1724
|
})
|
|
@@ -1376,6 +1730,39 @@ var StorageView = () => {
|
|
|
1376
1730
|
onClose: () => setUploadDialogOpen(false),
|
|
1377
1731
|
onUpload: handleUpload
|
|
1378
1732
|
}),
|
|
1733
|
+
/* @__PURE__ */ jsxs(Dialog, {
|
|
1734
|
+
open: replacePrompt !== null,
|
|
1735
|
+
onOpenChange: (open) => {
|
|
1736
|
+
if (!open) replacePrompt?.answer(false);
|
|
1737
|
+
},
|
|
1738
|
+
children: [
|
|
1739
|
+
/* @__PURE__ */ jsx(DialogTitle, {
|
|
1740
|
+
hidden: true,
|
|
1741
|
+
children: t("studio_storage_replace_title")
|
|
1742
|
+
}),
|
|
1743
|
+
/* @__PURE__ */ jsxs(DialogContent, { children: [/* @__PURE__ */ jsx(Typography, {
|
|
1744
|
+
variant: "subtitle1",
|
|
1745
|
+
className: "font-semibold mb-2",
|
|
1746
|
+
children: t("studio_storage_replace_question", { count: replacePrompt?.names.length ?? 0 })
|
|
1747
|
+
}), /* @__PURE__ */ jsx(Typography, {
|
|
1748
|
+
variant: "body2",
|
|
1749
|
+
color: "secondary",
|
|
1750
|
+
children: t("studio_storage_replace_body", {
|
|
1751
|
+
count: replacePrompt?.names.length ?? 0,
|
|
1752
|
+
names: replacePrompt?.names.join(", ") ?? ""
|
|
1753
|
+
})
|
|
1754
|
+
})] }),
|
|
1755
|
+
/* @__PURE__ */ jsxs(DialogActions, { children: [/* @__PURE__ */ jsx(Button, {
|
|
1756
|
+
variant: "text",
|
|
1757
|
+
onClick: () => replacePrompt?.answer(false),
|
|
1758
|
+
children: t("studio_storage_cancel")
|
|
1759
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
1760
|
+
variant: "filled",
|
|
1761
|
+
onClick: () => replacePrompt?.answer(true),
|
|
1762
|
+
children: t("studio_storage_replace")
|
|
1763
|
+
})] })
|
|
1764
|
+
]
|
|
1765
|
+
}),
|
|
1379
1766
|
/* @__PURE__ */ jsxs(Dialog, {
|
|
1380
1767
|
open: deleteDialogOpen,
|
|
1381
1768
|
onOpenChange: (open) => {
|
|
@@ -1387,20 +1774,16 @@ var StorageView = () => {
|
|
|
1387
1774
|
children: [
|
|
1388
1775
|
/* @__PURE__ */ jsx(DialogTitle, {
|
|
1389
1776
|
hidden: true,
|
|
1390
|
-
children: "
|
|
1777
|
+
children: t("studio_storage_delete_confirmation_title")
|
|
1391
1778
|
}),
|
|
1392
1779
|
/* @__PURE__ */ jsxs(DialogContent, { children: [/* @__PURE__ */ jsx(Typography, {
|
|
1393
1780
|
variant: "subtitle1",
|
|
1394
1781
|
className: "font-semibold mb-2",
|
|
1395
|
-
children: deleteDialogTarget === "selection" ?
|
|
1782
|
+
children: deleteDialogTarget === "selection" ? t("studio_storage_delete_items_question", { count: selectedPaths.size }) : deleteDialogTarget?.isFolder ? t("studio_storage_delete_folder_question", { name: deleteDialogTarget.name }) : deleteDialogTarget ? t("studio_storage_delete_file_question") : t("studio_storage_delete_question")
|
|
1396
1783
|
}), /* @__PURE__ */ jsx(Typography, {
|
|
1397
1784
|
variant: "body2",
|
|
1398
1785
|
color: "secondary",
|
|
1399
|
-
children: deleteDialogTarget === "selection" ? "
|
|
1400
|
-
"Are you sure you want to delete \"",
|
|
1401
|
-
deleteDialogTarget.name,
|
|
1402
|
-
"\"? This action cannot be undone."
|
|
1403
|
-
] }) : "This will permanently delete the folder and all of its contents. This action cannot be undone."
|
|
1786
|
+
children: deleteDialogTarget === "selection" ? t("studio_storage_delete_selection_body") : deleteDialogTarget && !deleteDialogTarget.isFolder ? t("studio_storage_delete_file_body", { name: deleteDialogTarget.name }) : t("studio_storage_delete_folder_body")
|
|
1404
1787
|
})] }),
|
|
1405
1788
|
/* @__PURE__ */ jsxs(DialogActions, { children: [/* @__PURE__ */ jsx(Button, {
|
|
1406
1789
|
variant: "text",
|
|
@@ -1409,7 +1792,7 @@ var StorageView = () => {
|
|
|
1409
1792
|
setDeleteDialogTarget(null);
|
|
1410
1793
|
},
|
|
1411
1794
|
disabled: deleting,
|
|
1412
|
-
children: "
|
|
1795
|
+
children: t("studio_storage_cancel")
|
|
1413
1796
|
}), /* @__PURE__ */ jsxs(LoadingButton, {
|
|
1414
1797
|
color: "error",
|
|
1415
1798
|
loading: deleting,
|
|
@@ -1417,7 +1800,7 @@ var StorageView = () => {
|
|
|
1417
1800
|
children: [/* @__PURE__ */ jsx(Trash2Icon, {
|
|
1418
1801
|
size: 14,
|
|
1419
1802
|
className: "mr-1"
|
|
1420
|
-
}), "
|
|
1803
|
+
}), t("studio_storage_delete")]
|
|
1421
1804
|
})] })
|
|
1422
1805
|
]
|
|
1423
1806
|
}),
|
|
@@ -1432,12 +1815,12 @@ var StorageView = () => {
|
|
|
1432
1815
|
children: [
|
|
1433
1816
|
/* @__PURE__ */ jsx(DialogTitle, {
|
|
1434
1817
|
hidden: true,
|
|
1435
|
-
children: "
|
|
1818
|
+
children: t("studio_storage_new_folder_title")
|
|
1436
1819
|
}),
|
|
1437
1820
|
/* @__PURE__ */ jsxs(DialogContent, { children: [/* @__PURE__ */ jsx(TextField, {
|
|
1438
1821
|
autoFocus: true,
|
|
1439
1822
|
size: "small",
|
|
1440
|
-
label: "
|
|
1823
|
+
label: t("studio_storage_folder_name"),
|
|
1441
1824
|
value: newFolderName,
|
|
1442
1825
|
onChange: (e) => setNewFolderName(e.target.value),
|
|
1443
1826
|
onKeyDown: (e) => {
|
|
@@ -1447,19 +1830,23 @@ var StorageView = () => {
|
|
|
1447
1830
|
}
|
|
1448
1831
|
},
|
|
1449
1832
|
disabled: creatingFolder,
|
|
1450
|
-
placeholder: "
|
|
1833
|
+
placeholder: t("studio_storage_folder_name_placeholder")
|
|
1451
1834
|
}), currentPath && /* @__PURE__ */ jsxs(Typography, {
|
|
1452
1835
|
variant: "caption",
|
|
1453
1836
|
color: "secondary",
|
|
1454
1837
|
className: "mt-2",
|
|
1455
|
-
children: [
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1838
|
+
children: [
|
|
1839
|
+
t("studio_storage_created_in"),
|
|
1840
|
+
" ",
|
|
1841
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1842
|
+
className: "font-mono",
|
|
1843
|
+
children: [
|
|
1844
|
+
"/",
|
|
1845
|
+
currentPath,
|
|
1846
|
+
"/"
|
|
1847
|
+
]
|
|
1848
|
+
})
|
|
1849
|
+
]
|
|
1463
1850
|
})] }),
|
|
1464
1851
|
/* @__PURE__ */ jsxs(DialogActions, { children: [/* @__PURE__ */ jsx(Button, {
|
|
1465
1852
|
variant: "text",
|
|
@@ -1468,7 +1855,7 @@ var StorageView = () => {
|
|
|
1468
1855
|
setNewFolderName("");
|
|
1469
1856
|
},
|
|
1470
1857
|
disabled: creatingFolder,
|
|
1471
|
-
children: "
|
|
1858
|
+
children: t("studio_storage_cancel")
|
|
1472
1859
|
}), /* @__PURE__ */ jsxs(LoadingButton, {
|
|
1473
1860
|
color: "primary",
|
|
1474
1861
|
loading: creatingFolder,
|
|
@@ -1477,7 +1864,7 @@ var StorageView = () => {
|
|
|
1477
1864
|
children: [/* @__PURE__ */ jsx(FolderPlusIcon, {
|
|
1478
1865
|
size: 14,
|
|
1479
1866
|
className: "mr-1"
|
|
1480
|
-
}), "
|
|
1867
|
+
}), t("studio_storage_create")]
|
|
1481
1868
|
})] })
|
|
1482
1869
|
]
|
|
1483
1870
|
})
|
|
@@ -1487,4 +1874,4 @@ var StorageView = () => {
|
|
|
1487
1874
|
//#endregion
|
|
1488
1875
|
export { StorageView };
|
|
1489
1876
|
|
|
1490
|
-
//# sourceMappingURL=StorageView-
|
|
1877
|
+
//# sourceMappingURL=StorageView-CPkDKbsX.js.map
|