fix(web): scope dashboard tile hydration
This commit is contained in:
parent
2963c5dfde
commit
2a1d94195e
5 changed files with 124 additions and 22 deletions
|
|
@ -63,6 +63,17 @@ export async function loadDashboardTileResponse(
|
|||
tile: DashboardTileReference,
|
||||
options: LoadDashboardResponseOptions = {},
|
||||
): Promise<DashboardTileResolution> {
|
||||
if (
|
||||
options.disableLiveDatasources ||
|
||||
process.env.DISABLE_LIVE_DATASOURCES === "1"
|
||||
) {
|
||||
return {
|
||||
state: "disabled",
|
||||
tile,
|
||||
message: "Live datasource hydration is disabled.",
|
||||
};
|
||||
}
|
||||
|
||||
const dashboard = loadDashboardRuntime(undefined, {
|
||||
refreshSeedDocument: options.refreshSeedDocument ?? true,
|
||||
seedIfEmpty: options.seedIfEmpty ?? true,
|
||||
|
|
@ -95,7 +106,7 @@ export async function handleDashboardTileRoute(pathname: string): Promise<Respon
|
|||
|
||||
const response = await loadDashboardTileResponse(tile);
|
||||
return Response.json(response, {
|
||||
status: response.state === "ready" ? 200 : 404,
|
||||
status: response.state === "not_found" ? 404 : 200,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -107,10 +118,18 @@ function parseDashboardTilePath(pathname: string): DashboardTileReference | null
|
|||
}
|
||||
|
||||
const id = decodeURIComponent(firstId);
|
||||
if (kind === "telemetry" || kind === "service" || kind === "module") {
|
||||
if (kind === "telemetry" || kind === "module") {
|
||||
return { kind, id };
|
||||
}
|
||||
|
||||
if (kind === "service" && secondId) {
|
||||
return {
|
||||
kind,
|
||||
groupId: id,
|
||||
id: decodeURIComponent(secondId),
|
||||
};
|
||||
}
|
||||
|
||||
if (kind === "status" && secondId) {
|
||||
return {
|
||||
kind,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue