FS: Fix rendering of public dashboards in MT frontend service (#115162)
* pass publicDashboardAccessToken to ST backend via bootdata * slightly cleaner * slightly tidy up go templating * add HandleView middleware
This commit is contained in:
@@ -188,6 +188,7 @@
|
||||
// Wrap in an IIFE to avoid polluting the global scope. Intentionally global-scope properties
|
||||
// are explicitly assigned to the `window` object.
|
||||
(() => {
|
||||
const publicDashboardAccessToken = [[.PublicDashboardAccessToken]]
|
||||
// Grafana can only fail to load once
|
||||
// However, it can fail to load in multiple different places
|
||||
// To avoid double reporting the error, we use this boolean to check if we've already failed
|
||||
@@ -271,9 +272,15 @@
|
||||
async function fetchBootData() {
|
||||
const queryParams = new URLSearchParams(window.location.search);
|
||||
|
||||
let path = '/bootdata';
|
||||
// call a special bootdata url with the public access token
|
||||
// this is needed to set the access token and correct org for public dashboards on the ST backend
|
||||
if (publicDashboardAccessToken) {
|
||||
path += `/${publicDashboardAccessToken}`;
|
||||
}
|
||||
// pass the search params through to the bootdata request
|
||||
// this allows for overriding the theme/language etc
|
||||
const bootDataUrl = new URL('/bootdata', window.location.origin);
|
||||
const bootDataUrl = new URL(path, window.location.origin);
|
||||
for (const [key, value] of queryParams.entries()) {
|
||||
bootDataUrl.searchParams.append(key, value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user