mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Dashboard: Scene Migration: Add variable definition
prop to serialization (#79022)
Co-authored-by: Ivan Ortega Alba <ivanortegaalba@gmail.com>
This commit is contained in:
parent
3299809977
commit
e8b2e85966
@ -256,7 +256,7 @@
|
||||
"@grafana/lezer-traceql": "0.0.11",
|
||||
"@grafana/monaco-logql": "^0.0.7",
|
||||
"@grafana/runtime": "workspace:*",
|
||||
"@grafana/scenes": "^1.24.6",
|
||||
"@grafana/scenes": "^1.26.0",
|
||||
"@grafana/schema": "workspace:*",
|
||||
"@grafana/ui": "workspace:*",
|
||||
"@kusto/monaco-kusto": "^7.4.0",
|
||||
|
@ -520,6 +520,7 @@ exports[`transformSceneToSaveModel Given a simple scene with custom settings Sho
|
||||
"text": "A",
|
||||
"value": "A",
|
||||
},
|
||||
"definition": "*",
|
||||
"includeAll": false,
|
||||
"name": "query0",
|
||||
"options": [],
|
||||
@ -842,6 +843,7 @@ exports[`transformSceneToSaveModel Given a simple scene with variables Should tr
|
||||
"text": "A",
|
||||
"value": "A",
|
||||
},
|
||||
"definition": "*",
|
||||
"includeAll": false,
|
||||
"name": "query0",
|
||||
"options": [],
|
||||
|
@ -120,6 +120,58 @@ describe('sceneVariablesSetToVariables', () => {
|
||||
"type": "fake-std",
|
||||
"uid": "fake-std",
|
||||
},
|
||||
"definition": undefined,
|
||||
"description": "test-desc",
|
||||
"includeAll": true,
|
||||
"label": "test-label",
|
||||
"multi": true,
|
||||
"name": "test",
|
||||
"options": [],
|
||||
"query": "query",
|
||||
"refresh": 1,
|
||||
"regex": "",
|
||||
"type": "query",
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
it('should handle QueryVariable with definition set', () => {
|
||||
const variable = new QueryVariable({
|
||||
name: 'test',
|
||||
label: 'test-label',
|
||||
description: 'test-desc',
|
||||
value: ['selected-value'],
|
||||
text: ['selected-value-text'],
|
||||
datasource: { uid: 'fake-std', type: 'fake-std' },
|
||||
query: 'query',
|
||||
definition: 'query',
|
||||
includeAll: true,
|
||||
allValue: 'test-all',
|
||||
isMulti: true,
|
||||
});
|
||||
const set = new SceneVariableSet({
|
||||
variables: [variable],
|
||||
});
|
||||
|
||||
const result = sceneVariablesSetToVariables(set);
|
||||
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result[0]).toMatchInlineSnapshot(`
|
||||
{
|
||||
"allValue": "test-all",
|
||||
"current": {
|
||||
"text": [
|
||||
"selected-value-text",
|
||||
],
|
||||
"value": [
|
||||
"selected-value",
|
||||
],
|
||||
},
|
||||
"datasource": {
|
||||
"type": "fake-std",
|
||||
"uid": "fake-std",
|
||||
},
|
||||
"definition": "query",
|
||||
"description": "test-desc",
|
||||
"includeAll": true,
|
||||
"label": "test-label",
|
||||
|
@ -25,6 +25,7 @@ export function sceneVariablesSetToVariables(set: SceneVariables) {
|
||||
},
|
||||
options: [],
|
||||
query: variable.state.query,
|
||||
definition: variable.state.definition,
|
||||
datasource: variable.state.datasource,
|
||||
sort: variable.state.sort,
|
||||
refresh: variable.state.refresh,
|
||||
|
@ -455,7 +455,7 @@ describe('transformSaveModelToScene', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should migrate query variable', () => {
|
||||
it('should migrate query variable with definition', () => {
|
||||
const variable: QueryVariableModel = {
|
||||
allValue: null,
|
||||
current: {
|
||||
@ -467,7 +467,7 @@ describe('transformSaveModelToScene', () => {
|
||||
uid: 'P15396BDD62B2BE29',
|
||||
type: 'influxdb',
|
||||
},
|
||||
definition: '',
|
||||
definition: 'SHOW TAG VALUES WITH KEY = "datacenter"',
|
||||
hide: 0,
|
||||
includeAll: false,
|
||||
label: 'Datacenter',
|
||||
@ -536,6 +536,7 @@ describe('transformSaveModelToScene', () => {
|
||||
type: 'query',
|
||||
value: 'America',
|
||||
hide: 0,
|
||||
definition: 'SHOW TAG VALUES WITH KEY = "datacenter"',
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -310,6 +310,7 @@ export function createSceneVariableFromVariableModel(variable: TypedVariableMode
|
||||
isMulti: variable.multi,
|
||||
skipUrlSync: variable.skipUrlSync,
|
||||
hide: variable.hide,
|
||||
definition: variable.definition,
|
||||
});
|
||||
} else if (variable.type === 'datasource') {
|
||||
return new DataSourceVariable({
|
||||
|
10
yarn.lock
10
yarn.lock
@ -3302,9 +3302,9 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@grafana/scenes@npm:^1.24.6":
|
||||
version: 1.24.6
|
||||
resolution: "@grafana/scenes@npm:1.24.6"
|
||||
"@grafana/scenes@npm:^1.26.0":
|
||||
version: 1.26.0
|
||||
resolution: "@grafana/scenes@npm:1.26.0"
|
||||
dependencies:
|
||||
"@grafana/e2e-selectors": "npm:10.0.2"
|
||||
react-grid-layout: "npm:1.3.4"
|
||||
@ -3316,7 +3316,7 @@ __metadata:
|
||||
"@grafana/runtime": 10.0.3
|
||||
"@grafana/schema": 10.0.3
|
||||
"@grafana/ui": 10.0.3
|
||||
checksum: 71df3f23f2a9083643ff2344960c01bcd87e7ff8c0802c8074e11d2b1acc9b99c0a6a3239c75db47b2507493beb83374dca4e02787b486d45f4dcbd5400a4055
|
||||
checksum: a4d00396552ef048c28a51d4a4d36a7c9a9fb3ca193641002b279a33a5e85c10b1e63b859c0f42c6cc34992016fb18c10566817ac04c637dc48a0e85d21a93ab
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@ -17332,7 +17332,7 @@ __metadata:
|
||||
"@grafana/lezer-traceql": "npm:0.0.11"
|
||||
"@grafana/monaco-logql": "npm:^0.0.7"
|
||||
"@grafana/runtime": "workspace:*"
|
||||
"@grafana/scenes": "npm:^1.24.6"
|
||||
"@grafana/scenes": "npm:^1.26.0"
|
||||
"@grafana/schema": "workspace:*"
|
||||
"@grafana/tsconfig": "npm:^1.3.0-rc1"
|
||||
"@grafana/ui": "workspace:*"
|
||||
|
Loading…
Reference in New Issue
Block a user