Skip to content

Commit

Permalink
PMM-13180 Fix menu variables link generation
Browse files Browse the repository at this point in the history
  • Loading branch information
matejkubinec committed Jun 19, 2024
1 parent e589465 commit 787ecf1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions public/app/percona/shared/helpers/navigation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getLinkSrv } from 'app/features/panel/panellinks/link_srv';

export const useLinkWithVariables = (url?: string) => {
if (url?.match('/d/')) {
if (url && isDashboardUrl(url) && isDashboardUrl(window.location.pathname)) {
return getLinkSrv().getLinkUrl({
url: url,
keepTime: true,
Expand All @@ -13,9 +13,11 @@ export const useLinkWithVariables = (url?: string) => {
}
};

const isDashboardUrl = (url?: string) => url?.match('/d/');

const checkDbType = (url: string): boolean => {
const currentDB = window.location.pathname.split('/')[3].split('-')[0];
const urlDB = url.split('/')[3].split('-')[0];
const currentDB = window.location.pathname?.split('/')[3]?.split('-')[0];
const urlDB = url?.split('/')[3]?.split('-')[0];

return currentDB === urlDB;
return currentDB !== undefined && currentDB === urlDB;
};

0 comments on commit 787ecf1

Please sign in to comment.