@stoker-platform/web-app 0.5.111 → 0.5.113
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 +10 -2
- package/src/Form.tsx +2 -2
- package/src/loadRoutes.tsx +2 -1
- package/src/utils/getRelationFields.ts +6 -3
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
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
|
|
|
@@ -528,7 +529,13 @@ export const RecordFiles = ({ collection, record }: FilesProps) => {
|
|
|
528
529
|
return
|
|
529
530
|
}
|
|
530
531
|
if (shouldSkipPermissionsDialog()) {
|
|
531
|
-
|
|
532
|
+
if (uploadLockRef.current) return
|
|
533
|
+
uploadLockRef.current = true
|
|
534
|
+
try {
|
|
535
|
+
await uploadFiles([pendingUploadFile], getDefaultPermissions(), trimmedName)
|
|
536
|
+
} finally {
|
|
537
|
+
uploadLockRef.current = false
|
|
538
|
+
}
|
|
532
539
|
} else {
|
|
533
540
|
setShowPermissionsDialog(true)
|
|
534
541
|
}
|
|
@@ -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 ${
|
|
4627
|
-
: `Add system access for this ${
|
|
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"}
|
package/src/loadRoutes.tsx
CHANGED
|
@@ -89,7 +89,8 @@ export const loadRoutes = (): RouteObject[] => {
|
|
|
89
89
|
element: <Dashboard />,
|
|
90
90
|
errorElement: <ErrorPage />,
|
|
91
91
|
})
|
|
92
|
-
|
|
92
|
+
// eslint-disable-next-line security/detect-object-injection
|
|
93
|
+
} else if (homePage && collectionAccess("Read", permissions.collections?.[homePage])) {
|
|
93
94
|
routes[0].children.unshift({
|
|
94
95
|
index: true,
|
|
95
96
|
element: <Navigate to={`/${homePage.toLowerCase()}`} replace />,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CollectionSchema } from "@stoker-platform/types"
|
|
2
|
-
import { getFieldCustomization,
|
|
2
|
+
import { getFieldCustomization, isRelationField, tryFunction } from "@stoker-platform/utils"
|
|
3
3
|
import {
|
|
4
|
+
getAllRoleGroups,
|
|
4
5
|
getCollectionConfigModule,
|
|
5
6
|
getCollectionRefs,
|
|
6
7
|
getCurrentUserPermissions,
|
|
@@ -13,14 +14,16 @@ export const getRelationFields = (collection: CollectionSchema) => {
|
|
|
13
14
|
const permissions = getCurrentUserPermissions()
|
|
14
15
|
if (!permissions?.Role) throw new Error("PERMISSION_DENIED")
|
|
15
16
|
const customization = getCollectionConfigModule(labels.collection)
|
|
16
|
-
const collectionSchema = schema.collections[labels.collection]
|
|
17
17
|
const relationFields: string[] = []
|
|
18
18
|
for (const field of fields) {
|
|
19
19
|
const fieldCustomization = getFieldCustomization(field, customization)
|
|
20
20
|
if (!isRelationField(field)) continue
|
|
21
21
|
const queryFullRecord = tryFunction(fieldCustomization.admin?.queryFullRecord)
|
|
22
22
|
const condition = tryFunction(fieldCustomization.admin?.condition?.form, ["update"])
|
|
23
|
-
const
|
|
23
|
+
const roleGroups = getAllRoleGroups()
|
|
24
|
+
const roleGroup = Array.from(roleGroups[labels.collection]).find(
|
|
25
|
+
(roleGroup) => permissions.Role && roleGroup.roles.includes(permissions.Role),
|
|
26
|
+
)
|
|
24
27
|
if (!roleGroup) throw new Error("PERMISSION_DENIED")
|
|
25
28
|
if (!schema.collections[field.collection]) continue
|
|
26
29
|
const refs = getCollectionRefs([field.collection], roleGroup)
|