@@ -126,11 +126,11 @@ export function CollapsibleNav({
126
126
const appId = useObservable ( observables . appId$ , '' ) ;
127
127
const currentWorkspace = useObservable ( observables . currentWorkspace$ ) ;
128
128
const lockRef = useRef < HTMLButtonElement > ( null ) ;
129
- const groupedNavLinks = groupBy ( navLinks , ( link ) => link ?. category ?. id ) ;
129
+ const filterdLinks = getFilterLinks ( currentWorkspace , navLinks ) ;
130
+ const groupedNavLinks = groupBy ( filterdLinks , ( link ) => link ?. category ?. id ) ;
130
131
const { undefined : unknowns = [ ] , ...allCategorizedLinks } = groupedNavLinks ;
131
- const filterdLinks = getFilterLinks ( currentWorkspace , allCategorizedLinks ) ;
132
- const categoryDictionary = getAllCategories ( filterdLinks ) ;
133
- const orderedCategories = getOrderedCategories ( filterdLinks , categoryDictionary ) ;
132
+ const categoryDictionary = getAllCategories ( allCategorizedLinks ) ;
133
+ const orderedCategories = getOrderedCategories ( allCategorizedLinks , categoryDictionary ) ;
134
134
135
135
const readyForEUI = ( link : ChromeNavLink , needsIcon : boolean = false ) => {
136
136
return createEuiListItem ( {
@@ -152,20 +152,13 @@ export function CollapsibleNav({
152
152
153
153
function getFilterLinks (
154
154
workspace : WorkspaceAttribute | null | undefined ,
155
- categorizedLinks : Record < string , ChromeNavLink [ ] >
155
+ allNavLinks : ChromeNavLink [ ]
156
156
) {
157
- // plugins are in this dictionary
158
- const pluginsDictionary = categorizedLinks . opensearch ;
159
- if ( ! pluginsDictionary ) return categorizedLinks ;
157
+ if ( ! workspace ) return allNavLinks ;
160
158
161
- const features = workspace ?. features ?? [ ] ;
162
- const newPluginsDictionary = pluginsDictionary . filter ( ( item ) => features . indexOf ( item . id ) > - 1 ) ;
163
- if ( newPluginsDictionary . length === 0 ) {
164
- delete categorizedLinks . opensearch ;
165
- } else {
166
- categorizedLinks . opensearch = newPluginsDictionary ;
167
- }
168
- return categorizedLinks ;
159
+ const features = workspace . features ?? [ ] ;
160
+ const links = allNavLinks . filter ( ( item ) => features . indexOf ( item . id ) > - 1 ) ;
161
+ return links ;
169
162
}
170
163
171
164
/**
0 commit comments