mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Profiling] Preserve kuery
filters when switching between Universal Profiling pages in new solution navigation (#203545)
Closes #197401 ### Summary This PR adds ability to preserve `kuery` filters when switching between pages in Universal Profiling using `solution navigation`. The missing filters were considered regression in comparison to `classic navigation`. ### Testing Expected behavior with **classic navigation** for comparison:  Before with **solution navigation**:  After with **solution navigation**: 
This commit is contained in:
parent
748193d0a7
commit
881cdc142b
2 changed files with 40 additions and 20 deletions
|
@ -7,6 +7,7 @@
|
|||
|
||||
import {
|
||||
AppMountParameters,
|
||||
AppUpdater,
|
||||
CoreSetup,
|
||||
CoreStart,
|
||||
DEFAULT_APP_CATEGORIES,
|
||||
|
@ -15,7 +16,7 @@ import {
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import { NavigationSection } from '@kbn/observability-shared-plugin/public';
|
||||
import type { Location } from 'history';
|
||||
import { BehaviorSubject, combineLatest, from, map } from 'rxjs';
|
||||
import { BehaviorSubject, combineLatest, from, map, take } from 'rxjs';
|
||||
import { OBLT_PROFILING_APP_ID } from '@kbn/deeplinks-observability';
|
||||
import { registerEmbeddables } from './embeddables/register_embeddables';
|
||||
import { getServices } from './services';
|
||||
|
@ -64,29 +65,47 @@ export class ProfilingPlugin
|
|||
];
|
||||
|
||||
const kuerySubject = new BehaviorSubject<string>('');
|
||||
const appUpdater$ = new BehaviorSubject<AppUpdater>(() => ({}));
|
||||
|
||||
const section$ = combineLatest([from(coreSetup.getStartServices()), kuerySubject]).pipe(
|
||||
map(([[coreStart], kuery]) => {
|
||||
if (coreStart.application.capabilities.profiling.show) {
|
||||
const sections: NavigationSection[] = [
|
||||
{
|
||||
label: i18n.translate('xpack.profiling.navigation.sectionLabel', {
|
||||
defaultMessage: 'Universal Profiling',
|
||||
}),
|
||||
entries: links.map((link) => {
|
||||
return {
|
||||
app: OBLT_PROFILING_APP_ID,
|
||||
label: link.title,
|
||||
path: `${link.path}?kuery=${kuery ?? ''}`,
|
||||
matchPath: (path) => {
|
||||
return path.startsWith(link.path);
|
||||
},
|
||||
};
|
||||
}),
|
||||
sortKey: 700,
|
||||
},
|
||||
];
|
||||
return sections;
|
||||
let isSidebarEnabled = true;
|
||||
coreStart.chrome
|
||||
.getChromeStyle$()
|
||||
.pipe(take(1))
|
||||
.subscribe((style) => (isSidebarEnabled = style === 'classic'));
|
||||
|
||||
if (isSidebarEnabled) {
|
||||
// classic navigation
|
||||
const sections: NavigationSection[] = [
|
||||
{
|
||||
label: i18n.translate('xpack.profiling.navigation.sectionLabel', {
|
||||
defaultMessage: 'Universal Profiling',
|
||||
}),
|
||||
entries: links.map((link) => {
|
||||
return {
|
||||
app: OBLT_PROFILING_APP_ID,
|
||||
label: link.title,
|
||||
path: kuery ? `${link.path}?kuery=${kuery}` : link.path,
|
||||
matchPath: (path) => {
|
||||
return path.startsWith(link.path);
|
||||
},
|
||||
};
|
||||
}),
|
||||
sortKey: 700,
|
||||
},
|
||||
];
|
||||
return sections;
|
||||
} else {
|
||||
// solution navigation
|
||||
appUpdater$.next(() => ({
|
||||
deepLinks: links.map((link) => ({
|
||||
...link,
|
||||
path: kuery ? `${link.path}?kuery=${encodeURIComponent(kuery)}` : link.path,
|
||||
})),
|
||||
}));
|
||||
}
|
||||
}
|
||||
return [];
|
||||
})
|
||||
|
@ -103,6 +122,7 @@ export class ProfilingPlugin
|
|||
appRoute: '/app/profiling',
|
||||
category: DEFAULT_APP_CATEGORIES.observability,
|
||||
deepLinks: links,
|
||||
updater$: appUpdater$,
|
||||
async mount({ element, history, theme$, setHeaderActionMenu }: AppMountParameters) {
|
||||
const [coreStart, pluginsStart] = await coreSetup.getStartServices();
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue