mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
DashboardScene: Reset query variable query and definition on datasource change (#84347)
reset query variable query and definition on datasource change
This commit is contained in:
parent
c0933fa6bb
commit
c0d0f13a8d
@ -152,6 +152,8 @@ describe('QueryVariableEditor', () => {
|
||||
});
|
||||
|
||||
expect(variable.state.datasource).toEqual({ uid: 'mock-ds-3', type: 'prometheus' });
|
||||
expect(variable.state.query).toBe('');
|
||||
expect(variable.state.definition).toBe('');
|
||||
});
|
||||
|
||||
it('should update the variable state when changing the query', async () => {
|
||||
|
@ -36,6 +36,12 @@ export function QueryVariableEditor({ variable, onRunQuery }: QueryVariableEdito
|
||||
};
|
||||
const onDataSourceChange = (dsInstanceSettings: DataSourceInstanceSettings) => {
|
||||
const datasource: DataSourceRef = { uid: dsInstanceSettings.uid, type: dsInstanceSettings.type };
|
||||
|
||||
if (variable.state.datasource && variable.state.datasource.type !== datasource.type) {
|
||||
variable.setState({ datasource, query: '', definition: '' });
|
||||
return;
|
||||
}
|
||||
|
||||
variable.setState({ datasource });
|
||||
};
|
||||
const onQueryChange = (query: VariableQueryType) => {
|
||||
|
Loading…
Reference in New Issue
Block a user