mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Use SafeSerializableSceneObject in TemplateSrv (#90272)
* Test * Opaque object * Update scenes tentatively * Betterer * Fix dashboard data source * Fix dashboard data source test * Scenes bump * Cleanup * Ivan's feedback
This commit is contained in:
@@ -6,8 +6,9 @@ import {
|
||||
DataQueryResponse,
|
||||
DataSourceInstanceSettings,
|
||||
TestDataSourceResponse,
|
||||
ScopedVar,
|
||||
} from '@grafana/data';
|
||||
import { SceneDataProvider, SceneDataTransformer, SceneObject } from '@grafana/scenes';
|
||||
import { SafeSerializableSceneObject, SceneDataProvider, SceneDataTransformer, SceneObject } from '@grafana/scenes';
|
||||
import { findVizPanelByKey, getVizPanelKeyForPanelId } from 'app/features/dashboard-scene/utils/utils';
|
||||
|
||||
import { DashboardQuery } from './types';
|
||||
@@ -25,7 +26,14 @@ export class DashboardDatasource extends DataSourceApi<DashboardQuery> {
|
||||
}
|
||||
|
||||
query(options: DataQueryRequest<DashboardQuery>): Observable<DataQueryResponse> {
|
||||
const scene: SceneObject | undefined = options.scopedVars?.__sceneObject?.value;
|
||||
const sceneScopedVar: ScopedVar | undefined = options.scopedVars?.__sceneObject;
|
||||
let scene: SceneObject | undefined;
|
||||
|
||||
if (!(sceneScopedVar instanceof SafeSerializableSceneObject)) {
|
||||
throw new Error('Scene object from scopedVars is not safe serializable.');
|
||||
}
|
||||
|
||||
scene = sceneScopedVar.valueOf();
|
||||
|
||||
if (options.requestId.indexOf('mixed') > -1) {
|
||||
throw new Error('Dashboard data source cannot be used with Mixed data source.');
|
||||
|
||||
Reference in New Issue
Block a user