Commit db16d149 authored by Tristan Read's avatar Tristan Read Committed by Lin Jen-Shin

Move alert management behind a feature flag

parent d43df1b7
# frozen_string_literal: true # frozen_string_literal: true
class Projects::AlertManagementController < Projects::ApplicationController class Projects::AlertManagementController < Projects::ApplicationController
before_action :ensure_feature_enabled
def index def index
respond_to do |format| end
format.html
end private
def ensure_feature_enabled
render_404 unless Feature.enabled?(:alert_management_minimal, project)
end end
end end
...@@ -222,12 +222,14 @@ ...@@ -222,12 +222,14 @@
%span %span
= _('Metrics') = _('Metrics')
- if project_nav_tab?(:alert_management) - if Feature.enabled?(:alert_management_minimal, @project)
= nav_link(controller: :alert_management) do - if project_nav_tab?(:alert_management)
= link_to project_alert_management_index_path(@project), title: _('Alerts'), class: 'shortcuts-tracking qa-operations-tracking-link' do = nav_link(controller: :alert_management) do
%span = link_to project_alert_management_index_path(@project), title: _('Alerts'), class: 'shortcuts-tracking qa-operations-tracking-link' do
= _('Alerts') %span
= _('Alerts')
- if project_nav_tab? :environments
= render_if_exists "layouts/nav/sidebar/tracing_link" = render_if_exists "layouts/nav/sidebar/tracing_link"
= nav_link(controller: :environments, action: [:index, :folder, :show, :new, :edit, :create, :update, :stop, :terminal]) do = nav_link(controller: :environments, action: [:index, :folder, :show, :new, :edit, :create, :update, :stop, :terminal]) do
......
---
title: Move alert management behind a feature flag
merge_request: 30133
author:
type: fixed
# frozen_string_literal: true
require 'spec_helper'
describe Projects::AlertManagementController do
let_it_be(:project) { create(:project) }
let_it_be(:role) { :reporter }
let_it_be(:user) { create(:user) }
before do
project.add_role(user, role)
sign_in(user)
end
describe 'GET #index' do
context 'when alert_management_minimal is enabled' do
before do
stub_feature_flags(alert_management_minimal: true)
end
it 'shows the page' do
get :index, params: { namespace_id: project.namespace, project_id: project }
expect(response).to have_gitlab_http_status(:ok)
end
end
context 'when alert_management_minimal is disabled' do
before do
stub_feature_flags(alert_management_minimal: false)
end
it 'shows 404' do
get :index, params: { namespace_id: project.namespace, project_id: project }
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
end
...@@ -136,27 +136,55 @@ describe 'layouts/nav/sidebar/_project' do ...@@ -136,27 +136,55 @@ describe 'layouts/nav/sidebar/_project' do
end end
describe 'operations settings tab' do describe 'operations settings tab' do
before do describe 'archive projects' do
project.update!(archived: project_archived) before do
end project.update!(archived: project_archived)
end
context 'when project is archived' do context 'when project is archived' do
let(:project_archived) { true } let(:project_archived) { true }
it 'does not show the operations settings tab' do it 'does not show the operations settings tab' do
render render
expect(rendered).not_to have_link('Operations', href: project_settings_operations_path(project))
end
end
expect(rendered).not_to have_link('Operations', href: project_settings_operations_path(project)) context 'when project is active' do
let(:project_archived) { false }
it 'shows the operations settings tab' do
render
expect(rendered).to have_link('Operations', href: project_settings_operations_path(project))
end
end end
end end
context 'when project is active' do describe 'Alert Management' do
let(:project_archived) { false } context 'when alert_management_minimal is enabled' do
before do
stub_feature_flags(alert_management_minimal: true)
end
it 'shows the operations settings tab' do it 'shows the Alerts sidebar entry' do
render render
expect(rendered).to have_css('a[title="Alerts"]')
end
end
context 'when alert_management_minimal is disabled' do
before do
stub_feature_flags(alert_management_minimal: false)
end
it 'does not show the Alerts sidebar entry' do
render
expect(rendered).to have_link('Operations', href: project_settings_operations_path(project)) expect(rendered).to have_no_css('a[title="Alerts"]')
end
end end
end end
end end
......
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