* TestData: Interpolate variables in more fields
* only interpolate variables if the field is set
* Correctly type scenarioId which can be undefined
(cherry picked from commit b857f8339e)
Co-authored-by: Josh Hunt <joshhunt@users.noreply.github.com>
This commit is contained in:
co-authored by
Josh Hunt
parent
5965a7e479
commit
ec1ae002ea
+1
-1
@@ -161,7 +161,7 @@ export const QueryEditor = ({ query, datasource, onChange, onRunQuery }: Props)
|
||||
.sort((a, b) => a.label.localeCompare(b.label)),
|
||||
[scenarioList]
|
||||
);
|
||||
const showLabels = useMemo(() => showLabelsFor.includes(query.scenarioId), [query]);
|
||||
const showLabels = useMemo(() => showLabelsFor.includes(query.scenarioId ?? ''), [query]);
|
||||
|
||||
if (loading) {
|
||||
return null;
|
||||
|
||||
+23
-7
@@ -81,10 +81,6 @@ export class TestDataDataSource extends DataSourceWithBackend<TestDataQuery> {
|
||||
}
|
||||
|
||||
default:
|
||||
if (target.alias) {
|
||||
target.alias = this.templateSrv.replace(target.alias, options.scopedVars);
|
||||
}
|
||||
|
||||
backendQueries.push(target);
|
||||
}
|
||||
}
|
||||
@@ -105,7 +101,24 @@ export class TestDataDataSource extends DataSourceWithBackend<TestDataQuery> {
|
||||
}
|
||||
|
||||
resolveTemplateVariables(query: TestDataQuery, scopedVars: ScopedVars) {
|
||||
query.labels = this.templateSrv.replace(query.labels!, scopedVars);
|
||||
if (query.labels) {
|
||||
query.labels = this.templateSrv.replace(query.labels, scopedVars);
|
||||
}
|
||||
if (query.alias) {
|
||||
query.alias = this.templateSrv.replace(query.alias, scopedVars);
|
||||
}
|
||||
if (query.scenarioId) {
|
||||
query.scenarioId = this.templateSrv.replace(query.scenarioId, scopedVars);
|
||||
}
|
||||
if (query.stringInput) {
|
||||
query.stringInput = this.templateSrv.replace(query.stringInput, scopedVars);
|
||||
}
|
||||
if (query.csvContent) {
|
||||
query.csvContent = this.templateSrv.replace(query.csvContent, scopedVars);
|
||||
}
|
||||
if (query.rawFrameContent) {
|
||||
query.rawFrameContent = this.templateSrv.replace(query.rawFrameContent, scopedVars);
|
||||
}
|
||||
}
|
||||
|
||||
annotationDataTopicTest(target: TestDataQuery, req: DataQueryRequest<TestDataQuery>): Observable<DataQueryResponse> {
|
||||
@@ -139,10 +152,13 @@ export class TestDataDataSource extends DataSourceWithBackend<TestDataQuery> {
|
||||
}
|
||||
|
||||
getQueryDisplayText(query: TestDataQuery) {
|
||||
const scenario = query.scenarioId ?? 'Default scenario';
|
||||
|
||||
if (query.alias) {
|
||||
return query.scenarioId + ' as ' + query.alias;
|
||||
return scenario + ' as ' + query.alias;
|
||||
}
|
||||
return query.scenarioId;
|
||||
|
||||
return scenario;
|
||||
}
|
||||
|
||||
testDatasource() {
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ export interface Scenario {
|
||||
|
||||
export interface TestDataQuery extends DataQuery {
|
||||
alias?: string;
|
||||
scenarioId: string;
|
||||
scenarioId?: string;
|
||||
stringInput?: string;
|
||||
stream?: StreamingQuery;
|
||||
pulseWave?: PulseWaveQuery;
|
||||
|
||||
Reference in New Issue
Block a user