@noya-app/noya-file-explorer 0.0.39 → 0.0.41
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.mjs
CHANGED
|
@@ -3010,7 +3010,8 @@ import {
|
|
|
3010
3010
|
FileExplorerUploadButton as FileExplorerUploadButton2,
|
|
3011
3011
|
formatByteSize as formatByteSize2,
|
|
3012
3012
|
MediaThumbnail as MediaThumbnail3,
|
|
3013
|
-
useOpenConfirmationDialog as useOpenConfirmationDialog3
|
|
3013
|
+
useOpenConfirmationDialog as useOpenConfirmationDialog3,
|
|
3014
|
+
useToast
|
|
3014
3015
|
} from "@noya-app/noya-designsystem";
|
|
3015
3016
|
import {
|
|
3016
3017
|
DownloadIcon as DownloadIcon2,
|
|
@@ -3288,7 +3289,7 @@ var ResourceExplorer = memo3(
|
|
|
3288
3289
|
}, ref) {
|
|
3289
3290
|
const setMedia = useCallback5(
|
|
3290
3291
|
(...args) => {
|
|
3291
|
-
setMediaProp?.(...args);
|
|
3292
|
+
return Promise.resolve(setMediaProp?.(...args));
|
|
3292
3293
|
},
|
|
3293
3294
|
[setMediaProp]
|
|
3294
3295
|
);
|
|
@@ -3381,6 +3382,7 @@ var ResourceExplorer = memo3(
|
|
|
3381
3382
|
[expandedMap, expandable]
|
|
3382
3383
|
);
|
|
3383
3384
|
const openConfirmationDialog = useOpenConfirmationDialog3();
|
|
3385
|
+
const { showToast } = useToast();
|
|
3384
3386
|
const handleDelete = useCallback5(
|
|
3385
3387
|
async (selectedIds2) => {
|
|
3386
3388
|
const ok = await openConfirmationDialog({
|
|
@@ -3513,7 +3515,7 @@ var ResourceExplorer = memo3(
|
|
|
3513
3515
|
const newMediaMap = Object.fromEntries(
|
|
3514
3516
|
uploadedAssets.map(({ assetPath, asset }) => [assetPath, asset])
|
|
3515
3517
|
);
|
|
3516
|
-
setMedia(
|
|
3518
|
+
await setMedia(
|
|
3517
3519
|
{ name: "Add media items", timestamp: Date.now() },
|
|
3518
3520
|
{
|
|
3519
3521
|
...media,
|
|
@@ -3524,13 +3526,17 @@ var ResourceExplorer = memo3(
|
|
|
3524
3526
|
} catch (error) {
|
|
3525
3527
|
if (error instanceof Error && error.name === "AbortError") {
|
|
3526
3528
|
} else {
|
|
3529
|
+
showToast({
|
|
3530
|
+
title: "Upload failed",
|
|
3531
|
+
content: getUploadErrorMessage(error)
|
|
3532
|
+
});
|
|
3527
3533
|
console.error("Failed to upload files:", error);
|
|
3528
3534
|
}
|
|
3529
3535
|
} finally {
|
|
3530
3536
|
setIsUploading(false);
|
|
3531
3537
|
}
|
|
3532
3538
|
},
|
|
3533
|
-
[tree, setMedia, media, onAssetsUploaded, parentFileId]
|
|
3539
|
+
[tree, setMedia, media, onAssetsUploaded, parentFileId, showToast]
|
|
3534
3540
|
);
|
|
3535
3541
|
const handleDownload = useCallback5(
|
|
3536
3542
|
async (selectedItems) => {
|
|
@@ -3564,7 +3570,7 @@ var ResourceExplorer = memo3(
|
|
|
3564
3570
|
const oldFile = selectedItem;
|
|
3565
3571
|
const oldFilePath = tree.idToPathMap.get(oldFile.id);
|
|
3566
3572
|
if (!oldFilePath || oldFile.type !== "asset") return;
|
|
3567
|
-
setMedia(
|
|
3573
|
+
await setMedia(
|
|
3568
3574
|
{ name: "Replace media file", timestamp: Date.now() },
|
|
3569
3575
|
{
|
|
3570
3576
|
...media,
|
|
@@ -3577,11 +3583,15 @@ var ResourceExplorer = memo3(
|
|
|
3577
3583
|
} catch (error) {
|
|
3578
3584
|
if (error instanceof Error && error.name === "AbortError") {
|
|
3579
3585
|
} else {
|
|
3586
|
+
showToast({
|
|
3587
|
+
title: "Replace failed",
|
|
3588
|
+
content: getUploadErrorMessage(error)
|
|
3589
|
+
});
|
|
3580
3590
|
console.error("Failed to upload files:", error);
|
|
3581
3591
|
}
|
|
3582
3592
|
}
|
|
3583
3593
|
},
|
|
3584
|
-
[media, setMedia, assetManager, tree]
|
|
3594
|
+
[media, setMedia, assetManager, tree, showToast]
|
|
3585
3595
|
);
|
|
3586
3596
|
const handleRename = useCallback5(
|
|
3587
3597
|
(selectedItemId) => {
|
|
@@ -3999,6 +4009,25 @@ function getPublishStatus({
|
|
|
3999
4009
|
"Published"
|
|
4000
4010
|
);
|
|
4001
4011
|
}
|
|
4012
|
+
function getUploadErrorMessage(error) {
|
|
4013
|
+
const message = getErrorMessage(error).toLowerCase();
|
|
4014
|
+
if (message.includes("request entity too large") || message.includes("payload too large") || message.includes("entity too large") || message.includes("413")) {
|
|
4015
|
+
return "One or more files are too large to upload. Try smaller files.";
|
|
4016
|
+
}
|
|
4017
|
+
return "We couldn't upload your file. Please try again.";
|
|
4018
|
+
}
|
|
4019
|
+
function getErrorMessage(error) {
|
|
4020
|
+
if (typeof error === "string") {
|
|
4021
|
+
return error;
|
|
4022
|
+
}
|
|
4023
|
+
if (error instanceof Error) {
|
|
4024
|
+
return error.message;
|
|
4025
|
+
}
|
|
4026
|
+
if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string") {
|
|
4027
|
+
return error.message;
|
|
4028
|
+
}
|
|
4029
|
+
return "";
|
|
4030
|
+
}
|
|
4002
4031
|
export {
|
|
4003
4032
|
GitFileExplorer2 as GitFileExplorer,
|
|
4004
4033
|
MediaCollection,
|