Skip to content

Commit

Permalink
[8.16] [Profiling] Preserve `kuery` filters when switching …
Browse files Browse the repository at this point in the history
…between Universal Profiling pages in new solution navigation (#203545) (#203985)

# Backport

This will backport the following commits from `main` to `8.16`:
- [[Profiling] Preserve `kuery` filters when switching between
Universal Profiling pages in new solution navigation
(#203545)](#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":"[email protected]"},"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![Screen Recording 2024-12-10 at 14
40\r\n26](https://github.com/user-attachments/assets/db066c2e-3a47-4ac1-9860-f00364716c19)\r\n\r\nBefore
with **solution navigation**:\r\n![Screen Recording 2024-12-10 at 14
50\r\n21](https://github.com/user-attachments/assets/23481d63-37ee-4983-b8ef-5b3e6da2f55d)\r\n\r\nAfter
with **solution navigation**:\r\n![Screen Recording 2024-12-10 at 14
45\r\n30](https://github.com/user-attachments/assets/216b6c8d-bfb4-4f32-b4f8-40cf17f5847d)","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![Screen Recording 2024-12-10 at 14
40\r\n26](https://github.com/user-attachments/assets/db066c2e-3a47-4ac1-9860-f00364716c19)\r\n\r\nBefore
with **solution navigation**:\r\n![Screen Recording 2024-12-10 at 14
50\r\n21](https://github.com/user-attachments/assets/23481d63-37ee-4983-b8ef-5b3e6da2f55d)\r\n\r\nAfter
with **solution navigation**:\r\n![Screen Recording 2024-12-10 at 14
45\r\n30](https://github.com/user-attachments/assets/216b6c8d-bfb4-4f32-b4f8-40cf17f5847d)","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![Screen Recording 2024-12-10 at 14
40\r\n26](https://github.com/user-attachments/assets/db066c2e-3a47-4ac1-9860-f00364716c19)\r\n\r\nBefore
with **solution navigation**:\r\n![Screen Recording 2024-12-10 at 14
50\r\n21](https://github.com/user-attachments/assets/23481d63-37ee-4983-b8ef-5b3e6da2f55d)\r\n\r\nAfter
with **solution navigation**:\r\n![Screen Recording 2024-12-10 at 14
45\r\n30](https://github.com/user-attachments/assets/216b6c8d-bfb4-4f32-b4f8-40cf17f5847d)","sha":"881cdc142b3014f964a7b69fc8b29b85211fcbfa"}}]}]
BACKPORT-->

Co-authored-by: Milosz Marcinkowski <[email protected]>
  • Loading branch information
kibanamachine and miloszmarcinkowski authored Dec 12, 2024
1 parent c5bc2be commit 53495ac
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import {
AppMountParameters,
AppUpdater,
CoreSetup,
CoreStart,
DEFAULT_APP_CATEGORIES,
Expand All @@ -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';
Expand Down Expand Up @@ -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 [];
})
Expand All @@ -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();

Expand Down

0 comments on commit 53495ac

Please sign in to comment.