Scopes: Name relationship objects *binding (#84955)

Signed-off-by: bergquist <carl.bergquist@gmail.com>
Co-authored-by: Bogdan Matei <bogdan.matei@grafana.com>
This commit is contained in:
Carl Bergquist
2024-03-26 15:52:12 +01:00
committed by GitHub
parent c39b9b2cbe
commit b214b07695
9 changed files with 84 additions and 69 deletions

View File

@@ -58,13 +58,10 @@ export class ScopesDashboardsScene extends SceneObjectBase<ScopesDashboardsScene
private async fetchDashboardsUids(scope: string): Promise<string[]> {
try {
const response = await getBackendSrv().get<{
items: Array<{ spec: { dashboardUids: null | string[]; scopeUid: string } }>;
items: Array<{ spec: { dashboards: null | string[]; scope: string } }>;
}>(this._url, { scope });
return (
response.items.find((item) => !!item.spec.dashboardUids && item.spec.scopeUid === scope)?.spec.dashboardUids ??
[]
);
return response.items.find((item) => !!item.spec.dashboards && item.spec.scope === scope)?.spec.dashboards ?? [];
} catch (err) {
return [];
}

View File

@@ -92,8 +92,8 @@ jest.mock('@grafana/runtime', () => ({
return {
items: Object.values(scopesMocks).map((scope) => ({
spec: {
dashboardUids: scope.dashboards.map((dashboard) => dashboard.uid),
scopeUid: scope.uid,
dashboards: scope.dashboards.map((dashboard) => dashboard.uid),
scope: scope.uid,
},
})),
};