Scenes: Update to 0.19 and update transformations scenario (#64789)

* Scene: Transformations update

* Update
This commit is contained in:
Torkel Ödegaard 2023-03-15 09:29:42 +01:00 committed by GitHub
parent 51974c54d7
commit ec003d502b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 14 deletions

View File

@ -267,7 +267,7 @@
"@grafana/lezer-logql": "0.1.2",
"@grafana/monaco-logql": "^0.0.7",
"@grafana/runtime": "workspace:*",
"@grafana/scenes": "^0.0.18",
"@grafana/scenes": "^0.0.19",
"@grafana/schema": "workspace:*",
"@grafana/ui": "workspace:*",
"@kusto/monaco-kusto": "5.3.6",

View File

@ -2,6 +2,7 @@ import {
CustomVariable,
DataSourceVariable,
QueryVariable,
SceneDataTransformer,
SceneGridLayout,
SceneGridRow,
SceneQueryRunner,
@ -301,9 +302,13 @@ describe('DashboardLoader', () => {
expect(vizPanelSceneObject.state.options).toEqual(panel.options);
expect(vizPanelSceneObject.state.fieldConfig).toEqual(panel.fieldConfig);
expect(vizPanelSceneObject.state.pluginVersion).toBe('1.0.0');
expect((vizPanelSceneObject.state.$data as SceneQueryRunner)?.state.queries).toEqual(panel.targets);
expect((vizPanelSceneObject.state.$data as SceneQueryRunner)?.state.maxDataPoints).toEqual(100);
expect((vizPanelSceneObject.state.$data as SceneQueryRunner)?.state.transformations).toEqual(
expect(
((vizPanelSceneObject.state.$data as SceneDataTransformer)?.state.$data as SceneQueryRunner).state.queries
).toEqual(panel.targets);
expect(
((vizPanelSceneObject.state.$data as SceneDataTransformer)?.state.$data as SceneQueryRunner).state.maxDataPoints
).toEqual(100);
expect((vizPanelSceneObject.state.$data as SceneDataTransformer)?.state.transformations).toEqual(
panel.transformations
);
});

View File

@ -20,6 +20,7 @@ import {
DataSourceVariable,
QueryVariable,
ConstantVariable,
SceneDataTransformer,
} from '@grafana/scenes';
import { StateManagerBase } from 'app/core/services/StateManagerBase';
import { dashboardLoaderSrv } from 'app/features/dashboard/services/DashboardLoaderSrv';
@ -263,10 +264,12 @@ export function createVizPanelFromPanelModel(panel: PanelModel) {
options: panel.options,
fieldConfig: panel.fieldConfig,
pluginVersion: panel.pluginVersion,
$data: new SceneQueryRunner({
transformations: panel.transformations,
queries: panel.targets,
maxDataPoints: panel.maxDataPoints ?? undefined,
$data: new SceneDataTransformer({
$data: new SceneQueryRunner({
queries: panel.targets,
maxDataPoints: panel.maxDataPoints ?? undefined,
}),
transformations: panel.transformations ?? [],
}),
});
}

View File

@ -38,7 +38,8 @@ export function getTransformationsDemo(): DashboardScene {
}),
new VizPanel({
$data: getQueryRunnerWithRandomWalkQuery(undefined, {
$data: new SceneDataTransformer({
$data: getQueryRunnerWithRandomWalkQuery(),
transformations: [
{
id: 'reduce',
@ -48,6 +49,7 @@ export function getTransformationsDemo(): DashboardScene {
},
],
}),
pluginId: 'stat',
title: 'Query with predefined transformations',
}),

View File

@ -5207,9 +5207,9 @@ __metadata:
languageName: unknown
linkType: soft
"@grafana/scenes@npm:^0.0.18":
version: 0.0.18
resolution: "@grafana/scenes@npm:0.0.18"
"@grafana/scenes@npm:^0.0.19":
version: 0.0.19
resolution: "@grafana/scenes@npm:0.0.19"
dependencies:
"@grafana/e2e-selectors": ^9.4.3
"@grafana/experimental": 1.0.1
@ -5217,7 +5217,7 @@ __metadata:
react-use: 17.4.0
react-virtualized-auto-sizer: 1.0.7
uuid: ^9.0.0
checksum: f863cbf410d71e579cd4e343fb7b8ad014bc66a250f4d31f9d43c43fe8e97f5b6e3e8d01ed69818c347b3db31b6ecb153d1dc7a0e2946d360e7e1806eb6f5d8c
checksum: e71451751523c33a72d1fe777ac37795166da44c4316a8c1a00ffff936167d49eca91cbe1557a7ffbbfa220c58112dc5c84d45058725efd5c1bf3ba32c2cfb36
languageName: node
linkType: hard
@ -22118,7 +22118,7 @@ __metadata:
"@grafana/lezer-logql": 0.1.2
"@grafana/monaco-logql": ^0.0.7
"@grafana/runtime": "workspace:*"
"@grafana/scenes": ^0.0.18
"@grafana/scenes": ^0.0.19
"@grafana/schema": "workspace:*"
"@grafana/toolkit": "workspace:*"
"@grafana/tsconfig": ^1.2.0-rc1