@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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @stoker-platform/web-app
2
2
 
3
+ ## 0.5.112
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: fix role group issue
8
+
3
9
  ## 0.5.111
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoker-platform/web-app",
3
- "version": "0.5.111",
3
+ "version": "0.5.112",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "scripts": {
@@ -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, getRoleGroup, isRelationField, tryFunction } from "@stoker-platform/utils"
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 roleGroup = getRoleGroup(permissions.Role, collectionSchema, schema)
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)