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