Commit faee8a34 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas Committed by Clement Ho

Resolve "Environments dropdown is showing on the cluster health page"

parent 3549ee7a
...@@ -98,6 +98,11 @@ export default { ...@@ -98,6 +98,11 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
showEnvironmentDropdown: {
type: Boolean,
required: false,
default: true,
},
}, },
data() { data() {
return { return {
...@@ -126,9 +131,25 @@ export default { ...@@ -126,9 +131,25 @@ export default {
}, },
mounted() { mounted() {
this.resizeThrottled = _.throttle(this.resize, 600); this.resizeThrottled = _.throttle(this.resize, 600);
this.servicePromises = [
this.service
.getGraphsData()
.then(data => this.store.storeMetrics(data))
.catch(() => Flash(s__('Metrics|There was an error while retrieving metrics'))),
this.service
.getDeploymentData()
.then(data => this.store.storeDeploymentData(data))
.catch(() => Flash(s__('Metrics|There was an error getting deployment information.'))),
];
if (!this.hasMetrics) { if (!this.hasMetrics) {
this.state = 'gettingStarted'; this.state = 'gettingStarted';
} else { } else {
if (this.showEnvironmentDropdown) {
this.servicePromises.push(this.service
.getEnvironmentsData()
.then((data) => this.store.storeEnvironmentsData(data))
.catch(() => Flash(s__('Metrics|There was an error getting environments information.'))));
}
this.getGraphsData(); this.getGraphsData();
window.addEventListener('resize', this.resizeThrottled, false); window.addEventListener('resize', this.resizeThrottled, false);
} }
...@@ -136,17 +157,7 @@ export default { ...@@ -136,17 +157,7 @@ export default {
methods: { methods: {
getGraphsData() { getGraphsData() {
this.state = 'loading'; this.state = 'loading';
Promise.all([ Promise.all(this.servicePromises)
this.service.getGraphsData().then(data => this.store.storeMetrics(data)),
this.service
.getDeploymentData()
.then(data => this.store.storeDeploymentData(data))
.catch(() => Flash(s__('Metrics|There was an error getting deployment information.'))),
this.service
.getEnvironmentsData()
.then(data => this.store.storeEnvironmentsData(data))
.catch(() => Flash(s__('Metrics|There was an error getting environments information.'))),
])
.then(() => { .then(() => {
if (this.store.groups.length < 1) { if (this.store.groups.length < 1) {
this.state = 'noData'; this.state = 'noData';
...@@ -180,7 +191,10 @@ export default { ...@@ -180,7 +191,10 @@ export default {
v-if="!showEmptyState" v-if="!showEmptyState"
class="prometheus-graphs prepend-top-10" class="prometheus-graphs prepend-top-10"
> >
<div class="environments d-flex align-items-center"> <div
v-if="showEnvironmentDropdown"
class="environments d-flex align-items-center"
>
{{ s__('Metrics|Environment') }} {{ s__('Metrics|Environment') }}
<div class="dropdown prepend-left-10"> <div class="dropdown prepend-left-10">
<button <button
......
...@@ -15,6 +15,9 @@ export default () => { ...@@ -15,6 +15,9 @@ export default () => {
showLegend: false, showLegend: false,
showPanels: false, showPanels: false,
forceSmallGraph: true, forceSmallGraph: true,
showEnvironmentDropdown: false,
currentEnvironmentName: '',
environmentsEndpoint: '',
}, },
}); });
}, },
......
---
title: Resolve Environments dropdown is showing on the cluster health page
merge_request: 6528
author:
type: fixed
...@@ -4107,6 +4107,9 @@ msgstr "" ...@@ -4107,6 +4107,9 @@ msgstr ""
msgid "Metrics|There was an error getting environments information." msgid "Metrics|There was an error getting environments information."
msgstr "" msgstr ""
msgid "Metrics|There was an error while retrieving metrics"
msgstr ""
msgid "Metrics|Type" msgid "Metrics|Type"
msgstr "" msgstr ""
......
...@@ -126,5 +126,23 @@ describe('Dashboard', () => { ...@@ -126,5 +126,23 @@ describe('Dashboard', () => {
done(); done();
}); });
}); });
it('hides the dropdown', done => {
const component = new DashboardComponent({
el: document.querySelector('.prometheus-graphs'),
propsData: {
...propsData,
hasMetrics: true,
showPanels: false,
showEnvironmentDropdown: false,
},
});
Vue.nextTick(() => {
const dropdownIsActiveElement = component.$el.querySelectorAll('.environments');
expect(dropdownIsActiveElement.length).toEqual(0);
done();
});
});
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment