Commit 06847b2a authored by Mike Greiling's avatar Mike Greiling

Merge branch '45068-no-longer-require-a-deploy-to-start-prometheus-monitoring' into 'master'

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

Closes #45068

See merge request gitlab-org/gitlab-ce!22401
parents 91765b80 8270be8a
......@@ -149,7 +149,7 @@ export default {
.catch(() => Flash(s__('Metrics|There was an error getting deployment information.'))),
this.service
.getEnvironmentsData()
.then((data) => this.store.storeEnvironmentsData(data))
.then(data => this.store.storeEnvironmentsData(data))
.catch(() => Flash(s__('Metrics|There was an error getting environments information.'))),
])
.then(() => {
......@@ -157,6 +157,7 @@ export default {
this.state = 'noData';
return;
}
this.showEmptyState = false;
})
.then(this.resize)
......@@ -195,7 +196,10 @@ export default {
name="chevron-down"
/>
</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>
<li
v-for="environment in store.environmentsData"
......
......@@ -149,7 +149,7 @@ class Environment < ActiveRecord::Base
end
def has_metrics?
prometheus_adapter&.can_query? && available? && last_deployment.present?
prometheus_adapter&.can_query? && available?
end
def metrics
......
---
title: No longer require a deploy to start Prometheus monitoring
merge_request: 22401
author:
type: changed
......@@ -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 => {
const component = new DashboardComponent({
el: document.querySelector('.prometheus-graphs'),
......
......@@ -334,7 +334,7 @@ describe Environment do
describe '#has_terminals?' do
subject { environment.has_terminals? }
context 'when the enviroment is available' do
context 'when the environment is available' do
context 'with a deployment service' do
shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
context 'and a deployment' do
......@@ -447,7 +447,7 @@ describe Environment do
describe '#has_metrics?' do
subject { environment.has_metrics? }
context 'when the enviroment is available' do
context 'when the environment is available' do
context 'with a deployment service' do
let(:project) { create(:prometheus_project) }
......@@ -456,8 +456,8 @@ describe Environment do
it { is_expected.to be_truthy }
end
context 'but no deployments' do
it { is_expected.to be_falsy }
context 'and no deployments' do
it { is_expected.to be_truthy }
end
end
......@@ -504,39 +504,6 @@ describe Environment do
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
let(:project) { create(:prometheus_project) }
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