Skip to content

Commit 7c0d719

Browse files
committed
DataSourceVariable: Fix state property name to be more descriptive
1 parent 44d607d commit 7c0d719

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

packages/scenes/src/variables/variants/DataSourceVariable.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ describe('DataSourceVariable', () => {
7474
options: [],
7575
value: '',
7676
text: '',
77-
query: '',
77+
pluginId: '',
7878
});
7979

8080
await lastValueFrom(variable.validateAndUpdate());
@@ -92,7 +92,7 @@ describe('DataSourceVariable', () => {
9292
options: [],
9393
value: '',
9494
text: '',
95-
query: 'non-existant-datasource',
95+
pluginId: 'non-existant-datasource',
9696
});
9797

9898
await lastValueFrom(variable.validateAndUpdate());
@@ -113,7 +113,7 @@ describe('DataSourceVariable', () => {
113113
options: [],
114114
value: '',
115115
text: '',
116-
query: 'prometheus',
116+
pluginId: 'prometheus',
117117
});
118118

119119
await lastValueFrom(variable.validateAndUpdate());
@@ -142,7 +142,7 @@ describe('DataSourceVariable', () => {
142142
options: [],
143143
value: '',
144144
text: '',
145-
query: 'prometheus',
145+
pluginId: 'prometheus',
146146
});
147147

148148
await lastValueFrom(variable.validateAndUpdate());
@@ -164,7 +164,7 @@ describe('DataSourceVariable', () => {
164164
options: [],
165165
value: '',
166166
text: '',
167-
query: 'prometheus',
167+
pluginId: 'prometheus',
168168
regex: 'slow.*',
169169
});
170170

@@ -181,7 +181,7 @@ describe('DataSourceVariable', () => {
181181
options: [],
182182
value: '',
183183
text: '',
184-
query: 'prometheus',
184+
pluginId: 'prometheus',
185185
regex: '$variable-1.*',
186186
});
187187

@@ -198,7 +198,7 @@ describe('DataSourceVariable', () => {
198198
const variable = new DataSourceVariable({
199199
name: 'test',
200200
options: [],
201-
query: 'prometheus',
201+
pluginId: 'prometheus',
202202
value: 'slow-prometheus-mocked',
203203
text: 'slow-prometheus-mocked',
204204
});
@@ -214,7 +214,7 @@ describe('DataSourceVariable', () => {
214214
name: 'test',
215215
options: [],
216216
isMulti: true,
217-
query: 'prometheus',
217+
pluginId: 'prometheus',
218218
value: ['prometheus-mocked', 'slow-prometheus-mocked', 'elastic-mocked'],
219219
text: ['prometheus-mocked', 'slow-prometheus-mocked', 'elastic-mocked'],
220220
});
@@ -230,7 +230,7 @@ describe('DataSourceVariable', () => {
230230
name: 'test',
231231
options: [],
232232
isMulti: true,
233-
query: 'elastic',
233+
pluginId: 'elastic',
234234
value: ['prometheus-mocked', 'slow-prometheus-mocked'],
235235
text: ['prometheus-mocked', 'slow-prometheus-mocked'],
236236
});

packages/scenes/src/variables/variants/DataSourceVariable.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ import { VariableValueOption } from '../types';
1212
import { MultiValueVariable, MultiValueVariableState, VariableGetOptionsArgs } from './MultiValueVariable';
1313

1414
export interface DataSourceVariableState extends MultiValueVariableState {
15-
query: string;
15+
/**
16+
* Include all data source instance of this plugin type
17+
*/
18+
pluginId: string;
19+
/**
20+
* Filter data source instances based on name
21+
*/
1622
regex: string;
1723
}
1824

@@ -29,13 +35,13 @@ export class DataSourceVariable extends MultiValueVariable<DataSourceVariableSta
2935
options: [],
3036
name: '',
3137
regex: '',
32-
query: '',
38+
pluginId: '',
3339
...initialState,
3440
});
3541
}
3642

3743
public getValueOptions(args: VariableGetOptionsArgs): Observable<VariableValueOption[]> {
38-
if (!this.state.query) {
44+
if (!this.state.pluginId) {
3945
return of([]);
4046
}
4147

@@ -52,7 +58,7 @@ export class DataSourceVariable extends MultiValueVariable<DataSourceVariableSta
5258
for (let i = 0; i < dataSourceTypes.length; i++) {
5359
const source = dataSourceTypes[i];
5460
// must match on type
55-
if (source.meta.id !== this.state.query) {
61+
if (source.meta.id !== this.state.pluginId) {
5662
continue;
5763
}
5864

0 commit comments

Comments
 (0)