@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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noya-app/noya-file-explorer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.40",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"dev": "npm run build:main -- --watch"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@noya-app/noya-designsystem": "0.1.
|
|
22
|
+
"@noya-app/noya-designsystem": "0.1.85",
|
|
23
23
|
"@noya-app/noya-icons": "0.1.19",
|
|
24
|
-
"@noya-app/noya-multiplayer-react": "0.1.
|
|
24
|
+
"@noya-app/noya-multiplayer-react": "0.1.82",
|
|
25
25
|
"@noya-app/noya-keymap": "0.1.4",
|
|
26
26
|
"@noya-app/react-utils": "0.1.30",
|
|
27
27
|
"@noya-app/noya-utils": "0.1.9",
|
package/src/ResourceExplorer.tsx
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
MediaThumbnailProps,
|
|
21
21
|
RelativeDropPosition,
|
|
22
22
|
useOpenConfirmationDialog,
|
|
23
|
+
useToast,
|
|
23
24
|
} from "@noya-app/noya-designsystem";
|
|
24
25
|
import {
|
|
25
26
|
DownloadIcon,
|
|
@@ -296,7 +297,7 @@ export const ResourceExplorer = memo(
|
|
|
296
297
|
) {
|
|
297
298
|
const setMedia = useCallback(
|
|
298
299
|
(...args: Parameters<Extract<typeof setMediaProp, Function>>) => {
|
|
299
|
-
setMediaProp?.(...args);
|
|
300
|
+
return Promise.resolve(setMediaProp?.(...args));
|
|
300
301
|
},
|
|
301
302
|
[setMediaProp]
|
|
302
303
|
);
|
|
@@ -404,6 +405,7 @@ export const ResourceExplorer = memo(
|
|
|
404
405
|
);
|
|
405
406
|
|
|
406
407
|
const openConfirmationDialog = useOpenConfirmationDialog();
|
|
408
|
+
const { showToast } = useToast();
|
|
407
409
|
|
|
408
410
|
const handleDelete = useCallback(
|
|
409
411
|
async (selectedIds: string[]) => {
|
|
@@ -557,7 +559,7 @@ export const ResourceExplorer = memo(
|
|
|
557
559
|
uploadedAssets.map(({ assetPath, asset }) => [assetPath, asset])
|
|
558
560
|
);
|
|
559
561
|
|
|
560
|
-
setMedia(
|
|
562
|
+
await setMedia(
|
|
561
563
|
{ name: "Add media items", timestamp: Date.now() },
|
|
562
564
|
{
|
|
563
565
|
...media,
|
|
@@ -570,13 +572,17 @@ export const ResourceExplorer = memo(
|
|
|
570
572
|
if (error instanceof Error && error.name === "AbortError") {
|
|
571
573
|
// Ignore user-cancelled file picker
|
|
572
574
|
} else {
|
|
575
|
+
showToast({
|
|
576
|
+
title: "Upload failed",
|
|
577
|
+
content: getUploadErrorMessage(error),
|
|
578
|
+
});
|
|
573
579
|
console.error("Failed to upload files:", error);
|
|
574
580
|
}
|
|
575
581
|
} finally {
|
|
576
582
|
setIsUploading(false);
|
|
577
583
|
}
|
|
578
584
|
},
|
|
579
|
-
[tree, setMedia, media, onAssetsUploaded, parentFileId]
|
|
585
|
+
[tree, setMedia, media, onAssetsUploaded, parentFileId, showToast]
|
|
580
586
|
);
|
|
581
587
|
|
|
582
588
|
const handleDownload = useCallback(
|
|
@@ -624,7 +630,7 @@ export const ResourceExplorer = memo(
|
|
|
624
630
|
const oldFile = selectedItem;
|
|
625
631
|
const oldFilePath = tree.idToPathMap.get(oldFile.id);
|
|
626
632
|
if (!oldFilePath || oldFile.type !== "asset") return;
|
|
627
|
-
setMedia(
|
|
633
|
+
await setMedia(
|
|
628
634
|
{ name: "Replace media file", timestamp: Date.now() },
|
|
629
635
|
{
|
|
630
636
|
...media,
|
|
@@ -638,11 +644,15 @@ export const ResourceExplorer = memo(
|
|
|
638
644
|
if (error instanceof Error && error.name === "AbortError") {
|
|
639
645
|
// Ignore user-cancelled file picker
|
|
640
646
|
} else {
|
|
647
|
+
showToast({
|
|
648
|
+
title: "Replace failed",
|
|
649
|
+
content: getUploadErrorMessage(error),
|
|
650
|
+
});
|
|
641
651
|
console.error("Failed to upload files:", error);
|
|
642
652
|
}
|
|
643
653
|
}
|
|
644
654
|
},
|
|
645
|
-
[media, setMedia, assetManager, tree]
|
|
655
|
+
[media, setMedia, assetManager, tree, showToast]
|
|
646
656
|
);
|
|
647
657
|
|
|
648
658
|
const handleRename = useCallback(
|
|
@@ -1147,3 +1157,39 @@ function getPublishStatus({
|
|
|
1147
1157
|
// but removed, it will be in the removed set
|
|
1148
1158
|
"Published";
|
|
1149
1159
|
}
|
|
1160
|
+
|
|
1161
|
+
function getUploadErrorMessage(error: unknown) {
|
|
1162
|
+
const message = getErrorMessage(error).toLowerCase();
|
|
1163
|
+
|
|
1164
|
+
if (
|
|
1165
|
+
message.includes("request entity too large") ||
|
|
1166
|
+
message.includes("payload too large") ||
|
|
1167
|
+
message.includes("entity too large") ||
|
|
1168
|
+
message.includes("413")
|
|
1169
|
+
) {
|
|
1170
|
+
return "One or more files are too large to upload. Try smaller files.";
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
return "We couldn't upload your file. Please try again.";
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
function getErrorMessage(error: unknown) {
|
|
1177
|
+
if (typeof error === "string") {
|
|
1178
|
+
return error;
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
if (error instanceof Error) {
|
|
1182
|
+
return error.message;
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
if (
|
|
1186
|
+
typeof error === "object" &&
|
|
1187
|
+
error !== null &&
|
|
1188
|
+
"message" in error &&
|
|
1189
|
+
typeof error.message === "string"
|
|
1190
|
+
) {
|
|
1191
|
+
return error.message;
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
return "";
|
|
1195
|
+
}
|