@stoker-platform/web-app 0.5.111 → 0.5.112
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 +6 -0
- package/package.json +1 -1
- package/src/loadRoutes.tsx +1 -1
- package/src/utils/getRelationFields.ts +6 -3
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/loadRoutes.tsx
CHANGED
|
@@ -89,7 +89,7 @@ export const loadRoutes = (): RouteObject[] => {
|
|
|
89
89
|
element: <Dashboard />,
|
|
90
90
|
errorElement: <ErrorPage />,
|
|
91
91
|
})
|
|
92
|
-
} else if (homePage) {
|
|
92
|
+
} else if (homePage && collectionAccess("Read", permissions.collections?.[homePage])) {
|
|
93
93
|
routes[0].children.unshift({
|
|
94
94
|
index: true,
|
|
95
95
|
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)
|