Skip to content

Commit

Permalink
PMM-13689 Remove menu link variables with value "All"
Browse files Browse the repository at this point in the history
  • Loading branch information
matejkubinec committed Jan 22, 2025
1 parent 47516dc commit 727a4ab
Showing 1 changed file with 20 additions and 2 deletions.
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;
};

0 comments on commit 727a4ab

Please sign in to comment.