diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
commit | 311b0269b4eb9839fa63f80c8d7a58f32b8138a0 (patch) | |
tree | 07e7870bca8aed6d61fdcc810731c50d2c40af47 /lib/sidebars/projects/menus | |
parent | 27909cef6c4170ed9205afa7426b8d3de47cbb0c (diff) |
Add latest changes from gitlab-org/gitlab@14-5-stable-eev14.5.0-rc42
Diffstat (limited to 'lib/sidebars/projects/menus')
-rw-r--r-- | lib/sidebars/projects/menus/confluence_menu.rb | 5 | ||||
-rw-r--r-- | lib/sidebars/projects/menus/infrastructure_menu.rb | 4 | ||||
-rw-r--r-- | lib/sidebars/projects/menus/invite_team_members_menu.rb | 47 | ||||
-rw-r--r-- | lib/sidebars/projects/menus/settings_menu.rb | 4 | ||||
-rw-r--r-- | lib/sidebars/projects/menus/zentao_menu.rb | 77 |
5 files changed, 131 insertions, 6 deletions
diff --git a/lib/sidebars/projects/menus/confluence_menu.rb b/lib/sidebars/projects/menus/confluence_menu.rb index 0d83238fa82..0fd42a57da3 100644 --- a/lib/sidebars/projects/menus/confluence_menu.rb +++ b/lib/sidebars/projects/menus/confluence_menu.rb @@ -37,6 +37,11 @@ module Sidebars def render? context.project.has_confluence? end + + override :active_routes + def active_routes + { controller: :confluences } + end end end end diff --git a/lib/sidebars/projects/menus/infrastructure_menu.rb b/lib/sidebars/projects/menus/infrastructure_menu.rb index 92e9cbb7040..ccc4787601a 100644 --- a/lib/sidebars/projects/menus/infrastructure_menu.rb +++ b/lib/sidebars/projects/menus/infrastructure_menu.rb @@ -91,7 +91,7 @@ module Sidebars def google_cloud_menu_item feature_is_enabled = Feature.enabled?(:incubation_5mp_google_cloud) - user_has_permissions = can?(context.current_user, :manage_project_google_cloud, context.project) + user_has_permissions = can?(context.current_user, :admin_project_google_cloud, context.project) unless feature_is_enabled && user_has_permissions return ::Sidebars::NilMenuItem.new(item_id: :incubation_5mp_google_cloud) @@ -100,7 +100,7 @@ module Sidebars ::Sidebars::MenuItem.new( title: _('Google Cloud'), link: project_google_cloud_index_path(context.project), - active_routes: {}, + active_routes: { controller: :google_cloud }, item_id: :google_cloud ) end diff --git a/lib/sidebars/projects/menus/invite_team_members_menu.rb b/lib/sidebars/projects/menus/invite_team_members_menu.rb new file mode 100644 index 00000000000..0db49f1e12a --- /dev/null +++ b/lib/sidebars/projects/menus/invite_team_members_menu.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +module Sidebars + module Projects + module Menus + class InviteTeamMembersMenu < ::Sidebars::Menu + override :title + def title + s_('InviteMember|Invite members') + end + + override :render? + def render? + can?(context.current_user, :admin_project_member, context.project) && all_valid_members.size <= 1 + end + + override :menu_partial + def menu_partial + 'projects/invite_members_side_nav_link' + end + + override :menu_partial_options + def menu_partial_options + { + project: context.project, + title: title, + sidebar_menu: self + } + end + + override :extra_nav_link_html_options + def extra_nav_link_html_options + { + 'data-test-id': 'side-nav-invite-members' + } + end + + private + + def all_valid_members + MembersFinder.new(context.project, context.current_user) + .execute(include_relations: [:inherited, :direct, :invited_groups]) + end + end + end + end +end diff --git a/lib/sidebars/projects/menus/settings_menu.rb b/lib/sidebars/projects/menus/settings_menu.rb index 6439c97d0bc..2411ca8263a 100644 --- a/lib/sidebars/projects/menus/settings_menu.rb +++ b/lib/sidebars/projects/menus/settings_menu.rb @@ -144,10 +144,6 @@ module Sidebars end def usage_quotas_menu_item - unless Feature.enabled?(:project_storage_ui, context.project&.group, default_enabled: :yaml) - return ::Sidebars::NilMenuItem.new(item_id: :usage_quotas) - end - ::Sidebars::MenuItem.new( title: s_('UsageQuota|Usage Quotas'), link: project_usage_quotas_path(context.project), diff --git a/lib/sidebars/projects/menus/zentao_menu.rb b/lib/sidebars/projects/menus/zentao_menu.rb new file mode 100644 index 00000000000..db9e60326a4 --- /dev/null +++ b/lib/sidebars/projects/menus/zentao_menu.rb @@ -0,0 +1,77 @@ +# frozen_string_literal: true + +module Sidebars + module Projects + module Menus + class ZentaoMenu < ::Sidebars::Menu + override :configure_menu_items + def configure_menu_items + render?.tap { |render| add_items if render } + end + + override :link + def link + zentao_integration.url + end + + override :title + def title + s_('ZentaoIntegration|ZenTao issues') + end + + override :title_html_options + def title_html_options + { + id: 'js-onboarding-settings-link' + } + end + + override :image_path + def image_path + 'logos/zentao.svg' + end + + # Hardcode sizes so image doesn't flash before CSS loads https://gitlab.com/gitlab-org/gitlab/-/issues/321022 + override :image_html_options + def image_html_options + { + size: 16 + } + end + + override :render? + def render? + return false if zentao_integration.blank? + + zentao_integration.active? + end + + def add_items + add_item(open_zentao_menu_item) + end + + private + + def zentao_integration + @zentao_integration ||= context.project.zentao_integration + end + + def open_zentao_menu_item + ::Sidebars::MenuItem.new( + title: s_('ZentaoIntegration|Open ZenTao'), + link: zentao_integration.url, + active_routes: {}, + item_id: :open_zentao, + sprite_icon: 'external-link', + container_html_options: { + target: '_blank', + rel: 'noopener noreferrer' + } + ) + end + end + end + end +end + +::Sidebars::Projects::Menus::ZentaoMenu.prepend_mod |