@stoker-platform/web-app 0.5.115 → 0.5.117
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/CHANGELOG.md +12 -0
- package/package.json +1 -1
- package/src/Files.tsx +69 -73
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/Files.tsx
CHANGED
|
@@ -138,14 +138,16 @@ const FileImageThumbnail = ({ storage, fullPath, fileName, pathPrefix }: FileIma
|
|
|
138
138
|
return <File className="h-5 w-5 shrink-0 text-gray-500" aria-hidden />
|
|
139
139
|
}
|
|
140
140
|
return (
|
|
141
|
-
<
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
141
|
+
<div className="h-12 w-12 shrink-0 rounded-md flex items-center justify-center">
|
|
142
|
+
<img
|
|
143
|
+
src={url}
|
|
144
|
+
alt={`Thumbnail for ${fileName}`}
|
|
145
|
+
className="rounded-md max-h-12 max-w-12 object-contain"
|
|
146
|
+
loading="lazy"
|
|
147
|
+
decoding="async"
|
|
148
|
+
onError={() => setPhase("fallback")}
|
|
149
|
+
/>
|
|
150
|
+
</div>
|
|
149
151
|
)
|
|
150
152
|
}
|
|
151
153
|
|
|
@@ -379,71 +381,65 @@ export const RecordFiles = ({ collection, record }: FilesProps) => {
|
|
|
379
381
|
|
|
380
382
|
const uploadTask = uploadBytesResumable(storageRef, uploadFile, metadata)
|
|
381
383
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
(snapshot)
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
(
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
loadDirectory(currentPath)
|
|
443
|
-
resolve()
|
|
444
|
-
},
|
|
445
|
-
)
|
|
446
|
-
})
|
|
384
|
+
uploadTask.on(
|
|
385
|
+
"state_changed",
|
|
386
|
+
(snapshot) => {
|
|
387
|
+
const progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100
|
|
388
|
+
setUploadProgress((prev) =>
|
|
389
|
+
prev.map((item) => (item.file === uploadFile ? { ...item, progress } : item)),
|
|
390
|
+
)
|
|
391
|
+
},
|
|
392
|
+
(error) => {
|
|
393
|
+
void runHooks("postFileAddError", globalConfig, customization, {
|
|
394
|
+
record,
|
|
395
|
+
fullPath: filePath,
|
|
396
|
+
filename,
|
|
397
|
+
permissions: {
|
|
398
|
+
read: metadata.customMetadata.read,
|
|
399
|
+
update: metadata.customMetadata.update,
|
|
400
|
+
delete: metadata.customMetadata.delete,
|
|
401
|
+
},
|
|
402
|
+
error,
|
|
403
|
+
}).catch(() => {})
|
|
404
|
+
setUploadProgress((prev) =>
|
|
405
|
+
prev.map((item) =>
|
|
406
|
+
item.file === uploadFile ? { ...item, status: "error", error: error.message } : item,
|
|
407
|
+
),
|
|
408
|
+
)
|
|
409
|
+
console.error(error.message)
|
|
410
|
+
toast({
|
|
411
|
+
title: "Upload failed",
|
|
412
|
+
description: `Failed to upload ${filename}`,
|
|
413
|
+
variant: "destructive",
|
|
414
|
+
})
|
|
415
|
+
},
|
|
416
|
+
async () => {
|
|
417
|
+
setUploadProgress((prev) =>
|
|
418
|
+
prev.map((item) =>
|
|
419
|
+
item.file === uploadFile
|
|
420
|
+
? { ...item, status: "completed", completedAt: Date.now() }
|
|
421
|
+
: item,
|
|
422
|
+
),
|
|
423
|
+
)
|
|
424
|
+
toast({
|
|
425
|
+
title: "Upload successful",
|
|
426
|
+
description: `${filename} uploaded successfully`,
|
|
427
|
+
})
|
|
428
|
+
|
|
429
|
+
await runHooks("postFileAdd", globalConfig, customization, {
|
|
430
|
+
record,
|
|
431
|
+
fullPath: filePath,
|
|
432
|
+
filename,
|
|
433
|
+
permissions: {
|
|
434
|
+
read: metadata.customMetadata.read,
|
|
435
|
+
update: metadata.customMetadata.update,
|
|
436
|
+
delete: metadata.customMetadata.delete,
|
|
437
|
+
},
|
|
438
|
+
}).catch(() => {})
|
|
439
|
+
|
|
440
|
+
loadDirectory(currentPath)
|
|
441
|
+
},
|
|
442
|
+
)
|
|
447
443
|
}
|
|
448
444
|
|
|
449
445
|
setShowFilenameDialog(false)
|