mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[8.17] [Profiling] Preserve `kuery` filters when switching between Universal Profiling pages in new solution navigation (#203545) (#203986)
# Backport This will backport the following commits from `main` to `8.17`: - [[Profiling] Preserve `kuery` filters when switching between Universal Profiling pages in new solution navigation (#203545)](https://github.com/elastic/kibana/pull/203545) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Milosz Marcinkowski","email":"38698566+miloszmarcinkowski@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-12-12T10:23:24Z","message":"[Profiling] Preserve `kuery` filters when switching between Universal Profiling pages in new solution navigation (#203545)\n\nCloses #197401\r\n\r\n### Summary\r\n\r\nThis PR adds ability to preserve `kuery` filters when switching between\r\npages in Universal Profiling using `solution navigation`. The missing\r\nfilters were considered regression in comparison to `classic\r\nnavigation`.\r\n\r\n### Testing\r\n\r\nExpected behavior with **classic navigation** for comparison:\r\n\r\n\r\nBefore with **solution navigation**:\r\n\r\n\r\nAfter with **solution navigation**:\r\n","sha":"881cdc142b3014f964a7b69fc8b29b85211fcbfa","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","v9.0.0","backport:prev-major","ci:project-deploy-observability"],"title":"[Profiling] Preserve `kuery` filters when switching between Universal Profiling pages in new solution navigation","number":203545,"url":"https://github.com/elastic/kibana/pull/203545","mergeCommit":{"message":"[Profiling] Preserve `kuery` filters when switching between Universal Profiling pages in new solution navigation (#203545)\n\nCloses #197401\r\n\r\n### Summary\r\n\r\nThis PR adds ability to preserve `kuery` filters when switching between\r\npages in Universal Profiling using `solution navigation`. The missing\r\nfilters were considered regression in comparison to `classic\r\nnavigation`.\r\n\r\n### Testing\r\n\r\nExpected behavior with **classic navigation** for comparison:\r\n\r\n\r\nBefore with **solution navigation**:\r\n\r\n\r\nAfter with **solution navigation**:\r\n","sha":"881cdc142b3014f964a7b69fc8b29b85211fcbfa"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/203545","number":203545,"mergeCommit":{"message":"[Profiling] Preserve `kuery` filters when switching between Universal Profiling pages in new solution navigation (#203545)\n\nCloses #197401\r\n\r\n### Summary\r\n\r\nThis PR adds ability to preserve `kuery` filters when switching between\r\npages in Universal Profiling using `solution navigation`. The missing\r\nfilters were considered regression in comparison to `classic\r\nnavigation`.\r\n\r\n### Testing\r\n\r\nExpected behavior with **classic navigation** for comparison:\r\n\r\n\r\nBefore with **solution navigation**:\r\n\r\n\r\nAfter with **solution navigation**:\r\n","sha":"881cdc142b3014f964a7b69fc8b29b85211fcbfa"}}]}] BACKPORT--> Co-authored-by: Milosz Marcinkowski <38698566+miloszmarcinkowski@users.noreply.github.com>
This commit is contained in:
parent
c31b41271a
commit
ebdcdd1c6f
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