grafana/public/app/features/variables/shared/testing/datasourceVariableBuilder.ts
Josh Hunt eaf6aea98f
Typed variables pt1: Use discriminated union for variable model (#52981)
* wip

* make diff easier to read

* Update template_srv getVariables to return new TypedVariableModel

* update VariableType to use the type from TypedVariableModel

* tidy things up
2022-08-02 10:15:25 +01:00

18 lines
490 B
TypeScript

import { DataSourceVariableModel, QueryVariableModel, VariableRefresh } from 'app/features/variables/types';
import { MultiVariableBuilder } from './multiVariableBuilder';
export class DatasourceVariableBuilder<
T extends DataSourceVariableModel | QueryVariableModel
> extends MultiVariableBuilder<T> {
withRefresh(refresh: VariableRefresh) {
this.variable.refresh = refresh;
return this;
}
withRegEx(regex: any) {
this.variable.regex = regex;
return this;
}
}