Filter out invalid links and sublinks
This commit is contained in:
parent
75d4be94b5
commit
98c91a005d
|
@ -117,21 +117,26 @@
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
return navItems
|
return navItems
|
||||||
.filter(navitem => {
|
.filter(navItem => {
|
||||||
// Strip nav items without text
|
// Strip nav items without text
|
||||||
if (!navitem.text) {
|
if (!navItem.text) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Strip out links without URLs
|
||||||
|
if (navItem.type !== "sublinks" && !navItem.url) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter to only links allowed by the current role
|
// Filter to only links allowed by the current role
|
||||||
const role = navitem.roleId || Constants.Roles.BASIC
|
const role = navItem.roleId || Constants.Roles.BASIC
|
||||||
return userRoleHierarchy?.find(roleId => roleId === role)
|
return userRoleHierarchy?.find(roleId => roleId === role)
|
||||||
})
|
})
|
||||||
.map(navItem => {
|
.map(navItem => {
|
||||||
const enrichedNavItem = enrichNavItem(navItem)
|
const enrichedNavItem = enrichNavItem(navItem)
|
||||||
if (navItem.type === "sublinks" && navItem.subLinks?.length) {
|
if (navItem.type === "sublinks" && navItem.subLinks?.length) {
|
||||||
enrichedNavItem.subLinks = navItem.subLinks
|
enrichedNavItem.subLinks = navItem.subLinks
|
||||||
.filter(subLink => subLink.text)
|
.filter(subLink => subLink.text && subLink.url)
|
||||||
.map(enrichNavItem)
|
.map(enrichNavItem)
|
||||||
}
|
}
|
||||||
return enrichedNavItem
|
return enrichedNavItem
|
||||||
|
|
Loading…
Reference in New Issue