Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] [Profiling] Preserve `kuery` filters when switching between Universal Profiling pages in new solution navigation (#203545) #203987

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading