Commit dc0858ff authored by Denys Mishunov's avatar Denys Mishunov

Merge branch '326343-fj-add-project-sidebar-panel' into 'master'

Add new project sidebar panel

See merge request gitlab-org/gitlab!58854
parents ec167d69 21b4b80e
...@@ -14,6 +14,10 @@ module SidebarsHelper ...@@ -14,6 +14,10 @@ module SidebarsHelper
end end
end end
def project_sidebar_context(project, user)
Sidebars::Context.new(**project_sidebar_context_data(project, user))
end
private private
def sidebar_project_tracking_attrs def sidebar_project_tracking_attrs
...@@ -27,4 +31,12 @@ module SidebarsHelper ...@@ -27,4 +31,12 @@ module SidebarsHelper
def sidebar_user_profile_tracking_attrs def sidebar_user_profile_tracking_attrs
tracking_attrs('user_side_navigation', 'render', 'user_side_navigation') tracking_attrs('user_side_navigation', 'render', 'user_side_navigation')
end end
def project_sidebar_context_data(project, user)
{
current_user: user,
container: project,
project: project
}
end
end end
...@@ -51,5 +51,25 @@ module Sidebars ...@@ -51,5 +51,25 @@ module Sidebars
def renderable_menus def renderable_menus
@renderable_menus ||= @menus.select(&:render?) @renderable_menus ||= @menus.select(&:render?)
end end
def container
context.container
end
# Auxiliar method that helps with the migration from
# regular views to the new logic
def render_raw_scope_menu_partial
# No-op
end
# Auxiliar method that helps with the migration from
# regular views to the new logic.
#
# Any menu inside this partial will be added after
# all the menus added in the `configure_menus`
# method.
def render_raw_menus_partial
# No-op
end
end end
end end
# frozen_string_literal: true
module Sidebars
module Projects
class Panel < ::Sidebars::Panel
override :render_raw_menus_partial
def render_raw_scope_menu_partial
'layouts/nav/sidebar/project_scope_menu'
end
override :render_raw_menus_partial
def render_raw_menus_partial
'layouts/nav/sidebar/project_menus'
end
override :aria_label
def aria_label
_('Project navigation')
end
end
end
end
This diff is collapsed.
.context-header
= link_to project_path(@project), title: @project.name do
.avatar-container.rect-avatar.s40.project-avatar
= project_icon(@project, alt: @project.name, class: 'avatar s40 avatar-tile', width: 40, height: 40)
.sidebar-context-title
= @project.name
%aside.nav-sidebar{ class: ('sidebar-collapsed-desktop' if collapsed_sidebar?), **sidebar_tracking_attributes_by_object(sidebar.container), 'aria-label': sidebar.aria_label }
.nav-sidebar-inner-scroll
- if sidebar.render_raw_scope_menu_partial
= render sidebar.render_raw_scope_menu_partial
%ul.sidebar-top-level-items.qa-project-sidebar
- if sidebar.render_raw_menus_partial
= render sidebar.render_raw_menus_partial
= render 'shared/sidebar_toggle_button'
...@@ -13,7 +13,7 @@ module QA ...@@ -13,7 +13,7 @@ module QA
include SubMenus::Settings include SubMenus::Settings
include SubMenus::Packages include SubMenus::Packages
view 'app/views/layouts/nav/sidebar/_project.html.haml' do view 'app/views/layouts/nav/sidebar/_project_menus.html.haml' do
element :activity_link element :activity_link
element :merge_requests_link element :merge_requests_link
element :snippets_link element :snippets_link
......
...@@ -13,7 +13,7 @@ module QA ...@@ -13,7 +13,7 @@ module QA
base.class_eval do base.class_eval do
include QA::Page::Project::SubMenus::Common include QA::Page::Project::SubMenus::Common
view 'app/views/layouts/nav/sidebar/_project.html.haml' do view 'app/views/layouts/nav/sidebar/_project_menus.html.haml' do
element :link_pipelines element :link_pipelines
end end
end end
......
...@@ -13,7 +13,7 @@ module QA ...@@ -13,7 +13,7 @@ module QA
base.class_eval do base.class_eval do
include QA::Page::Project::SubMenus::Common include QA::Page::Project::SubMenus::Common
view 'app/views/layouts/nav/sidebar/_project.html.haml' do view 'app/views/layouts/nav/sidebar/_project_menus.html.haml' do
element :issue_boards_link element :issue_boards_link
element :issues_item element :issues_item
element :labels_link element :labels_link
......
...@@ -13,7 +13,7 @@ module QA ...@@ -13,7 +13,7 @@ module QA
base.class_eval do base.class_eval do
include QA::Page::Project::SubMenus::Common include QA::Page::Project::SubMenus::Common
view 'app/views/layouts/nav/sidebar/_project.html.haml' do view 'app/views/layouts/nav/sidebar/_project_menus.html.haml' do
element :operations_link element :operations_link
element :operations_environments_link element :operations_environments_link
element :operations_metrics_link element :operations_metrics_link
......
...@@ -13,7 +13,7 @@ module QA ...@@ -13,7 +13,7 @@ module QA
base.class_eval do base.class_eval do
include QA::Page::Project::SubMenus::Common include QA::Page::Project::SubMenus::Common
view 'app/views/layouts/nav/sidebar/_project.html.haml' do view 'app/views/layouts/nav/sidebar/_project_menus.html.haml' do
element :project_link element :project_link
end end
end end
......
...@@ -13,7 +13,7 @@ module QA ...@@ -13,7 +13,7 @@ module QA
base.class_eval do base.class_eval do
include QA::Page::Project::SubMenus::Common include QA::Page::Project::SubMenus::Common
view 'app/views/layouts/nav/sidebar/_project.html.haml' do view 'app/views/layouts/nav/sidebar/_project_menus.html.haml' do
element :repository_link element :repository_link
element :branches_link element :branches_link
element :tags_link element :tags_link
......
...@@ -13,7 +13,7 @@ module QA ...@@ -13,7 +13,7 @@ module QA
base.class_eval do base.class_eval do
include QA::Page::Project::SubMenus::Common include QA::Page::Project::SubMenus::Common
view 'app/views/layouts/nav/sidebar/_project.html.haml' do view 'app/views/layouts/nav/sidebar/_project_menus.html.haml' do
element :settings_item element :settings_item
element :general_settings_link element :general_settings_link
element :integrations_settings_link element :integrations_settings_link
......
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