@noya-app/noya-file-explorer 0.0.38 → 0.0.40
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/.turbo/turbo-build.log +11 -11
- package/CHANGELOG.md +16 -0
- package/dist/index.css +18 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +33 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/ResourceExplorer.tsx +51 -5
package/dist/index.js
CHANGED
|
@@ -3219,7 +3219,7 @@ var ResourceExplorer = (0, import_react6.memo)(
|
|
|
3219
3219
|
}, ref) {
|
|
3220
3220
|
const setMedia = (0, import_react6.useCallback)(
|
|
3221
3221
|
(...args) => {
|
|
3222
|
-
setMediaProp?.(...args);
|
|
3222
|
+
return Promise.resolve(setMediaProp?.(...args));
|
|
3223
3223
|
},
|
|
3224
3224
|
[setMediaProp]
|
|
3225
3225
|
);
|
|
@@ -3312,6 +3312,7 @@ var ResourceExplorer = (0, import_react6.memo)(
|
|
|
3312
3312
|
[expandedMap, expandable]
|
|
3313
3313
|
);
|
|
3314
3314
|
const openConfirmationDialog = (0, import_noya_designsystem3.useOpenConfirmationDialog)();
|
|
3315
|
+
const { showToast } = (0, import_noya_designsystem3.useToast)();
|
|
3315
3316
|
const handleDelete = (0, import_react6.useCallback)(
|
|
3316
3317
|
async (selectedIds2) => {
|
|
3317
3318
|
const ok = await openConfirmationDialog({
|
|
@@ -3444,7 +3445,7 @@ var ResourceExplorer = (0, import_react6.memo)(
|
|
|
3444
3445
|
const newMediaMap = Object.fromEntries(
|
|
3445
3446
|
uploadedAssets.map(({ assetPath, asset }) => [assetPath, asset])
|
|
3446
3447
|
);
|
|
3447
|
-
setMedia(
|
|
3448
|
+
await setMedia(
|
|
3448
3449
|
{ name: "Add media items", timestamp: Date.now() },
|
|
3449
3450
|
{
|
|
3450
3451
|
...media,
|
|
@@ -3455,13 +3456,17 @@ var ResourceExplorer = (0, import_react6.memo)(
|
|
|
3455
3456
|
} catch (error) {
|
|
3456
3457
|
if (error instanceof Error && error.name === "AbortError") {
|
|
3457
3458
|
} else {
|
|
3459
|
+
showToast({
|
|
3460
|
+
title: "Upload failed",
|
|
3461
|
+
content: getUploadErrorMessage(error)
|
|
3462
|
+
});
|
|
3458
3463
|
console.error("Failed to upload files:", error);
|
|
3459
3464
|
}
|
|
3460
3465
|
} finally {
|
|
3461
3466
|
setIsUploading(false);
|
|
3462
3467
|
}
|
|
3463
3468
|
},
|
|
3464
|
-
[tree, setMedia, media, onAssetsUploaded, parentFileId]
|
|
3469
|
+
[tree, setMedia, media, onAssetsUploaded, parentFileId, showToast]
|
|
3465
3470
|
);
|
|
3466
3471
|
const handleDownload = (0, import_react6.useCallback)(
|
|
3467
3472
|
async (selectedItems) => {
|
|
@@ -3495,7 +3500,7 @@ var ResourceExplorer = (0, import_react6.memo)(
|
|
|
3495
3500
|
const oldFile = selectedItem;
|
|
3496
3501
|
const oldFilePath = tree.idToPathMap.get(oldFile.id);
|
|
3497
3502
|
if (!oldFilePath || oldFile.type !== "asset") return;
|
|
3498
|
-
setMedia(
|
|
3503
|
+
await setMedia(
|
|
3499
3504
|
{ name: "Replace media file", timestamp: Date.now() },
|
|
3500
3505
|
{
|
|
3501
3506
|
...media,
|
|
@@ -3508,11 +3513,15 @@ var ResourceExplorer = (0, import_react6.memo)(
|
|
|
3508
3513
|
} catch (error) {
|
|
3509
3514
|
if (error instanceof Error && error.name === "AbortError") {
|
|
3510
3515
|
} else {
|
|
3516
|
+
showToast({
|
|
3517
|
+
title: "Replace failed",
|
|
3518
|
+
content: getUploadErrorMessage(error)
|
|
3519
|
+
});
|
|
3511
3520
|
console.error("Failed to upload files:", error);
|
|
3512
3521
|
}
|
|
3513
3522
|
}
|
|
3514
3523
|
},
|
|
3515
|
-
[media, setMedia, assetManager, tree]
|
|
3524
|
+
[media, setMedia, assetManager, tree, showToast]
|
|
3516
3525
|
);
|
|
3517
3526
|
const handleRename = (0, import_react6.useCallback)(
|
|
3518
3527
|
(selectedItemId) => {
|
|
@@ -3930,6 +3939,25 @@ function getPublishStatus({
|
|
|
3930
3939
|
"Published"
|
|
3931
3940
|
);
|
|
3932
3941
|
}
|
|
3942
|
+
function getUploadErrorMessage(error) {
|
|
3943
|
+
const message = getErrorMessage(error).toLowerCase();
|
|
3944
|
+
if (message.includes("request entity too large") || message.includes("payload too large") || message.includes("entity too large") || message.includes("413")) {
|
|
3945
|
+
return "One or more files are too large to upload. Try smaller files.";
|
|
3946
|
+
}
|
|
3947
|
+
return "We couldn't upload your file. Please try again.";
|
|
3948
|
+
}
|
|
3949
|
+
function getErrorMessage(error) {
|
|
3950
|
+
if (typeof error === "string") {
|
|
3951
|
+
return error;
|
|
3952
|
+
}
|
|
3953
|
+
if (error instanceof Error) {
|
|
3954
|
+
return error.message;
|
|
3955
|
+
}
|
|
3956
|
+
if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string") {
|
|
3957
|
+
return error.message;
|
|
3958
|
+
}
|
|
3959
|
+
return "";
|
|
3960
|
+
}
|
|
3933
3961
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3934
3962
|
0 && (module.exports = {
|
|
3935
3963
|
GitFileExplorer,
|