mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* tech: investigating karma + jest mix * tech: migrating tests to jest * tech: moved anoter test file to jest * test: migrated two more test files to jest * test: updated readme and made test fail to verify that it causes CI build failure * tech: added code coverage for jest tests * tech: testing codecov coverage * tech: migrated more tests * tech: migrated template srv to typescript and the tests to jest * tech: minor build fix * tech: build fixes * build: another attempt at fixing go test with coverage
36 lines
764 B
TypeScript
36 lines
764 B
TypeScript
import kbn from 'app/core/utils/kbn';
|
|
import {assignModelProperties} from 'app/core/utils/model_utils';
|
|
|
|
export interface Variable {
|
|
setValue(option);
|
|
updateOptions();
|
|
dependsOn(variable);
|
|
setValueFromUrl(urlValue);
|
|
getValueForUrl();
|
|
getSaveModel();
|
|
}
|
|
|
|
export var variableTypes = {};
|
|
export {
|
|
assignModelProperties
|
|
};
|
|
|
|
export function containsVariable(...args: any[]) {
|
|
var variableName = args[args.length-1];
|
|
var str = args[0] || '';
|
|
|
|
for (var i = 1; i < args.length-1; i++) {
|
|
str += ' ' + args[i] || '';
|
|
}
|
|
|
|
variableName = kbn.regexEscape(variableName);
|
|
var findVarRegex = new RegExp('\\$(' + variableName + ')(?:\\W|$)|\\[\\[(' + variableName + ')\\]\\]', 'g');
|
|
var match = findVarRegex.exec(str);
|
|
return match !== null;
|
|
}
|
|
|
|
|
|
|
|
|
|
|