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
= 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
- if sidebar_menu.image_path
= image_tag(sidebar_menu.image_path, **sidebar_menu.image_html_options)
- elsif sidebar_menu.sprite_icon
= sprite_icon(sidebar_menu.sprite_icon, **sidebar_menu.sprite_icon_html_options)
- 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
- if sidebar_menu.image_path
= image_tag(sidebar_menu.image_path, **sidebar_menu.image_html_options)
- elsif sidebar_menu.sprite_icon
= sprite_icon(sidebar_menu.sprite_icon, **sidebar_menu.sprite_icon_html_options)
%span.nav-item-name{ **sidebar_menu.title_html_options }
= sidebar_menu.title
- if sidebar_menu.has_pill?
%span.badge.badge-pill.count{ **sidebar_menu.pill_html_options }
= number_with_delimiter(sidebar_menu.pill_count)
%span.nav-item-name{ **sidebar_menu.title_html_options }
= sidebar_menu.title
- if sidebar_menu.has_pill?
%span.badge.badge-pill.count{ **sidebar_menu.pill_html_options }
= number_with_delimiter(sidebar_menu.pill_count)
%ul.sidebar-sub-level-items{ class: ('is-fly-out-only' unless sidebar_menu.has_renderable_items?) }
= nav_link(**sidebar_menu.all_active_routes, html_options: { class: 'fly-out-top-item' } ) do
%span.fly-out-top-item-container
%strong.fly-out-top-item-name
= sidebar_menu.title
- if sidebar_menu.has_pill?
%span.badge.badge-pill.count.fly-out-badge{ **sidebar_menu.pill_html_options }
= number_with_delimiter(sidebar_menu.pill_count)
%ul.sidebar-sub-level-items{ class: ('is-fly-out-only' unless sidebar_menu.has_renderable_items?) }
= nav_link(**sidebar_menu.all_active_routes, html_options: { class: 'fly-out-top-item' } ) do
%span.fly-out-top-item-container
%strong.fly-out-top-item-name
= sidebar_menu.title
- if sidebar_menu.has_pill?
%span.badge.badge-pill.count.fly-out-badge{ **sidebar_menu.pill_html_options }
= number_with_delimiter(sidebar_menu.pill_count)
- if sidebar_menu.has_renderable_items?
%li.divider.fly-out-top-item
= render partial: 'shared/nav/sidebar_menu_item', collection: sidebar_menu.renderable_items
- if sidebar_menu.has_renderable_items?
%li.divider.fly-out-top-item
= render partial: 'shared/nav/sidebar_menu_item', collection: sidebar_menu.renderable_items
# 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