@stoker-platform/web-app 0.5.116 → 0.5.118

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @stoker-platform/web-app
2
2
 
3
+ ## 0.5.118
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: delay navigation when closing sidebar
8
+
9
+ ## 0.5.117
10
+
11
+ ### Patch Changes
12
+
13
+ - feat: re-enable parallel file uploads
14
+
3
15
  ## 0.5.116
4
16
 
5
17
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoker-platform/web-app",
3
- "version": "0.5.116",
3
+ "version": "0.5.118",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "scripts": {
package/src/Files.tsx CHANGED
@@ -381,71 +381,65 @@ export const RecordFiles = ({ collection, record }: FilesProps) => {
381
381
 
382
382
  const uploadTask = uploadBytesResumable(storageRef, uploadFile, metadata)
383
383
 
384
- await new Promise<void>((resolve) => {
385
- uploadTask.on(
386
- "state_changed",
387
- (snapshot) => {
388
- const progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100
389
- setUploadProgress((prev) =>
390
- prev.map((item) => (item.file === uploadFile ? { ...item, progress } : item)),
391
- )
392
- },
393
- (error) => {
394
- void runHooks("postFileAddError", globalConfig, customization, {
395
- record,
396
- fullPath: filePath,
397
- filename,
398
- permissions: {
399
- read: metadata.customMetadata.read,
400
- update: metadata.customMetadata.update,
401
- delete: metadata.customMetadata.delete,
402
- },
403
- error,
404
- }).catch(() => {})
405
- setUploadProgress((prev) =>
406
- prev.map((item) =>
407
- item.file === uploadFile
408
- ? { ...item, status: "error", error: error.message }
409
- : item,
410
- ),
411
- )
412
- console.error(error.message)
413
- toast({
414
- title: "Upload failed",
415
- description: `Failed to upload ${filename}`,
416
- variant: "destructive",
417
- })
418
- resolve()
419
- },
420
- async () => {
421
- setUploadProgress((prev) =>
422
- prev.map((item) =>
423
- item.file === uploadFile
424
- ? { ...item, status: "completed", completedAt: Date.now() }
425
- : item,
426
- ),
427
- )
428
- toast({
429
- title: "Upload successful",
430
- description: `${filename} uploaded successfully`,
431
- })
432
-
433
- await runHooks("postFileAdd", globalConfig, customization, {
434
- record,
435
- fullPath: filePath,
436
- filename,
437
- permissions: {
438
- read: metadata.customMetadata.read,
439
- update: metadata.customMetadata.update,
440
- delete: metadata.customMetadata.delete,
441
- },
442
- }).catch(() => {})
443
-
444
- loadDirectory(currentPath)
445
- resolve()
446
- },
447
- )
448
- })
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
+ )
449
443
  }
450
444
 
451
445
  setShowFilenameDialog(false)
package/src/Tenant.tsx CHANGED
@@ -60,6 +60,8 @@ import { getFunctions, httpsCallable } from "firebase/functions"
60
60
  import { getApp } from "firebase/app"
61
61
  import { useTheme } from "./components/theme-provider"
62
62
 
63
+ const MOBILE_SHEET_CLOSE_MS = 320
64
+
63
65
  function Tenant() {
64
66
  const [dialogContent, setDialogContent] = useDialog()
65
67
  const location = useLocation()
@@ -293,6 +295,16 @@ function Tenant() {
293
295
  [location.pathname, schema.collections],
294
296
  )
295
297
 
298
+ const navigateFromSidebar = useCallback(
299
+ (path: string) => {
300
+ setSidebarOpen(false)
301
+ window.setTimeout(() => {
302
+ runViewTransition(() => navigate(path))
303
+ }, MOBILE_SHEET_CLOSE_MS)
304
+ },
305
+ [navigate],
306
+ )
307
+
296
308
  const [mfaDialog, setMfaDialog] = useState<null | {
297
309
  secret: string
298
310
  totpUri: string
@@ -661,7 +673,7 @@ function Tenant() {
661
673
  ? "flex items-center gap-4 px-2.5 text-foreground"
662
674
  : "flex items-center gap-4 px-2.5 text-muted-foreground hover:text-foreground"
663
675
  }
664
- onClick={() => runViewTransition(() => navigate("/"))}
676
+ onClick={() => navigateFromSidebar("/")}
665
677
  >
666
678
  <ChartBar className="h-5 w-5" />
667
679
  Dashboard
@@ -678,12 +690,9 @@ function Tenant() {
678
690
  ? cn(className, "text-foreground")
679
691
  : cn(className, "text-muted-foreground hover:text-foreground")
680
692
  }
681
- onClick={() => {
682
- setSidebarOpen(false)
683
- runViewTransition(() =>
684
- navigate(`/${group.collections[0].toLowerCase()}`),
685
- )
686
- }}
693
+ onClick={() =>
694
+ navigateFromSidebar(`/${group.collections[0].toLowerCase()}`)
695
+ }
687
696
  >
688
697
  {/* eslint-disable security/detect-object-injection */}
689
698
  {iconNames[group.collections[0]]
@@ -709,12 +718,7 @@ function Tenant() {
709
718
  "text-muted-foreground hover:text-foreground",
710
719
  )
711
720
  }
712
- onClick={() => {
713
- setSidebarOpen(false)
714
- runViewTransition(() =>
715
- navigate(`/${collection.toLowerCase()}`),
716
- )
717
- }}
721
+ onClick={() => navigateFromSidebar(`/${collection.toLowerCase()}`)}
718
722
  >
719
723
  {/* eslint-disable security/detect-object-injection */}
720
724
  {iconNames[collection]