Commit 6affbcaa authored by David Kim's avatar David Kim

Merge branch '336872-fj-add-kubernetes-menu' into 'master'

Add Kubernetes menu

See merge request gitlab-org/gitlab!66834
parents fd9e67a5 d2da2b6e
- if group_sidebar_link?(:kubernetes)
= nav_link(controller: [:clusters]) do
= link_to group_clusters_path(@group) do
.nav-icon-container
= sprite_icon('cloud-gear')
%span.nav-item-name
= _('Kubernetes')
%ul.sidebar-sub-level-items.is-fly-out-only
= nav_link(controller: [:clusters], html_options: { class: "fly-out-top-item" } ) do
= link_to group_clusters_path(@group), title: _('Kubernetes'), class: 'shortcuts-kubernetes' do
%strong.fly-out-top-item-name
= _('Kubernetes')
= render 'groups/sidebar/packages' = render 'groups/sidebar/packages'
= render 'layouts/nav/sidebar/analytics_links', links: group_analytics_navbar_links(@group, current_user) = render 'layouts/nav/sidebar/analytics_links', links: group_analytics_navbar_links(@group, current_user)
......
# frozen_string_literal: true
module Sidebars
module Groups
module Menus
class KubernetesMenu < ::Sidebars::Menu
override :link
def link
group_clusters_path(context.group)
end
override :title
def title
_('Kubernetes')
end
override :sprite_icon
def sprite_icon
'cloud-gear'
end
override :render?
def render?
can?(context.current_user, :read_cluster, context.group)
end
override :extra_container_html_options
def extra_container_html_options
{
class: 'shortcuts-kubernetes'
}
end
override :active_routes
def active_routes
{ controller: :clusters }
end
end
end
end
end
...@@ -11,6 +11,7 @@ module Sidebars ...@@ -11,6 +11,7 @@ module Sidebars
add_menu(Sidebars::Groups::Menus::IssuesMenu.new(context)) add_menu(Sidebars::Groups::Menus::IssuesMenu.new(context))
add_menu(Sidebars::Groups::Menus::MergeRequestsMenu.new(context)) add_menu(Sidebars::Groups::Menus::MergeRequestsMenu.new(context))
add_menu(Sidebars::Groups::Menus::CiCdMenu.new(context)) add_menu(Sidebars::Groups::Menus::CiCdMenu.new(context))
add_menu(Sidebars::Groups::Menus::KubernetesMenu.new(context))
end end
override :render_raw_menus_partial override :render_raw_menus_partial
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Sidebars::Groups::Menus::KubernetesMenu do
let_it_be(:owner) { create(:user) }
let_it_be(:group) do
build(:group, :private).tap do |g|
g.add_owner(owner)
end
end
let(:user) { owner }
let(:context) { Sidebars::Groups::Context.new(current_user: user, container: group) }
let(:menu) { described_class.new(context) }
describe '#render?' do
context 'when user can read clusters' do
it 'returns true' do
expect(menu.render?).to eq true
end
end
context 'when user cannot read clusters rules' do
let(:user) { nil }
it 'returns false' do
expect(menu.render?).to eq false
end
end
end
end
...@@ -100,4 +100,12 @@ RSpec.describe 'layouts/nav/sidebar/_group' do ...@@ -100,4 +100,12 @@ RSpec.describe 'layouts/nav/sidebar/_group' do
expect(rendered).to have_link('Runners', href: group_runners_path(group)) expect(rendered).to have_link('Runners', href: group_runners_path(group))
end end
end end
describe 'Kubernetes menu' do
it 'has a link to the group cluster list path' do
render
expect(rendered).to have_link('Kubernetes', href: group_clusters_path(group))
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