fix(web): scope dashboard tile hydration
This commit is contained in:
parent
2963c5dfde
commit
2a1d94195e
5 changed files with 124 additions and 22 deletions
|
|
@ -12,7 +12,7 @@ import type {
|
|||
|
||||
export type DashboardTileReference =
|
||||
| { kind: "telemetry"; id: string }
|
||||
| { kind: "service"; id: string }
|
||||
| { kind: "service"; groupId: string; id: string }
|
||||
| { kind: "module"; id: string }
|
||||
| { kind: "status"; stripId: string; id: string };
|
||||
|
||||
|
|
@ -32,6 +32,11 @@ export type DashboardTileResolution =
|
|||
state: "not_found";
|
||||
tile: DashboardTileReference;
|
||||
message: string;
|
||||
}
|
||||
| {
|
||||
state: "disabled";
|
||||
tile: DashboardTileReference;
|
||||
message: string;
|
||||
};
|
||||
|
||||
export interface DatasourceResolutionOptions {
|
||||
|
|
@ -90,8 +95,8 @@ export async function resolveDashboardTile(
|
|||
|
||||
if (tile.kind === "service") {
|
||||
const service = document.serviceGroups
|
||||
.flatMap((group) => group.services)
|
||||
.find((item) => item.id === tile.id);
|
||||
.find((group) => group.id === tile.groupId)
|
||||
?.services.find((item) => item.id === tile.id);
|
||||
if (!service) return missingTile(tile);
|
||||
|
||||
return {
|
||||
|
|
@ -832,7 +837,7 @@ function missingTile(tile: DashboardTileReference): DashboardTileResolution {
|
|||
}
|
||||
|
||||
function tileKey(tile: DashboardTileReference): string {
|
||||
return tile.kind === "status"
|
||||
? `${tile.kind}:${tile.stripId}:${tile.id}`
|
||||
: `${tile.kind}:${tile.id}`;
|
||||
if (tile.kind === "status") return `${tile.kind}:${tile.stripId}:${tile.id}`;
|
||||
if (tile.kind === "service") return `${tile.kind}:${tile.groupId}:${tile.id}`;
|
||||
return `${tile.kind}:${tile.id}`;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue