Skip to content

Commit 9184819

Browse files
committed
fix(metricsegment): fixed issue with metric segment, fixes grafana#6212
1 parent 913f17e commit 9184819

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

public/app/core/directives/metric_segment.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function (_, $, coreModule) {
4343
var selected = _.find($scope.altSegments, {value: value});
4444
if (selected) {
4545
segment.value = selected.value;
46-
segment.html = selected.html;
46+
segment.html = selected.html || selected.value;
4747
segment.fake = false;
4848
segment.expandable = selected.expandable;
4949
}
@@ -186,27 +186,26 @@ function (_, $, coreModule) {
186186

187187
$scope.getOptionsInternal = function() {
188188
if ($scope.options) {
189-
cachedOptions = _.map($scope.options, function(option) {
190-
return uiSegmentSrv.newSegment({value: option.text});
191-
});
192-
return $q.when(cachedOptions);
189+
cachedOptions = $scope.options;
190+
return $q.when(_.map($scope.options, function(option) {
191+
return {value: option.text};
192+
}));
193193
} else {
194194
return $scope.getOptions().then(function(options) {
195-
cachedOptions =_.map(options, function(option) {
195+
cachedOptions = options;
196+
return _.map(options, function(option) {
196197
if (option.html) {
197198
return option;
198199
}
199-
return uiSegmentSrv.newSegment({value: option.text});
200+
return {value: option.text};
200201
});
201-
return cachedOptions;
202202
});
203203
}
204204
};
205205

206206
$scope.onSegmentChange = function() {
207-
208207
if (cachedOptions) {
209-
var option = _.find(cachedOptions, {value: $scope.segment.value});
208+
var option = _.find(cachedOptions, {text: $scope.segment.value});
210209
if (option && option.value !== $scope.property) {
211210
$scope.property = option.value;
212211
} else if (attrs.custom !== 'false') {

0 commit comments

Comments
 (0)