diff options
author | Jose Ivan Vargas <jvargas@gitlab.com> | 2018-07-17 20:44:26 +0000 |
---|---|---|
committer | Clement Ho <clemmakesapps@gmail.com> | 2018-07-17 20:44:26 +0000 |
commit | 236e752bfbb140b5cbe03f500b479eacdc7f98e0 (patch) | |
tree | 5bf86aa5887278eaf93a855b5b7642c0a4cdb2e2 | |
parent | 2f16eab03d8af372ae8461de5abf91b480ffd761 (diff) | |
download | gitlab-ce-236e752bfbb140b5cbe03f500b479eacdc7f98e0.tar.gz |
Resolve "Metrics drop down doesn't show all environment, some not clickable"
-rw-r--r-- | app/assets/javascripts/monitoring/stores/monitoring_store.js | 9 | ||||
-rw-r--r-- | spec/javascripts/monitoring/mock_data.js | 17 | ||||
-rw-r--r-- | spec/javascripts/monitoring/monitoring_store_spec.js | 7 |
3 files changed, 30 insertions, 3 deletions
diff --git a/app/assets/javascripts/monitoring/stores/monitoring_store.js b/app/assets/javascripts/monitoring/stores/monitoring_store.js index 748b8cb6e6e..176f7d9eef2 100644 --- a/app/assets/javascripts/monitoring/stores/monitoring_store.js +++ b/app/assets/javascripts/monitoring/stores/monitoring_store.js @@ -1,7 +1,10 @@ import _ from 'underscore'; function sortMetrics(metrics) { - return _.chain(metrics).sortBy('title').sortBy('weight').value(); + return _.chain(metrics) + .sortBy('title') + .sortBy('weight') + .value(); } function normalizeMetrics(metrics) { @@ -39,7 +42,9 @@ export default class MonitoringStore { } storeEnvironmentsData(environmentsData = []) { - this.environmentsData = environmentsData; + this.environmentsData = environmentsData.filter( + environment => !!environment.latest.last_deployment, + ); } getMetricsCount() { diff --git a/spec/javascripts/monitoring/mock_data.js b/spec/javascripts/monitoring/mock_data.js index 10808315372..e4c98a3bcb5 100644 --- a/spec/javascripts/monitoring/mock_data.js +++ b/spec/javascripts/monitoring/mock_data.js @@ -6561,6 +6561,9 @@ export const environmentData = [ folder_path: '/root/hello-prometheus/environments/folders/production', created_at: '2018-06-29T16:53:38.301Z', updated_at: '2018-06-29T16:57:09.825Z', + last_deployment: { + id: 127, + }, }, }, { @@ -6580,6 +6583,20 @@ export const environmentData = [ folder_path: '/root/hello-prometheus/environments/folders/review', created_at: '2018-07-03T18:39:41.702Z', updated_at: '2018-07-03T18:44:54.010Z', + last_deployment: { + id: 128, + }, + }, + }, + { + name: 'no-deployment', + size: 1, + latest: { + id: 36, + name: 'no-deployment/noop-branch', + state: 'available', + created_at: '2018-07-04T18:39:41.702Z', + updated_at: '2018-07-04T18:44:54.010Z', }, }, ]; diff --git a/spec/javascripts/monitoring/monitoring_store_spec.js b/spec/javascripts/monitoring/monitoring_store_spec.js index 08d54946787..ccdf4eda563 100644 --- a/spec/javascripts/monitoring/monitoring_store_spec.js +++ b/spec/javascripts/monitoring/monitoring_store_spec.js @@ -1,5 +1,5 @@ import MonitoringStore from '~/monitoring/stores/monitoring_store'; -import MonitoringMock, { deploymentData } from './mock_data'; +import MonitoringMock, { deploymentData, environmentData } from './mock_data'; describe('MonitoringStore', function () { this.store = new MonitoringStore(); @@ -21,4 +21,9 @@ describe('MonitoringStore', function () { expect(this.store.deploymentData.length).toEqual(3); expect(typeof this.store.deploymentData[0]).toEqual('object'); }); + + it('only stores environment data that contains deployments', () => { + this.store.storeEnvironmentsData(environmentData); + expect(this.store.environmentsData.length).toEqual(2); + }); }); |