Commit 2f18444a by Torkel Ödegaard

Graphite: alt node suggestions will now not include wildcard or template…

Graphite: alt node suggestions will now not include wildcard or template variables if the node is empty, Closes #1230
parent 8a4ff5bd
......@@ -162,6 +162,11 @@ function (angular, _, config, gfunc, Parser) {
return new MetricSegment({ value: segment.text, expandable: segment.expandable });
});
if ($scope.altSegments.length === 0) {
return;
}
// add template variables
_.each(templateSrv.variables, function(variable) {
$scope.altSegments.unshift(new MetricSegment({
type: 'template',
......@@ -170,6 +175,7 @@ function (angular, _, config, gfunc, Parser) {
}));
});
// add wildcard option
$scope.altSegments.unshift(new MetricSegment('*'));
})
.then(null, function(err) {
......
......@@ -136,6 +136,22 @@ define([
});
});
describe('when getting altSegments and metricFindQuery retuns empty array', function() {
beforeEach(function() {
ctx.scope.target.target = 'test.count';
ctx.scope.datasource.metricFindQuery.returns(ctx.$q.when([]));
ctx.scope.init();
ctx.scope.getAltSegments(1);
ctx.scope.$digest();
ctx.scope.$parent = { get_data: sinon.spy() };
});
it('should have no segments', function() {
expect(ctx.scope.altSegments.length).to.be(0);
});
});
describe('targetChanged', function() {
beforeEach(function() {
ctx.scope.datasource.metricFindQuery.returns(ctx.$q.when([{expandable: false}]));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment