Variable query editor (#856)

* refactor: convert module to typescript

* refactor: covert utils to typescript

* variable query editor WIP

* variable editor: fix type error after grafana/ui update

* variable editor: use FormLabel from grafana/ui

* variable editor: refactor

* variable editor: input validation and highlights

* variable editor: fix tests

* variable query: fix backward compatibility with empty queries

* fix linter errors

* variable editor: fix variable replacement in queries
This commit is contained in:
Alexander Zobnin
2020-01-13 11:31:40 +03:00
committed by GitHub
parent 4f24b2bf23
commit 82cfda6524
11 changed files with 519 additions and 78 deletions

View File

@@ -231,7 +231,7 @@ describe('ZabbixDatasource', () => {
});
});
describe('When invoking metricFindQuery()', () => {
describe('When invoking metricFindQuery() with legacy query', () => {
beforeEach(() => {
ctx.ds.replaceTemplateVars = (str) => str;
ctx.ds.zabbix = {
@@ -245,7 +245,6 @@ describe('ZabbixDatasource', () => {
it('should return groups', (done) => {
const tests = [
{query: '*', expect: '/.*/'},
{query: '', expect: ''},
{query: 'Backend', expect: 'Backend'},
{query: 'Back*', expect: 'Back*'},
];
@@ -258,6 +257,16 @@ describe('ZabbixDatasource', () => {
done();
});
it('should return empty list for empty query', (done) => {
ctx.ds.metricFindQuery('').then(result => {
expect(ctx.ds.zabbix.getGroups).toBeCalledTimes(0);
ctx.ds.zabbix.getGroups.mockClear();
expect(result).toEqual([]);
done();
});
});
it('should return hosts', (done) => {
const tests = [
{query: '*.*', expect: ['/.*/', '/.*/']},