Dashboard datasource: Activate parents of query runner when using dashboard ds (#95507)

* Activate parents of query runner when using dashboard ds

* Set plugin loading util to fix test because activating the ancestors of the query runner needs to be able to load the plugin for the panel
This commit is contained in:
Oscar Kilhed 2024-10-29 09:55:13 +01:00 committed by GitHub
parent 9b91be739d
commit 97027834a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 3 deletions

View File

@ -6,6 +6,8 @@ import {
LoadingState,
standardTransformersRegistry,
} from '@grafana/data';
import { getPanelPlugin } from '@grafana/data/test/__mocks__/pluginMocks';
import { setPluginImportUtils } from '@grafana/runtime';
import {
SafeSerializableSceneObject,
SceneDataNode,
@ -21,6 +23,10 @@ import { DashboardDatasource } from './datasource';
import { DashboardQuery } from './types';
standardTransformersRegistry.setInit(getStandardTransformers);
setPluginImportUtils({
importPanelPlugin: (id: string) => Promise.resolve(getPanelPlugin({})),
getPanelPluginFromCache: (id: string) => undefined,
});
describe('DashboardDatasource', () => {
it("should look up the other panel and subscribe to it's data", async () => {

View File

@ -9,7 +9,11 @@ import {
ScopedVar,
} from '@grafana/data';
import { SceneDataProvider, SceneDataTransformer, SceneObject } from '@grafana/scenes';
import { findVizPanelByKey, getVizPanelKeyForPanelId } from 'app/features/dashboard-scene/utils/utils';
import {
activateInActiveParents,
findVizPanelByKey,
getVizPanelKeyForPanelId,
} from 'app/features/dashboard-scene/utils/utils';
import { DashboardQuery } from './types';
@ -69,7 +73,7 @@ export class DashboardDatasource extends DataSourceApi<DashboardQuery> {
sourceDataProvider?.setContainerWidth(500);
}
const cleanUp = sourceDataProvider!.activate();
const cleanUp = activateInActiveParents(sourceDataProvider!);
return sourceDataProvider!.getResultsStream!().pipe(
map((result) => {
@ -81,7 +85,7 @@ export class DashboardDatasource extends DataSourceApi<DashboardQuery> {
key: 'source-ds-provider',
};
}),
finalize(cleanUp)
finalize(() => cleanUp?.())
);
});
}