From da488b0c32e7e7d471a4a463b4fe345434c6da37 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Wed, 15 Jan 2025 18:16:10 +0530 Subject: [PATCH] fix: ignore subgroups without link when checking for permission (#10690) --- .../dashboard/components-next/sidebar/SidebarGroup.vue | 7 ++++++- .../routes/dashboard/helpcenter/helpcenter.routes.js | 9 +++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/javascript/dashboard/components-next/sidebar/SidebarGroup.vue b/app/javascript/dashboard/components-next/sidebar/SidebarGroup.vue index f22e003f1..36caf61fe 100644 --- a/app/javascript/dashboard/components-next/sidebar/SidebarGroup.vue +++ b/app/javascript/dashboard/components-next/sidebar/SidebarGroup.vue @@ -40,7 +40,12 @@ const hasChildren = computed( const accessibleItems = computed(() => { if (!hasChildren.value) return []; - return props.children.filter(child => isAllowed(child.to)); + return props.children.filter(child => { + // If a item has no link, it means it's just a subgroup header + // So we don't need to check for permissions here, because there's nothing to + // access here anyway + return child.to && isAllowed(child.to); + }); }); const hasAccessibleChildren = computed(() => { diff --git a/app/javascript/dashboard/routes/dashboard/helpcenter/helpcenter.routes.js b/app/javascript/dashboard/routes/dashboard/helpcenter/helpcenter.routes.js index d1c575fae..1897d90e8 100644 --- a/app/javascript/dashboard/routes/dashboard/helpcenter/helpcenter.routes.js +++ b/app/javascript/dashboard/routes/dashboard/helpcenter/helpcenter.routes.js @@ -116,6 +116,15 @@ export default { { path: getPortalRoute(), component: HelpCenterPageRouteView, + redirect: to => { + return { + name: 'portals_index', + params: { + navigationPath: 'portals_articles_index', + ...to.params, + }, + }; + }, children: [...portalRoutes], }, ],