Commit 8270be8a authored by Peter Leitzen's avatar Peter Leitzen Committed by Mike Greiling

Resolve "No longer require a deploy to start Prometheus monitoring"

parent 91765b80
...@@ -149,7 +149,7 @@ export default { ...@@ -149,7 +149,7 @@ export default {
.catch(() => Flash(s__('Metrics|There was an error getting deployment information.'))), .catch(() => Flash(s__('Metrics|There was an error getting deployment information.'))),
this.service this.service
.getEnvironmentsData() .getEnvironmentsData()
.then((data) => this.store.storeEnvironmentsData(data)) .then(data => this.store.storeEnvironmentsData(data))
.catch(() => Flash(s__('Metrics|There was an error getting environments information.'))), .catch(() => Flash(s__('Metrics|There was an error getting environments information.'))),
]) ])
.then(() => { .then(() => {
...@@ -157,6 +157,7 @@ export default { ...@@ -157,6 +157,7 @@ export default {
this.state = 'noData'; this.state = 'noData';
return; return;
} }
this.showEmptyState = false; this.showEmptyState = false;
}) })
.then(this.resize) .then(this.resize)
...@@ -195,7 +196,10 @@ export default { ...@@ -195,7 +196,10 @@ export default {
name="chevron-down" name="chevron-down"
/> />
</button> </button>
<div class="dropdown-menu dropdown-menu-selectable dropdown-menu-drop-up"> <div
v-if="store.environmentsData.length > 0"
class="dropdown-menu dropdown-menu-selectable dropdown-menu-drop-up"
>
<ul> <ul>
<li <li
v-for="environment in store.environmentsData" v-for="environment in store.environmentsData"
......
...@@ -149,7 +149,7 @@ class Environment < ActiveRecord::Base ...@@ -149,7 +149,7 @@ class Environment < ActiveRecord::Base
end end
def has_metrics? def has_metrics?
prometheus_adapter&.can_query? && available? && last_deployment.present? prometheus_adapter&.can_query? && available?
end end
def metrics def metrics
......
---
title: No longer require a deploy to start Prometheus monitoring
merge_request: 22401
author:
type: changed
...@@ -113,6 +113,22 @@ describe('Dashboard', () => { ...@@ -113,6 +113,22 @@ describe('Dashboard', () => {
}); });
}); });
it('hides the dropdown list when there is no environments', done => {
const component = new DashboardComponent({
el: document.querySelector('.prometheus-graphs'),
propsData: { ...propsData, hasMetrics: true, showPanels: false },
});
component.store.storeEnvironmentsData([]);
setTimeout(() => {
const dropdownMenuEnvironments = component.$el.querySelectorAll('.dropdown-menu ul');
expect(dropdownMenuEnvironments.length).toEqual(0);
done();
});
});
it('renders the dropdown with a single is-active element', done => { it('renders the dropdown with a single is-active element', done => {
const component = new DashboardComponent({ const component = new DashboardComponent({
el: document.querySelector('.prometheus-graphs'), el: document.querySelector('.prometheus-graphs'),
......
...@@ -334,7 +334,7 @@ describe Environment do ...@@ -334,7 +334,7 @@ describe Environment do
describe '#has_terminals?' do describe '#has_terminals?' do
subject { environment.has_terminals? } subject { environment.has_terminals? }
context 'when the enviroment is available' do context 'when the environment is available' do
context 'with a deployment service' do context 'with a deployment service' do
shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
context 'and a deployment' do context 'and a deployment' do
...@@ -447,7 +447,7 @@ describe Environment do ...@@ -447,7 +447,7 @@ describe Environment do
describe '#has_metrics?' do describe '#has_metrics?' do
subject { environment.has_metrics? } subject { environment.has_metrics? }
context 'when the enviroment is available' do context 'when the environment is available' do
context 'with a deployment service' do context 'with a deployment service' do
let(:project) { create(:prometheus_project) } let(:project) { create(:prometheus_project) }
...@@ -456,8 +456,8 @@ describe Environment do ...@@ -456,8 +456,8 @@ describe Environment do
it { is_expected.to be_truthy } it { is_expected.to be_truthy }
end end
context 'but no deployments' do context 'and no deployments' do
it { is_expected.to be_falsy } it { is_expected.to be_truthy }
end end
end end
...@@ -504,39 +504,6 @@ describe Environment do ...@@ -504,39 +504,6 @@ describe Environment do
end end
end end
describe '#has_metrics?' do
subject { environment.has_metrics? }
context 'when the enviroment is available' do
context 'with a deployment service' do
let(:project) { create(:prometheus_project) }
context 'and a deployment' do
let!(:deployment) { create(:deployment, environment: environment) }
it { is_expected.to be_truthy }
end
context 'but no deployments' do
it { is_expected.to be_falsy }
end
end
context 'without a monitoring service' do
it { is_expected.to be_falsy }
end
end
context 'when the environment is unavailable' do
let(:project) { create(:prometheus_project) }
before do
environment.stop
end
it { is_expected.to be_falsy }
end
end
describe '#additional_metrics' do describe '#additional_metrics' do
let(:project) { create(:prometheus_project) } let(:project) { create(:prometheus_project) }
subject { environment.additional_metrics } subject { environment.additional_metrics }
......
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