@stoker-platform/web-app 0.5.112 → 0.5.114

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.114
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: hide file name dialog on upload
8
+
9
+ ## 0.5.113
10
+
11
+ ### Patch Changes
12
+
13
+ - feat: prevent file upload button re-click
14
+
3
15
  ## 0.5.112
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.112",
3
+ "version": "0.5.114",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "scripts": {
package/src/Files.tsx CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  StorageItem,
9
9
  UploadProgress,
10
10
  } from "@stoker-platform/types"
11
- import { useEffect, useState, useCallback } from "react"
11
+ import { useEffect, useState, useCallback, useRef } from "react"
12
12
  import { getCachedConfigValue, runHooks, sanitizeDownloadFilename, validateStorageName } from "@stoker-platform/utils"
13
13
  import {
14
14
  getCollectionConfigModule,
@@ -183,6 +183,7 @@ export const RecordFiles = ({ collection, record }: FilesProps) => {
183
183
  const { setIsRouteLoading } = useRouteLoading()
184
184
 
185
185
  const [showFilenameDialog, setShowFilenameDialog] = useState(false)
186
+ const uploadLockRef = useRef(false)
186
187
  const [pendingUploadFile, setPendingUploadFile] = useState<File | null>(null)
187
188
  const [editingFilename, setEditingFilename] = useState("")
188
189
 
@@ -519,7 +520,7 @@ export const RecordFiles = ({ collection, record }: FilesProps) => {
519
520
  [uploadFiles, shouldSkipPermissionsDialog, getDefaultPermissions],
520
521
  )
521
522
 
522
- const handleConfirmFilename = useCallback(async () => {
523
+ const handleConfirmFilename = useCallback(() => {
523
524
  if (!pendingUploadFile) return
524
525
  const trimmedName = editingFilename.trim()
525
526
  const validationError = validateStorageName(trimmedName)
@@ -528,8 +529,14 @@ export const RecordFiles = ({ collection, record }: FilesProps) => {
528
529
  return
529
530
  }
530
531
  if (shouldSkipPermissionsDialog()) {
531
- await uploadFiles([pendingUploadFile], getDefaultPermissions(), trimmedName)
532
+ if (uploadLockRef.current) return
533
+ uploadLockRef.current = true
534
+ setShowFilenameDialog(false)
535
+ uploadFiles([pendingUploadFile], getDefaultPermissions(), trimmedName).finally(() => {
536
+ uploadLockRef.current = false
537
+ })
532
538
  } else {
539
+ setShowFilenameDialog(false)
533
540
  setShowPermissionsDialog(true)
534
541
  }
535
542
  }, [pendingUploadFile, editingFilename, shouldSkipPermissionsDialog, uploadFiles, getDefaultPermissions])
@@ -1349,6 +1356,7 @@ export const RecordFiles = ({ collection, record }: FilesProps) => {
1349
1356
  className="mt-1"
1350
1357
  onKeyDown={(e) => {
1351
1358
  if (e.key === "Enter") {
1359
+ if (!editingFilename.trim()) return
1352
1360
  handleConfirmFilename()
1353
1361
  } else if (e.key === "Escape") {
1354
1362
  handleCancelFilename()
package/src/Form.tsx CHANGED
@@ -4623,8 +4623,8 @@ function RecordForm({
4623
4623
  <FormItem>
4624
4624
  <FormDescription className="pb-2">
4625
4625
  {originalRecord?.User_ID
4626
- ? `Enter a password below to change the password for this ${labels.record}`
4627
- : `Add system access for this ${labels.record} by entering a password below`}
4626
+ ? `Enter a password below to change the password for this ${recordTitle}`
4627
+ : `Add system access for this ${recordTitle} by entering a password below`}
4628
4628
  </FormDescription>
4629
4629
  <FormLabel className="text-primary">
4630
4630
  {record?.User_ID ? "New Password" : "Password"}
@@ -89,6 +89,7 @@ export const loadRoutes = (): RouteObject[] => {
89
89
  element: <Dashboard />,
90
90
  errorElement: <ErrorPage />,
91
91
  })
92
+ // eslint-disable-next-line security/detect-object-injection
92
93
  } else if (homePage && collectionAccess("Read", permissions.collections?.[homePage])) {
93
94
  routes[0].children.unshift({
94
95
  index: true,