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

PMM-13689 Remove menu link variables with value "All" #801

Merged
merged 1 commit into from
Jan 23, 2025
Merged
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
22 changes: 20 additions & 2 deletions public/app/percona/shared/helpers/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { getLinkSrv } from 'app/features/panel/panellinks/link_srv';

export const useLinkWithVariables = (url?: string) => {
if (url && isDashboardUrl(url) && isDashboardUrl(window.location.pathname)) {
return getLinkSrv().getLinkUrl({
const urlWithLinks = getLinkSrv().getLinkUrl({
url: url,
keepTime: true,
// Check if the DB type matches the current one used
includeVars: checkDbType(url),
});
return cleanupVariables(urlWithLinks);
} else {
return url ? url : '#';
}
Expand All @@ -19,5 +20,22 @@ const checkDbType = (url: string): boolean => {
const currentDB = window.location.pathname?.split('/')[3]?.split('-')[0];
const urlDB = url?.split('/')[3]?.split('-')[0];

return currentDB !== undefined && currentDB === urlDB;
// enable variable sharing between same db types and db type -> os/node
return (currentDB !== undefined && currentDB === urlDB) || urlDB === 'node';
};

const cleanupVariables = (urlWithLinks: string) => {
const [base, params] = urlWithLinks.split('?');

if (params) {
// remove variables which have the All value or the value is empty
const variables = params
.split('&')
.filter((param) => !(param.includes('All') || param.endsWith('=')))
.join('&');

return base + '?' + variables;
}

return base;
};
Loading