From 7c0d719ad8e62ea919f7c341f6c2ab7ae201cffa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 17 Mar 2023 15:58:48 +0100 Subject: [PATCH 1/3] DataSourceVariable: Fix state property name to be more descriptive --- .../variants/DataSourceVariable.test.ts | 18 +++++++++--------- .../variables/variants/DataSourceVariable.tsx | 14 ++++++++++---- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/packages/scenes/src/variables/variants/DataSourceVariable.test.ts b/packages/scenes/src/variables/variants/DataSourceVariable.test.ts index 01a64ca4a..758de204d 100644 --- a/packages/scenes/src/variables/variants/DataSourceVariable.test.ts +++ b/packages/scenes/src/variables/variants/DataSourceVariable.test.ts @@ -74,7 +74,7 @@ describe('DataSourceVariable', () => { options: [], value: '', text: '', - query: '', + pluginId: '', }); await lastValueFrom(variable.validateAndUpdate()); @@ -92,7 +92,7 @@ describe('DataSourceVariable', () => { options: [], value: '', text: '', - query: 'non-existant-datasource', + pluginId: 'non-existant-datasource', }); await lastValueFrom(variable.validateAndUpdate()); @@ -113,7 +113,7 @@ describe('DataSourceVariable', () => { options: [], value: '', text: '', - query: 'prometheus', + pluginId: 'prometheus', }); await lastValueFrom(variable.validateAndUpdate()); @@ -142,7 +142,7 @@ describe('DataSourceVariable', () => { options: [], value: '', text: '', - query: 'prometheus', + pluginId: 'prometheus', }); await lastValueFrom(variable.validateAndUpdate()); @@ -164,7 +164,7 @@ describe('DataSourceVariable', () => { options: [], value: '', text: '', - query: 'prometheus', + pluginId: 'prometheus', regex: 'slow.*', }); @@ -181,7 +181,7 @@ describe('DataSourceVariable', () => { options: [], value: '', text: '', - query: 'prometheus', + pluginId: 'prometheus', regex: '$variable-1.*', }); @@ -198,7 +198,7 @@ describe('DataSourceVariable', () => { const variable = new DataSourceVariable({ name: 'test', options: [], - query: 'prometheus', + pluginId: 'prometheus', value: 'slow-prometheus-mocked', text: 'slow-prometheus-mocked', }); @@ -214,7 +214,7 @@ describe('DataSourceVariable', () => { name: 'test', options: [], isMulti: true, - query: 'prometheus', + pluginId: 'prometheus', value: ['prometheus-mocked', 'slow-prometheus-mocked', 'elastic-mocked'], text: ['prometheus-mocked', 'slow-prometheus-mocked', 'elastic-mocked'], }); @@ -230,7 +230,7 @@ describe('DataSourceVariable', () => { name: 'test', options: [], isMulti: true, - query: 'elastic', + pluginId: 'elastic', value: ['prometheus-mocked', 'slow-prometheus-mocked'], text: ['prometheus-mocked', 'slow-prometheus-mocked'], }); diff --git a/packages/scenes/src/variables/variants/DataSourceVariable.tsx b/packages/scenes/src/variables/variants/DataSourceVariable.tsx index dbea25ae9..03cca7f40 100644 --- a/packages/scenes/src/variables/variants/DataSourceVariable.tsx +++ b/packages/scenes/src/variables/variants/DataSourceVariable.tsx @@ -12,7 +12,13 @@ import { VariableValueOption } from '../types'; import { MultiValueVariable, MultiValueVariableState, VariableGetOptionsArgs } from './MultiValueVariable'; export interface DataSourceVariableState extends MultiValueVariableState { - query: string; + /** + * Include all data source instance of this plugin type + */ + pluginId: string; + /** + * Filter data source instances based on name + */ regex: string; } @@ -29,13 +35,13 @@ export class DataSourceVariable extends MultiValueVariable { - if (!this.state.query) { + if (!this.state.pluginId) { return of([]); } @@ -52,7 +58,7 @@ export class DataSourceVariable extends MultiValueVariable Date: Mon, 20 Mar 2023 10:33:20 +0100 Subject: [PATCH 2/3] Update packages/scenes/src/variables/variants/DataSourceVariable.tsx --- packages/scenes/src/variables/variants/DataSourceVariable.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/scenes/src/variables/variants/DataSourceVariable.tsx b/packages/scenes/src/variables/variants/DataSourceVariable.tsx index 03cca7f40..de8ccd2ce 100644 --- a/packages/scenes/src/variables/variants/DataSourceVariable.tsx +++ b/packages/scenes/src/variables/variants/DataSourceVariable.tsx @@ -13,7 +13,7 @@ import { MultiValueVariable, MultiValueVariableState, VariableGetOptionsArgs } f export interface DataSourceVariableState extends MultiValueVariableState { /** - * Include all data source instance of this plugin type + * Include all data source instances with this plugin id */ pluginId: string; /** From 5d8fbefc28bf8f13bb3aeac69c042469048d7c89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 20 Mar 2023 10:42:29 +0100 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37a9ae050..3143d7398 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # 0.22 () * Removal of isEditing from SceneComponentProps (also $editor from SceneObjectState, and sceneGraph.getSceneEditor) +* DataSourceVariable state change, query property is now named pluginId # 0.21 (2023-03-17)