Commit c9931b84 authored by Doug Stull's avatar Doug Stull

Merge branch '335665-fj-add-trial-experiment-menu' into 'master'

Add Trial Experiment menu to group sidebar

See merge request gitlab-org/gitlab!65811
parents a9650f7f 0a54825a
- issues_count = cached_issuables_count(@group, type: :issues)
- merge_requests_count = cached_issuables_count(@group, type: :merge_requests)
= render_if_exists 'layouts/nav/sidebar/group_trial_status_widget', group: @group
- if group_sidebar_link?(:overview)
- paths = group_overview_nav_link_paths
= nav_link(path: paths, unless: -> { current_path?('groups/contribution_analytics#show') }, html_options: { class: 'home' }) do
......
= nav_link(**sidebar_menu.all_active_routes, html_options: sidebar_menu.nav_link_html_options) do
- if sidebar_menu.menu_with_partial?
= render_if_exists sidebar_menu.menu_partial, **sidebar_menu.menu_partial_options
- else
= link_to sidebar_menu.link, **sidebar_menu.container_html_options, data: { qa_selector: 'sidebar_menu_link', qa_menu_item: sidebar_menu.title } do
- if sidebar_menu.icon_or_image?
%span.nav-icon-container
......
# frozen_string_literal: true
module EE
module Sidebars
module Groups
module Panel
extend ::Gitlab::Utils::Override
override :configure_menus
def configure_menus
super
add_menu(::Sidebars::Groups::Menus::TrialExperimentMenu.new(context))
end
end
end
end
end
# frozen_string_literal: true
module Sidebars
module Groups
module Menus
class TrialExperimentMenu < ::Sidebars::Menu
override :menu_partial
def menu_partial
'layouts/nav/sidebar/group_trial_status_widget'
end
override :menu_partial_options
def menu_partial_options
{
group: context.group
}
end
end
end
end
end
# frozen_string_literal: true
# This module has the necessary methods to render
# menus using a custom partial
module Sidebars
module Concerns
module HasPartial
def menu_partial
nil
end
def menu_partial_options
{}
end
def menu_with_partial?
menu_partial.present?
end
end
end
end
......@@ -20,3 +20,5 @@ module Sidebars
end
end
end
Sidebars::Groups::Panel.prepend_mod_with('Sidebars::Groups::Panel')
......@@ -12,6 +12,7 @@ module Sidebars
include ::Sidebars::Concerns::Renderable
include ::Sidebars::Concerns::ContainerWithHtmlOptions
include ::Sidebars::Concerns::HasActiveRoutes
include ::Sidebars::Concerns::HasPartial
attr_reader :context
delegate :current_user, :container, to: :@context
......@@ -29,7 +30,7 @@ module Sidebars
override :render?
def render?
has_renderable_items?
has_renderable_items? || menu_with_partial?
end
# Menus might have or not a link
......
......@@ -26,6 +26,14 @@ RSpec.describe Sidebars::Menu do
it 'returns false' do
expect(menu.render?).to be false
end
context 'when menu has a partial' do
it 'returns true' do
allow(menu).to receive(:menu_partial).and_return('foo')
expect(menu.render?).to be true
end
end
end
context 'when the menu has items' do
......
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