forked from grafana/grafana
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* PMM-13122 Include variables in dashboard links in main menu * PMM-13122 Pass variables only to same db type dashboards
- Loading branch information
1 parent
fe5d27d
commit 5ea2ec4
Showing
2 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { getLinkSrv } from 'app/features/panel/panellinks/link_srv'; | ||
|
||
export const useLinkWithVariables = (url?: string) => { | ||
if (url?.match('/d/')) { | ||
return getLinkSrv().getLinkUrl({ | ||
url: url, | ||
keepTime: true, | ||
// Check if the DB type matches the current one used | ||
includeVars: checkDbType(url), | ||
}); | ||
} else { | ||
return url ? url : '#'; | ||
} | ||
}; | ||
|
||
const checkDbType = (url: string): boolean => { | ||
const currentDB = window.location.pathname.split('/')[3].split('-')[0]; | ||
const urlDB = url.split('/')[3].split('-')[0]; | ||
|
||
return currentDB === urlDB; | ||
}; |