Commit 04d99bd5 authored by Fabio Pitino's avatar Fabio Pitino

Merge branch 'fj-fix-monitor-default-link' into 'master'

Fix default link for Monitor sidebar menu

See merge request gitlab-org/gitlab!65639
parents b1163762 9129adb3
......@@ -123,37 +123,6 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end
end
describe 'Monitor main link' do
let_it_be(:user) { create(:user) }
before do
project.project_feature.update!(builds_access_level: feature)
project.team.add_developer(user)
sign_in(user)
end
context 'when ci/cd is disabled' do
let(:feature) { ProjectFeature::DISABLED }
it 'links to feature flags page' do
render
expect(rendered).to have_link('Monitor', href: project_feature_flags_path(project))
end
end
context 'when ci/cd is enabled' do
let(:feature) { ProjectFeature::ENABLED }
it 'links to metrics page' do
render
expect(rendered).to have_link('Monitor', href: metrics_project_environments_path(project))
end
end
end
describe 'Security and Compliance' do
context 'when user does not have permissions' do
before do
......
......@@ -21,11 +21,7 @@ module Sidebars
override :link
def link
if can?(context.current_user, :read_environment, context.project)
metrics_project_environments_path(context.project)
else
project_feature_flags_path(context.project)
end
renderable_items.first&.link
end
override :extra_container_html_options
......
......@@ -50,18 +50,21 @@ RSpec.describe Sidebars::Projects::Menus::MonitorMenu do
end
describe '#link' do
context 'when metrics dashboard is visible' do
it 'returns link to the metrics dashboard page' do
expect(subject.link).to include('/-/environments/metrics')
end
let(:foo_path) { '/foo_path'}
let(:foo_menu) do
::Sidebars::MenuItem.new(
title: 'foo',
link: foo_path,
active_routes: {},
item_id: :foo
)
end
context 'when metrics dashboard is not visible' do
it 'returns link to the feature flags page' do
project.project_feature.update!(operations_access_level: Featurable::DISABLED)
it 'returns first visible item link' do
subject.insert_element_before(subject.renderable_items, subject.renderable_items.first.item_id, foo_menu)
expect(subject.link).to include('/-/feature_flags')
end
expect(subject.link).to eq foo_path
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