Commit 3c2ba0bf authored by Denys Mishunov's avatar Denys Mishunov

Merge branch '322687-fj-new-group-active-state' into 'master'

Implement new active state for group sidebar context menu

See merge request gitlab-org/gitlab!61469
parents fbd2fb55 9678c1a6
......@@ -3,14 +3,16 @@
module GroupsHelper
def group_overview_nav_link_paths
%w[
groups#show
groups#details
groups#activity
groups#subgroups
].tap do |paths|
break paths if Feature.disabled?(:sidebar_refactor, current_user, default_enabled: :yaml)
extra_routes = if sidebar_refactor_disabled?
['groups#show', 'groups#details']
else
['labels#index', 'group_members#index']
end
paths.concat(['labels#index', 'group_members#index'])
paths.concat(extra_routes)
end
end
......
......@@ -20,6 +20,14 @@ module SidebarsHelper
Sidebars::Projects::Context.new(**context_data)
end
def sidebar_refactor_enabled?
Feature.enabled?(:sidebar_refactor, current_user, default_enabled: :yaml)
end
def sidebar_refactor_disabled?
!sidebar_refactor_enabled?
end
private
def sidebar_project_tracking_attrs
......
= link_to group_path(@group), title: @group.name do
%span.avatar-container.rect-avatar.s40.group-avatar
= group_icon(@group, class: "avatar s40 avatar-tile")
%span.sidebar-context-title
= @group.name
......@@ -4,33 +4,36 @@
%aside.nav-sidebar{ class: ("sidebar-collapsed-desktop" if collapsed_sidebar?), **sidebar_tracking_attributes_by_object(@group), 'aria-label': aside_title }
.nav-sidebar-inner-scroll
.context-header
= link_to group_path(@group), title: @group.name do
%span.avatar-container.rect-avatar.s40.group-avatar
= group_icon(@group, class: "avatar s40 avatar-tile")
%span.sidebar-context-title
= @group.name
- if sidebar_refactor_disabled?
.context-header
= render 'layouts/nav/sidebar/context_menu_body'
%ul.sidebar-top-level-items.qa-group-sidebar
- if sidebar_refactor_enabled?
= nav_link(path: ['groups#show', 'groups#details'], html_options: { class: 'context-header' }) do
= render 'layouts/nav/sidebar/context_menu_body'
= 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
= link_to group_path(@group) do
- information_link = sidebar_refactor_enabled? ? activity_group_path(@group) : group_path(@group)
= link_to information_link do
.nav-icon-container
- sprite = Feature.enabled?(:sidebar_refactor, current_user, default_enabled: :yaml) ? 'group' : 'home'
- sprite = sidebar_refactor_enabled? ? 'group' : 'home'
= sprite_icon(sprite)
%span.nav-item-name
= group_information_title(@group)
%ul.sidebar-sub-level-items
= nav_link(path: paths, html_options: { class: "fly-out-top-item" } ) do
= link_to group_path(@group) do
= link_to information_link do
%strong.fly-out-top-item-name
= group_information_title(@group)
%li.divider.fly-out-top-item
- if Feature.disabled?(:sidebar_refactor, current_user, default_enabled: :yaml)
- if sidebar_refactor_disabled?
= nav_link(path: ['groups#show', 'groups#details', 'groups#subgroups'], html_options: { class: 'home' }) do
= link_to details_group_path(@group), title: _('Group details') do
%span
......@@ -42,13 +45,13 @@
%span
= _('Activity')
- if group_sidebar_link?(:labels) && Feature.enabled?(:sidebar_refactor, current_user, default_enabled: :yaml)
- if group_sidebar_link?(:labels) && sidebar_refactor_enabled?
= nav_link(path: 'labels#index') do
= link_to group_labels_path(@group), title: _('Labels') do
%span
= _('Labels')
- if Feature.enabled?(:sidebar_refactor, current_user, default_enabled: :yaml)
- if sidebar_refactor_enabled?
- if group_sidebar_link?(:group_members)
= nav_link(path: 'group_members#index') do
= link_to group_group_members_path(@group), title: _('Members'), data: { qa_selector: 'group_members_item' } do
......@@ -85,7 +88,7 @@
%span
= boards_link_text
- if group_sidebar_link?(:labels) && Feature.disabled?(:sidebar_refactor, current_user, default_enabled: :yaml)
- if group_sidebar_link?(:labels) && sidebar_refactor_disabled?
= nav_link(path: 'labels#index') do
= link_to group_labels_path(@group), title: _('Labels') do
%span
......@@ -138,7 +141,7 @@
- if group_sidebar_link?(:wiki)
= render 'layouts/nav/sidebar/wiki_link', wiki_url: @group.wiki.web_url
- if Feature.disabled?(:sidebar_refactor, current_user, default_enabled: :yaml)
- if sidebar_refactor_disabled?
- if group_sidebar_link?(:group_members)
= nav_link(path: 'group_members#index') do
= link_to group_group_members_path(@group) do
......
......@@ -13,6 +13,7 @@ RSpec.describe 'Group navbar' do
let(:structure) do
[
group_context_nav_item,
group_information_nav_item,
{
nav_item: _('Issues'),
......@@ -37,6 +38,13 @@ RSpec.describe 'Group navbar' do
nil
end
let(:group_context_nav_item) do
{
nav_item: "#{group.name[0, 1].upcase} #{group.name}",
nav_sub_items: []
}
end
before do
insert_package_nav(_('Kubernetes'))
......@@ -79,6 +87,10 @@ RSpec.describe 'Group navbar' do
end
context 'when feature flag :sidebar_refactor is disabled' do
let(:group_context_nav_item) do
nil
end
let(:group_information_nav_item) do
{
nav_item: _('Group overview'),
......
......@@ -200,8 +200,16 @@ RSpec.shared_context 'group navbar structure' do
]
end
let(:group_context_nav_item) do
{
nav_item: "#{group.name[0, 1].upcase} #{group.name}",
nav_sub_items: []
}
end
let(:structure) do
[
group_context_nav_item,
group_information_nav_item,
{
nav_item: _('Issues'),
......
......@@ -12,11 +12,19 @@ RSpec.describe 'layouts/nav/sidebar/_group' do
it_behaves_like 'has nav sidebar'
it_behaves_like 'sidebar includes snowplow attributes', 'render', 'groups_side_navigation', 'groups_side_navigation'
describe 'Group information' do
describe 'Group context menu' do
it 'has a link to the group path' do
render
expect(rendered).to have_link('Group information', href: group_path(group))
expect(rendered).to have_link(group.name, href: group_path(group))
end
end
describe 'Group information' do
it 'has a link to the group activity path' do
render
expect(rendered).to have_link('Group information', href: activity_group_path(group))
end
it 'does not have a link to the details menu item' 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