diff --git a/app/assets/javascripts/monitoring/stores/monitoring_store.js b/app/assets/javascripts/monitoring/stores/monitoring_store.js index 541c8e7dd46..47ac8c5ff78 100644 --- a/app/assets/javascripts/monitoring/stores/monitoring_store.js +++ b/app/assets/javascripts/monitoring/stores/monitoring_store.js @@ -1,5 +1,7 @@ import _ from 'underscore'; +const sortMetrics = metrics => _.chain(metrics).sortBy('weight').sortBy('title').value(); + class MonitoringStore { constructor() { this.groups = []; @@ -43,12 +45,10 @@ class MonitoringStore { } storeMetrics(groups = []) { - this.groups = groups.map((group) => { - const currentGroup = group; - currentGroup.metrics = _.chain(group.metrics).sortBy('weight').sortBy('title').value(); - currentGroup.metrics = this.createArrayRows(currentGroup.metrics); - return currentGroup; - }); + this.groups = groups.map(group => ({ + ...group, + metrics: this.createArrayRows(sortMetrics(group.metrics)), + })); } storeDeploymentData(deploymentData = []) {