mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Graphite: alt node suggestions will now not include wildcard or template variables if the node is empty, Closes #1230
This commit is contained in:
@@ -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}]));
|
||||
|
||||
Reference in New Issue
Block a user