mirror of
https://github.com/grafana/grafana.git
synced 2025-01-02 12:17:01 -06:00
QueryRunners: Bind the query function where it is passed on (#73399)
This commit is contained in:
parent
0815d7f627
commit
f6f47678a4
@ -196,7 +196,7 @@ describe('QueryRunners', () => {
|
||||
|
||||
it('then it should call runRequest with correct args', () => {
|
||||
expect(runRequest).toHaveBeenCalledTimes(1);
|
||||
expect(runRequest).toHaveBeenCalledWith(datasource, {}, datasource.variables.query);
|
||||
expect(runRequest).toHaveBeenCalledWith(datasource, {}, expect.anything());
|
||||
});
|
||||
});
|
||||
|
||||
@ -263,7 +263,7 @@ describe('QueryRunners', () => {
|
||||
|
||||
it('then it should call runRequest with correct args', () => {
|
||||
expect(runRequest).toHaveBeenCalledTimes(1);
|
||||
expect(runRequest).toHaveBeenCalledWith(datasource, {}, datasource.variables.query);
|
||||
expect(runRequest).toHaveBeenCalledWith(datasource, {}, expect.anything());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -122,7 +122,7 @@ class StandardQueryRunner implements QueryRunner {
|
||||
return runRequest(datasource, request);
|
||||
}
|
||||
|
||||
return runRequest(datasource, request, datasource.variables.query);
|
||||
return runRequest(datasource, request, datasource.variables.query.bind(datasource.variables));
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ class CustomQueryRunner implements QueryRunner {
|
||||
return getEmptyMetricFindValueObservable();
|
||||
}
|
||||
|
||||
return runRequest(datasource, request, datasource.variables.query);
|
||||
return runRequest(datasource, request, datasource.variables.query.bind(datasource.variables));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,6 @@ export class VariableSupport extends CustomVariableSupport<DataSource, AzureMoni
|
||||
constructor(private readonly datasource: DataSource) {
|
||||
super();
|
||||
this.datasource = datasource;
|
||||
this.query = this.query.bind(this);
|
||||
this.templateSrv = getTemplateSrv();
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,6 @@ export class CloudMonitoringVariableSupport extends CustomVariableSupport<
|
||||
constructor(private readonly datasource: CloudMonitoringDatasource) {
|
||||
super();
|
||||
this.metricFindQuery = new CloudMonitoringMetricFindQuery(datasource);
|
||||
this.query = this.query.bind(this);
|
||||
}
|
||||
|
||||
editor = CloudMonitoringVariableQueryEditor;
|
||||
|
@ -21,7 +21,6 @@ import { VariableQuery, VariableQueryType } from './types';
|
||||
export class CloudWatchVariableSupport extends CustomVariableSupport<CloudWatchDatasource, VariableQuery> {
|
||||
constructor(private readonly resources: ResourcesAPI) {
|
||||
super();
|
||||
this.query = this.query.bind(this);
|
||||
}
|
||||
|
||||
editor = VariableQueryEditor;
|
||||
|
@ -20,8 +20,6 @@ export class VariableSupport extends CustomVariableSupport<PhlareDataSource> {
|
||||
private readonly timeSrv: TimeSrv = getTimeSrv()
|
||||
) {
|
||||
super();
|
||||
// This is needed because code in queryRunners.ts passes this method without binding it.
|
||||
this.query = this.query.bind(this);
|
||||
}
|
||||
|
||||
editor = VariableQueryEditor;
|
||||
|
@ -12,7 +12,6 @@ export class LokiVariableSupport extends CustomVariableSupport<LokiDatasource, L
|
||||
|
||||
constructor(private datasource: LokiDatasource) {
|
||||
super();
|
||||
this.query = this.query.bind(this);
|
||||
}
|
||||
|
||||
async execute(query: LokiVariableQuery) {
|
||||
|
@ -18,7 +18,6 @@ export class PrometheusVariableSupport extends CustomVariableSupport<PrometheusD
|
||||
private readonly timeSrv: TimeSrv = getTimeSrv()
|
||||
) {
|
||||
super();
|
||||
this.query = this.query.bind(this);
|
||||
}
|
||||
|
||||
editor = PromVariableQueryEditor;
|
||||
|
@ -11,7 +11,6 @@ export class TempoVariableSupport extends CustomVariableSupport<TempoDatasource,
|
||||
|
||||
constructor(private datasource: TempoDatasource) {
|
||||
super();
|
||||
this.query = this.query.bind(this);
|
||||
}
|
||||
|
||||
query(request: DataQueryRequest<TempoVariableQuery>): Observable<DataQueryResponse> {
|
||||
|
Loading…
Reference in New Issue
Block a user