diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 13:18:24 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 13:18:24 +0000 |
commit | 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch) | |
tree | 4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /lib/sidebars | |
parent | 744144d28e3e7fddc117924fef88de5d9674fe4c (diff) | |
download | gitlab-ce-0653e08efd039a5905f3fa4f6e9cef9f5d2f799c.tar.gz |
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'lib/sidebars')
21 files changed, 23 insertions, 91 deletions
diff --git a/lib/sidebars/concerns/has_pill.rb b/lib/sidebars/concerns/has_pill.rb index 4bbf69bf16b..0a2e1f12008 100644 --- a/lib/sidebars/concerns/has_pill.rb +++ b/lib/sidebars/concerns/has_pill.rb @@ -21,8 +21,8 @@ module Sidebars {} end - def format_cached_count(count_service, count) - if count > count_service::CACHED_COUNT_THRESHOLD + def format_cached_count(threshold, count) + if count > threshold number_to_human( count, units: { thousand: 'k', million: 'm' }, precision: 1, significant: false, format: '%n%u' diff --git a/lib/sidebars/groups/menus/ci_cd_menu.rb b/lib/sidebars/groups/menus/ci_cd_menu.rb index e870bbf5ebc..f5bce57f496 100644 --- a/lib/sidebars/groups/menus/ci_cd_menu.rb +++ b/lib/sidebars/groups/menus/ci_cd_menu.rb @@ -11,11 +11,6 @@ module Sidebars true end - override :link - def link - renderable_items.first.link - end - override :title def title _('CI/CD') diff --git a/lib/sidebars/groups/menus/group_information_menu.rb b/lib/sidebars/groups/menus/group_information_menu.rb index b28cb927ad2..9656811455e 100644 --- a/lib/sidebars/groups/menus/group_information_menu.rb +++ b/lib/sidebars/groups/menus/group_information_menu.rb @@ -13,11 +13,6 @@ module Sidebars true end - override :link - def link - renderable_items.first.link - end - override :title def title context.group.subgroup? ? _('Subgroup information') : _('Group information') diff --git a/lib/sidebars/groups/menus/issues_menu.rb b/lib/sidebars/groups/menus/issues_menu.rb index 95641c09076..4044cb1c716 100644 --- a/lib/sidebars/groups/menus/issues_menu.rb +++ b/lib/sidebars/groups/menus/issues_menu.rb @@ -17,11 +17,6 @@ module Sidebars true end - override :link - def link - issues_group_path(context.group) - end - override :title def title _('Issues') @@ -43,7 +38,7 @@ module Sidebars count_service = ::Groups::OpenIssuesCountService count = count_service.new(context.group, context.current_user).count - format_cached_count(count_service, count) + format_cached_count(count_service::CACHED_COUNT_THRESHOLD, count) end end diff --git a/lib/sidebars/groups/menus/merge_requests_menu.rb b/lib/sidebars/groups/menus/merge_requests_menu.rb index 7faf50305c6..050cba07641 100644 --- a/lib/sidebars/groups/menus/merge_requests_menu.rb +++ b/lib/sidebars/groups/menus/merge_requests_menu.rb @@ -37,7 +37,7 @@ module Sidebars count_service = ::Groups::MergeRequestsCountService count = count_service.new(context.group, context.current_user).count - format_cached_count(count_service, count) + format_cached_count(count_service::CACHED_COUNT_THRESHOLD, count) end end diff --git a/lib/sidebars/groups/menus/packages_registries_menu.rb b/lib/sidebars/groups/menus/packages_registries_menu.rb index e46e2820c04..e81e9355e7e 100644 --- a/lib/sidebars/groups/menus/packages_registries_menu.rb +++ b/lib/sidebars/groups/menus/packages_registries_menu.rb @@ -13,11 +13,6 @@ module Sidebars true end - override :link - def link - renderable_items.first.link - end - override :title def title _('Packages & Registries') diff --git a/lib/sidebars/groups/menus/settings_menu.rb b/lib/sidebars/groups/menus/settings_menu.rb index 8bc6077d302..f0239ca6a1a 100644 --- a/lib/sidebars/groups/menus/settings_menu.rb +++ b/lib/sidebars/groups/menus/settings_menu.rb @@ -19,11 +19,6 @@ module Sidebars true end - override :link - def link - edit_group_path(context.group) - end - override :title def title _('Settings') diff --git a/lib/sidebars/groups/panel.rb b/lib/sidebars/groups/panel.rb index 73b943c5655..6efe89d496a 100644 --- a/lib/sidebars/groups/panel.rb +++ b/lib/sidebars/groups/panel.rb @@ -16,11 +16,6 @@ module Sidebars add_menu(Sidebars::Groups::Menus::SettingsMenu.new(context)) end - override :render_raw_menus_partial - def render_raw_menus_partial - 'layouts/nav/sidebar/group_menus' - end - override :aria_label def aria_label context.group.subgroup? ? _('Subgroup navigation') : _('Group navigation') diff --git a/lib/sidebars/menu.rb b/lib/sidebars/menu.rb index 3b8872fd572..1af3d024291 100644 --- a/lib/sidebars/menu.rb +++ b/lib/sidebars/menu.rb @@ -33,10 +33,9 @@ module Sidebars has_renderable_items? || menu_with_partial? end - # Menus might have or not a link override :link def link - nil + renderable_items.first&.link end # This method normalizes the information retrieved from the submenus and this menu diff --git a/lib/sidebars/projects/menus/analytics_menu.rb b/lib/sidebars/projects/menus/analytics_menu.rb index 29fd0609596..b13b25d1cfe 100644 --- a/lib/sidebars/projects/menus/analytics_menu.rb +++ b/lib/sidebars/projects/menus/analytics_menu.rb @@ -21,7 +21,7 @@ module Sidebars def link return cycle_analytics_menu_item.link if cycle_analytics_menu_item.render? - renderable_items.first.link + super end override :extra_container_html_options diff --git a/lib/sidebars/projects/menus/ci_cd_menu.rb b/lib/sidebars/projects/menus/ci_cd_menu.rb index f85a9faacd3..67e4209c382 100644 --- a/lib/sidebars/projects/menus/ci_cd_menu.rb +++ b/lib/sidebars/projects/menus/ci_cd_menu.rb @@ -15,11 +15,6 @@ module Sidebars add_item(pipeline_schedules_menu_item) end - override :link - def link - project_pipelines_path(context.project) - end - override :extra_container_html_options def extra_container_html_options { diff --git a/lib/sidebars/projects/menus/deployments_menu.rb b/lib/sidebars/projects/menus/deployments_menu.rb index fa6482562e8..110d78367b9 100644 --- a/lib/sidebars/projects/menus/deployments_menu.rb +++ b/lib/sidebars/projects/menus/deployments_menu.rb @@ -13,11 +13,6 @@ module Sidebars true end - override :link - def link - renderable_items.first.link - end - override :extra_container_html_options def extra_container_html_options { diff --git a/lib/sidebars/projects/menus/infrastructure_menu.rb b/lib/sidebars/projects/menus/infrastructure_menu.rb index aad1ce60d0e..e26bb2237e6 100644 --- a/lib/sidebars/projects/menus/infrastructure_menu.rb +++ b/lib/sidebars/projects/menus/infrastructure_menu.rb @@ -15,11 +15,6 @@ module Sidebars true end - override :link - def link - renderable_items.first.link - end - override :extra_container_html_options def extra_container_html_options { diff --git a/lib/sidebars/projects/menus/issues_menu.rb b/lib/sidebars/projects/menus/issues_menu.rb index fd57f21db88..3774bec2f13 100644 --- a/lib/sidebars/projects/menus/issues_menu.rb +++ b/lib/sidebars/projects/menus/issues_menu.rb @@ -18,11 +18,6 @@ module Sidebars true end - override :link - def link - project_issues_path(context.project) - end - override :extra_container_html_options def extra_container_html_options { diff --git a/lib/sidebars/projects/menus/learn_gitlab_menu.rb b/lib/sidebars/projects/menus/learn_gitlab_menu.rb index f29f4a6eed6..16335f5b076 100644 --- a/lib/sidebars/projects/menus/learn_gitlab_menu.rb +++ b/lib/sidebars/projects/menus/learn_gitlab_menu.rb @@ -23,7 +23,7 @@ module Sidebars override :has_pill? def has_pill? - context.learn_gitlab_experiment_enabled + context.learn_gitlab_enabled end override :pill_count @@ -40,8 +40,7 @@ module Sidebars { class: 'home', data: { - track_label: 'learn_gitlab', - track_property: context.learn_gitlab_experiment_tracking_category + track_label: 'learn_gitlab' } } end @@ -53,7 +52,7 @@ module Sidebars override :render? def render? - context.learn_gitlab_experiment_enabled + context.learn_gitlab_enabled end end end diff --git a/lib/sidebars/projects/menus/monitor_menu.rb b/lib/sidebars/projects/menus/monitor_menu.rb index 0d7e0776d5b..59554726263 100644 --- a/lib/sidebars/projects/menus/monitor_menu.rb +++ b/lib/sidebars/projects/menus/monitor_menu.rb @@ -19,11 +19,6 @@ module Sidebars true end - override :link - def link - renderable_items.first&.link - end - override :extra_container_html_options def extra_container_html_options { diff --git a/lib/sidebars/projects/menus/packages_registries_menu.rb b/lib/sidebars/projects/menus/packages_registries_menu.rb index d49bb680853..f5f0da2992e 100644 --- a/lib/sidebars/projects/menus/packages_registries_menu.rb +++ b/lib/sidebars/projects/menus/packages_registries_menu.rb @@ -13,11 +13,6 @@ module Sidebars true end - override :link - def link - renderable_items.first.link - end - override :title def title _('Packages & Registries') diff --git a/lib/sidebars/projects/menus/project_information_menu.rb b/lib/sidebars/projects/menus/project_information_menu.rb index a5f06ebea20..44b94ee3522 100644 --- a/lib/sidebars/projects/menus/project_information_menu.rb +++ b/lib/sidebars/projects/menus/project_information_menu.rb @@ -13,11 +13,6 @@ module Sidebars true end - override :link - def link - renderable_items.first.link - end - override :extra_container_html_options def extra_container_html_options { class: 'shortcuts-project-information' } diff --git a/lib/sidebars/projects/menus/repository_menu.rb b/lib/sidebars/projects/menus/repository_menu.rb index a784aecc3dc..0a295f0f618 100644 --- a/lib/sidebars/projects/menus/repository_menu.rb +++ b/lib/sidebars/projects/menus/repository_menu.rb @@ -20,11 +20,6 @@ module Sidebars true end - override :link - def link - project_tree_path(context.project) - end - override :extra_container_html_options def extra_container_html_options { diff --git a/lib/sidebars/projects/menus/security_compliance_menu.rb b/lib/sidebars/projects/menus/security_compliance_menu.rb index 5616b466560..9367514cdca 100644 --- a/lib/sidebars/projects/menus/security_compliance_menu.rb +++ b/lib/sidebars/projects/menus/security_compliance_menu.rb @@ -15,11 +15,6 @@ module Sidebars true end - override :link - def link - renderable_items.first&.link - end - override :title def title _('Security & Compliance') diff --git a/lib/sidebars/projects/menus/settings_menu.rb b/lib/sidebars/projects/menus/settings_menu.rb index 250143df649..6439c97d0bc 100644 --- a/lib/sidebars/projects/menus/settings_menu.rb +++ b/lib/sidebars/projects/menus/settings_menu.rb @@ -17,15 +17,11 @@ module Sidebars add_item(monitor_menu_item) add_item(pages_menu_item) add_item(packages_and_registries_menu_item) + add_item(usage_quotas_menu_item) true end - override :link - def link - edit_project_path(context.project) - end - override :title def title _('Settings') @@ -146,6 +142,19 @@ module Sidebars item_id: :packages_and_registries ) 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), + active_routes: { path: 'usage_quotas#index' }, + item_id: :usage_quotas + ) + end end end end |