From 976f1feb28265bfc427a00e7031275f49aa7f877 Mon Sep 17 00:00:00 2001 From: Jose Vargas Date: Wed, 3 Apr 2019 16:10:39 -0600 Subject: Document getTimeDifferenceMinutes usage Also added a finally clause to the getGraphsDataWithTime promise --- app/assets/javascripts/monitoring/components/dashboard.vue | 5 +++-- app/assets/javascripts/monitoring/utils.js | 6 ++++++ spec/javascripts/monitoring/dashboard_spec.js | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/monitoring/components/dashboard.vue b/app/assets/javascripts/monitoring/components/dashboard.vue index 529f82b4ae1..d7055097a63 100644 --- a/app/assets/javascripts/monitoring/components/dashboard.vue +++ b/app/assets/javascripts/monitoring/components/dashboard.vue @@ -178,11 +178,12 @@ export default { .then(data => { this.store.storeMetrics(data); this.selectedTimeWindow = this.timeWindows[timeFrame]; - this.showEmptyState = false; }) .catch(() => { - this.showEmptyState = false; Flash(s__('Metrics|Not enough data to display')); + }) + .finally(() => { + this.showEmptyState = false; }); }, onSidebarMutation() { diff --git a/app/assets/javascripts/monitoring/utils.js b/app/assets/javascripts/monitoring/utils.js index b01bee66d9e..e379827b769 100644 --- a/app/assets/javascripts/monitoring/utils.js +++ b/app/assets/javascripts/monitoring/utils.js @@ -1,5 +1,11 @@ import { timeWindows, msPerMinute } from './constants'; +/** + * method that converts a predetermined time window to minutes + * defaults to 8 hours as the default option + * @param {String} timeWindow - The time window to convert to minutes + * @returns {number} The time window in minutes + */ const getTimeDifferenceMinutes = timeWindow => { switch (timeWindow) { case timeWindows.thirtyMinutes: diff --git a/spec/javascripts/monitoring/dashboard_spec.js b/spec/javascripts/monitoring/dashboard_spec.js index 1436bcb466e..ce2c6c43c0f 100644 --- a/spec/javascripts/monitoring/dashboard_spec.js +++ b/spec/javascripts/monitoring/dashboard_spec.js @@ -224,7 +224,7 @@ describe('Dashboard', () => { }); }); - it('rewnders the time window dropdown with a set of options', done => { + it('renders the time window dropdown with a set of options', done => { const component = new DashboardComponent({ el: document.querySelector('.prometheus-graphs'), propsData: { -- cgit v1.2.1