|
|
@@ -27,14 +27,14 @@ export const canViewVerticalNavMenuLink = item => can('read', item.group)
|
|
|
// eslint-disable-next-line arrow-body-style
|
|
|
export const canViewVerticalNavMenuGroup = item => {
|
|
|
// ! This same logic is used in canViewHorizontalNavMenuGroup and canViewHorizontalNavMenuHeaderGroup. So make sure to update logic in them as well
|
|
|
- const hasAnyVisibleChild = item.children.some(i => can(i.action, i.resource))
|
|
|
+ const hasAnyVisibleChild = item.children.some(i => can('read', i.group))
|
|
|
|
|
|
// If resource and action is defined in item => Return based on children visibility (Hide group if no child is visible)
|
|
|
// Else check for ability using provided resource and action along with checking if has any visible child
|
|
|
- if (!(item.action && item.resource)) {
|
|
|
+ if (!('read' && item.group)) {
|
|
|
return hasAnyVisibleChild
|
|
|
}
|
|
|
- return can(item.action, item.resource) && hasAnyVisibleChild
|
|
|
+ return can('read', item.group) && hasAnyVisibleChild
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -49,14 +49,14 @@ export const canViewVerticalNavMenuHeader = item => can('read', item.group)
|
|
|
* Based on item's action and resource
|
|
|
* @param {Object} item navigation object item
|
|
|
*/
|
|
|
-export const canViewHorizontalNavMenuLink = item => can(item.action, item.resource)
|
|
|
+export const canViewHorizontalNavMenuLink = item => can('read', item.group)
|
|
|
|
|
|
/**
|
|
|
* Check if user can view item based on it's ability
|
|
|
* Based on item's action and resource
|
|
|
* @param {Object} item navigation object item
|
|
|
*/
|
|
|
-export const canViewHorizontalNavMenuHeaderLink = item => can(item.action, item.resource)
|
|
|
+export const canViewHorizontalNavMenuHeaderLink = item => can('read', item.group)
|
|
|
|
|
|
/**
|
|
|
* Check if user can view item based on it's ability
|
|
|
@@ -66,14 +66,14 @@ export const canViewHorizontalNavMenuHeaderLink = item => can(item.action, item.
|
|
|
// eslint-disable-next-line arrow-body-style
|
|
|
export const canViewHorizontalNavMenuGroup = item => {
|
|
|
// ? Same logic as canViewVerticalNavMenuGroup
|
|
|
- const hasAnyVisibleChild = item.children.some(i => can(i.action, i.resource))
|
|
|
+ const hasAnyVisibleChild = item.children.some(i => can(i.action, i.group))
|
|
|
|
|
|
// If resource and action is defined in item => Return based on children visibility (Hide group if no child is visible)
|
|
|
// Else check for ability using provided resource and action along with checking if has any visible child
|
|
|
- if (!(item.action && item.resource)) {
|
|
|
+ if (!('read' && item.group)) {
|
|
|
return hasAnyVisibleChild
|
|
|
}
|
|
|
- return can(item.action, item.resource) && hasAnyVisibleChild
|
|
|
+ return can('read', item.group) && hasAnyVisibleChild
|
|
|
}
|
|
|
|
|
|
// eslint-disable-next-line arrow-body-style
|
|
|
@@ -89,8 +89,8 @@ export const canViewHorizontalNavMenuHeaderGroup = item => {
|
|
|
|
|
|
// If resource and action is defined in item => Return based on children visibility (Hide group if no child is visible)
|
|
|
// Else check for ability using provided resource and action along with checking if has any visible child
|
|
|
- if (!(item.action && item.resource)) {
|
|
|
+ if (!('read' && item.group)) {
|
|
|
return hasAnyVisibleChild
|
|
|
}
|
|
|
- return can(item.action, item.resource) && hasAnyVisibleChild
|
|
|
+ return can('read', item.group) && hasAnyVisibleChild
|
|
|
}
|