1+ import { generatePath } from 'react-router-dom'
2+
13import {
24 Icon ,
35 ImageWithFallback ,
6+ InfrastructureManagementAppListType ,
7+ NavigationItemID ,
48 SERVER_MODE ,
59 URL_FILTER_KEYS ,
610 URLS as COMMON_URLS ,
@@ -33,28 +37,30 @@ export const getNewSelectedIndex = (prevIndex: number, type: 'up' | 'down', tota
3337 return prevIndex === totalItems - 1 ? 0 : prevIndex + 1
3438}
3539
36- const getAppManagementAdditionalNavItems = (
37- serverMode : SERVER_MODE ,
38- isSuperAdmin : boolean ,
39- ) : CommandBarGroupType [ 'items' ] => [
40+ const getAppManagementNavItemsBreakdown = ( serverMode : SERVER_MODE ) : CommandBarGroupType [ 'items' ] => [
4041 ...( serverMode === SERVER_MODE . FULL
4142 ? [
4243 {
4344 id : 'app-management-devtron-app-list' ,
4445 title : 'Devtron Applications' ,
4546 icon : 'ic-devtron-app' ,
4647 iconColor : 'none' ,
47- href : URLS . DEVTRON_APP_LIST ,
48+ href : COMMON_URLS . APPLICATION_MANAGEMENT_APP_LIST ,
4849 keywords : [ ] ,
4950 } satisfies CommandBarGroupType [ 'items' ] [ number ] ,
5051 ]
5152 : [ ] ) ,
53+ ]
54+
55+ const getInfraManagementNavItemsBreakdown = ( isSuperAdmin : boolean ) : CommandBarGroupType [ 'items' ] => [
5256 {
5357 id : 'app-management-helm-app-list' ,
5458 title : 'Helm Applications' ,
5559 icon : 'ic-helm-app' ,
5660 iconColor : 'none' ,
57- href : URLS . HELM_APP_LIST ,
61+ href : generatePath ( COMMON_URLS . INFRASTRUCTURE_MANAGEMENT_APP_LIST , {
62+ appType : InfrastructureManagementAppListType . HELM ,
63+ } ) ,
5864 keywords : [ ] ,
5965 } ,
6066 ...( window . _env_ ?. ENABLE_EXTERNAL_ARGO_CD && isSuperAdmin
@@ -64,7 +70,9 @@ const getAppManagementAdditionalNavItems = (
6470 title : 'ArgoCD Applications' ,
6571 icon : 'ic-argocd-app' ,
6672 iconColor : 'none' ,
67- href : URLS . ARGO_APP_LIST ,
73+ href : generatePath ( COMMON_URLS . INFRASTRUCTURE_MANAGEMENT_APP_LIST , {
74+ appType : InfrastructureManagementAppListType . ARGO_CD ,
75+ } ) ,
6876 keywords : [ ] ,
6977 } satisfies CommandBarGroupType [ 'items' ] [ number ] ,
7078 ]
@@ -76,18 +84,32 @@ const getAppManagementAdditionalNavItems = (
7684 title : 'FluxCD Applications' ,
7785 icon : 'ic-fluxcd-app' ,
7886 iconColor : 'none' ,
79- href : URLS . FLUX_APP_LIST ,
87+ href : generatePath ( COMMON_URLS . INFRASTRUCTURE_MANAGEMENT_APP_LIST , {
88+ appType : InfrastructureManagementAppListType . FLUX_CD ,
89+ } ) ,
8090 keywords : [ ] ,
8191 } satisfies CommandBarGroupType [ 'items' ] [ number ] ,
8292 ]
8393 : [ ] ) ,
8494]
8595
96+ const getNavItemBreakdownItems = (
97+ rootId : NavigationItemID ,
98+ serverMode : SERVER_MODE ,
99+ isSuperAdmin : boolean ,
100+ ) : CommandBarGroupType [ 'items' ] => {
101+ switch ( rootId ) {
102+ case 'application-management-devtron-applications' :
103+ return getAppManagementNavItemsBreakdown ( serverMode )
104+ case 'infrastructure-management-applications' :
105+ return getInfraManagementNavItemsBreakdown ( isSuperAdmin )
106+ default :
107+ return [ ]
108+ }
109+ }
110+
86111export const getNavigationGroups = ( serverMode : SERVER_MODE , isSuperAdmin : boolean ) : CommandBarGroupType [ ] =>
87112 NAVIGATION_LIST . map < CommandBarGroupType > ( ( group ) => {
88- const isAppManagementBlock = group . id === 'application-management'
89- const additionalItems = isAppManagementBlock ? getAppManagementAdditionalNavItems ( serverMode , isSuperAdmin ) : [ ]
90-
91113 const parsedItems = group . items . flatMap < CommandBarGroupType [ 'items' ] [ number ] > (
92114 ( { hasSubMenu, subItems, title, href, id, icon, keywords } ) => {
93115 if ( hasSubMenu && subItems ?. length ) {
@@ -102,6 +124,12 @@ export const getNavigationGroups = (serverMode: SERVER_MODE, isSuperAdmin: boole
102124 } ) )
103125 }
104126
127+ const breakdownItems = getNavItemBreakdownItems ( id , serverMode , isSuperAdmin )
128+
129+ if ( breakdownItems . length ) {
130+ return breakdownItems
131+ }
132+
105133 return {
106134 title,
107135 id,
@@ -116,7 +144,7 @@ export const getNavigationGroups = (serverMode: SERVER_MODE, isSuperAdmin: boole
116144 return {
117145 title : group . title ,
118146 id : group . id ,
119- items : [ ... additionalItems , ... parsedItems ] ,
147+ items : parsedItems ,
120148 }
121149 } )
122150
@@ -169,7 +197,7 @@ export const parseChartListToNavItems = (
169197 fallbackImage = { < Icon name = "ic-helm-app" color = { null } size = { 20 } /> }
170198 />
171199 ) ,
172- href : `${ COMMON_URLS . APPLICATION_MANAGEMENT_CHART_STORE_DISCOVER } ${ URLS . CHART } /${ chart . id } ` ,
200+ href : `${ COMMON_URLS . INFRASTRUCTURE_MANAGEMENT_CHART_STORE_DISCOVER } ${ URLS . CHART } /${ chart . id } ` ,
173201 keywords : [ ] ,
174202 } ) ) ,
175203 } ,
@@ -224,7 +252,7 @@ export const parseHelmAppListToNavItems = (
224252 fallbackImage = { < Icon name = "ic-helm-app" color = { null } size = { 20 } /> }
225253 />
226254 ) ,
227- href : `${ URLS . APPLICATION_MANAGEMENT_APP } /${ URLS . DEVTRON_CHARTS } /deployments/${ helmApp . appId } /env/${ helmApp . environmentDetail ?. environmentId } ` ,
255+ href : `${ COMMON_URLS . INFRASTRUCTURE_MANAGEMENT_APP } /${ URLS . DEVTRON_CHARTS } /deployments/${ helmApp . appId } /env/${ helmApp . environmentDetail ?. environmentId } ` ,
228256 keywords : [ ] ,
229257 } ) ) ,
230258 } ,
@@ -276,7 +304,7 @@ const getTopFiveAppListGroup = (
276304 return parsedAppList [ 0 ]
277305 ? topFiveGroupParser ( parsedAppList [ 0 ] , {
278306 id : 'search-app-list-view' ,
279- href : `${ URLS . DEVTRON_APP_LIST } ?${ URL_FILTER_KEYS . SEARCH_KEY } =${ encodeURIComponent ( searchText ) } ` ,
307+ href : `${ COMMON_URLS . APPLICATION_MANAGEMENT_APP_LIST } ?${ URL_FILTER_KEYS . SEARCH_KEY } =${ encodeURIComponent ( searchText ) } ` ,
280308 } )
281309 : parsedAppList
282310}
@@ -294,7 +322,7 @@ const getTopFiveHelmAppListGroup = (
294322 return parsedHelmAppList [ 0 ]
295323 ? topFiveGroupParser ( parsedHelmAppList [ 0 ] , {
296324 id : 'search-helm-app-list-view' ,
297- href : `${ URLS . HELM_APP_LIST } ?${ URL_FILTER_KEYS . SEARCH_KEY } =${ encodeURIComponent ( searchText ) } ` ,
325+ href : `${ generatePath ( COMMON_URLS . INFRASTRUCTURE_MANAGEMENT_APP_LIST , { appType : InfrastructureManagementAppListType . HELM } ) } ?${ URL_FILTER_KEYS . SEARCH_KEY } =${ encodeURIComponent ( searchText ) } ` ,
298326 } )
299327 : parsedHelmAppList
300328}
@@ -332,7 +360,7 @@ const getTopFiveChartListGroup = (
332360 return parsedChartList [ 0 ]
333361 ? topFiveGroupParser ( parsedChartList [ 0 ] , {
334362 id : 'search-chart-list-view' ,
335- href : `${ COMMON_URLS . APPLICATION_MANAGEMENT_CHART_STORE_DISCOVER } ?${ ChartStoreQueryParams . AppStoreName } =${ encodeURIComponent (
363+ href : `${ COMMON_URLS . INFRASTRUCTURE_MANAGEMENT_CHART_STORE_DISCOVER } ?${ ChartStoreQueryParams . AppStoreName } =${ encodeURIComponent (
336364 searchText ,
337365 ) } `,
338366 } )
0 commit comments