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) - issues_count = cached_issuables_count(@group, type: :issues)
- merge_requests_count = cached_issuables_count(@group, type: :merge_requests) - 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) - if group_sidebar_link?(:overview)
- paths = group_overview_nav_link_paths - paths = group_overview_nav_link_paths
= nav_link(path: paths, unless: -> { current_path?('groups/contribution_analytics#show') }, html_options: { class: 'home' }) do = 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 = 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.menu_with_partial?
- if sidebar_menu.icon_or_image? = render_if_exists sidebar_menu.menu_partial, **sidebar_menu.menu_partial_options
%span.nav-icon-container - else
- if sidebar_menu.image_path = link_to sidebar_menu.link, **sidebar_menu.container_html_options, data: { qa_selector: 'sidebar_menu_link', qa_menu_item: sidebar_menu.title } do
= image_tag(sidebar_menu.image_path, **sidebar_menu.image_html_options) - if sidebar_menu.icon_or_image?
- elsif sidebar_menu.sprite_icon %span.nav-icon-container
= sprite_icon(sidebar_menu.sprite_icon, **sidebar_menu.sprite_icon_html_options) - 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 } %span.nav-item-name{ **sidebar_menu.title_html_options }
= sidebar_menu.title = sidebar_menu.title
- if sidebar_menu.has_pill? - if sidebar_menu.has_pill?
%span.badge.badge-pill.count{ **sidebar_menu.pill_html_options } %span.badge.badge-pill.count{ **sidebar_menu.pill_html_options }
= number_with_delimiter(sidebar_menu.pill_count) = number_with_delimiter(sidebar_menu.pill_count)
%ul.sidebar-sub-level-items{ class: ('is-fly-out-only' unless sidebar_menu.has_renderable_items?) } %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 = nav_link(**sidebar_menu.all_active_routes, html_options: { class: 'fly-out-top-item' } ) do
%span.fly-out-top-item-container %span.fly-out-top-item-container
%strong.fly-out-top-item-name %strong.fly-out-top-item-name
= sidebar_menu.title = sidebar_menu.title
- if sidebar_menu.has_pill? - if sidebar_menu.has_pill?
%span.badge.badge-pill.count.fly-out-badge{ **sidebar_menu.pill_html_options } %span.badge.badge-pill.count.fly-out-badge{ **sidebar_menu.pill_html_options }
= number_with_delimiter(sidebar_menu.pill_count) = number_with_delimiter(sidebar_menu.pill_count)
- if sidebar_menu.has_renderable_items? - if sidebar_menu.has_renderable_items?
%li.divider.fly-out-top-item %li.divider.fly-out-top-item
= render partial: 'shared/nav/sidebar_menu_item', collection: sidebar_menu.renderable_items = 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 ...@@ -20,3 +20,5 @@ module Sidebars
end end
end end
end end
Sidebars::Groups::Panel.prepend_mod_with('Sidebars::Groups::Panel')
...@@ -12,6 +12,7 @@ module Sidebars ...@@ -12,6 +12,7 @@ module Sidebars
include ::Sidebars::Concerns::Renderable include ::Sidebars::Concerns::Renderable
include ::Sidebars::Concerns::ContainerWithHtmlOptions include ::Sidebars::Concerns::ContainerWithHtmlOptions
include ::Sidebars::Concerns::HasActiveRoutes include ::Sidebars::Concerns::HasActiveRoutes
include ::Sidebars::Concerns::HasPartial
attr_reader :context attr_reader :context
delegate :current_user, :container, to: :@context delegate :current_user, :container, to: :@context
...@@ -29,7 +30,7 @@ module Sidebars ...@@ -29,7 +30,7 @@ module Sidebars
override :render? override :render?
def render? def render?
has_renderable_items? has_renderable_items? || menu_with_partial?
end end
# Menus might have or not a link # Menus might have or not a link
......
...@@ -26,6 +26,14 @@ RSpec.describe Sidebars::Menu do ...@@ -26,6 +26,14 @@ RSpec.describe Sidebars::Menu do
it 'returns false' do it 'returns false' do
expect(menu.render?).to be false expect(menu.render?).to be false
end 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 end
context 'when the menu has items' do 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