Commit 6ab49d29 authored by Alex Kalderimis's avatar Alex Kalderimis

Merge branch '337000-fj-add-runners-menu' into 'master'

Add CI/CD menu

See merge request gitlab-org/gitlab!66931
parents 5cec5cfa 331e7be1
- if group_sidebar_link?(:runners)
= nav_link(path: 'groups/runners#index') do
= link_to group_runners_path(@group), title: _('CI/CD'), class: 'has-sub-items' do
.nav-icon-container
= sprite_icon('rocket')
%span.nav-item-name
= _('CI/CD')
%ul.sidebar-sub-level-items
= nav_link(path: 'groups/runners#index', html_options: { class: "fly-out-top-item" } ) do
= link_to group_runners_path(@group), title: _('CI/CD') do
%strong.fly-out-top-item-name
= _('CI/CD')
%li.divider.fly-out-top-item
= nav_link(path: 'groups/runners#index') do
= link_to group_runners_path(@group), title: s_('Runners|Runners') do
%span= s_('Runners|Runners')
- if group_sidebar_link?(:kubernetes)
= nav_link(controller: [:clusters]) do
= link_to group_clusters_path(@group) do
......
# frozen_string_literal: true
module Sidebars
module Groups
module Menus
class CiCdMenu < ::Sidebars::Menu
override :configure_menu_items
def configure_menu_items
add_item(runners_menu_item)
true
end
override :link
def link
renderable_items.first.link
end
override :title
def title
_('CI/CD')
end
override :sprite_icon
def sprite_icon
'rocket'
end
private
def runners_menu_item
return ::Sidebars::NilMenuItem.new(item_id: :runners) unless show_runners?
::Sidebars::MenuItem.new(
title: _('Runners'),
link: group_runners_path(context.group),
active_routes: { path: 'groups/runners#index' },
item_id: :runners
)
end
# TODO Proper policies, such as `read_group_runners`, should be implemented per
# See https://gitlab.com/gitlab-org/gitlab/-/issues/334802
def show_runners?
can?(context.current_user, :admin_group, context.group) &&
Feature.enabled?(:runner_list_group_view_vue_ui, context.group, default_enabled: :yaml)
end
end
end
end
end
......@@ -10,6 +10,7 @@ module Sidebars
add_menu(Sidebars::Groups::Menus::GroupInformationMenu.new(context))
add_menu(Sidebars::Groups::Menus::IssuesMenu.new(context))
add_menu(Sidebars::Groups::Menus::MergeRequestsMenu.new(context))
add_menu(Sidebars::Groups::Menus::CiCdMenu.new(context))
end
override :render_raw_menus_partial
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Sidebars::Groups::Menus::CiCdMenu do
let_it_be(:owner) { create(:user) }
let_it_be(:root_group) do
build(:group, :private).tap do |g|
g.add_owner(owner)
end
end
let(:group) { root_group }
let(:user) { owner }
let(:context) { Sidebars::Groups::Context.new(current_user: user, container: group) }
describe 'Menu Items' do
subject { described_class.new(context).renderable_items.index { |e| e.item_id == item_id } }
describe 'Runners' do
let(:item_id) { :runners }
specify { is_expected.not_to be_nil }
describe 'when feature flag :runner_list_group_view_vue_ui is disabled' do
before do
stub_feature_flags(runner_list_group_view_vue_ui: false)
end
specify { is_expected.to be_nil }
end
describe 'when the user does not have access' do
let(:user) { nil }
specify { is_expected.to be_nil }
end
end
end
end
......@@ -3,10 +3,17 @@
require 'spec_helper'
RSpec.describe 'layouts/nav/sidebar/_group' do
let_it_be(:group) { create(:group) }
let_it_be(:owner) { create(:user) }
let_it_be(:group) do
create(:group).tap do |g|
g.add_owner(owner)
end
end
before do
assign(:group, group)
allow(view).to receive(:current_user).and_return(owner)
end
it_behaves_like 'has nav sidebar'
......@@ -79,4 +86,18 @@ RSpec.describe 'layouts/nav/sidebar/_group' do
expect(rendered).to have_css('span.badge.badge-pill.merge_counter.js-merge-counter')
end
end
describe 'CI/CD' do
it 'has a default link to the runners list path' do
render
expect(rendered).to have_link('CI/CD', href: group_runners_path(group))
end
it 'has a link to the runners list page' do
render
expect(rendered).to have_link('Runners', href: group_runners_path(group))
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