diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
commit | e8d2c2579383897a1dd7f9debd359abe8ae8373d (patch) | |
tree | c42be41678c2586d49a75cabce89322082698334 /app/helpers/sidebars_helper.rb | |
parent | fc845b37ec3a90aaa719975f607740c22ba6a113 (diff) |
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'app/helpers/sidebars_helper.rb')
-rw-r--r-- | app/helpers/sidebars_helper.rb | 74 |
1 files changed, 61 insertions, 13 deletions
diff --git a/app/helpers/sidebars_helper.rb b/app/helpers/sidebars_helper.rb index 39ad8ed8a0f..77af6e37099 100644 --- a/app/helpers/sidebars_helper.rb +++ b/app/helpers/sidebars_helper.rb @@ -2,34 +2,75 @@ module SidebarsHelper def sidebar_tracking_attributes_by_object(object) + sidebar_attributes_for_object(object).fetch(:tracking_attrs, {}) + end + + def sidebar_qa_selector(object) + sidebar_attributes_for_object(object).fetch(:sidebar_qa_selector, nil) + end + + def scope_qa_menu_item(object) + sidebar_attributes_for_object(object).fetch(:scope_qa_menu_item, nil) + end + + def scope_avatar_classes(object) + %w[avatar-container rect-avatar s32].tap do |klasses| + klass = sidebar_attributes_for_object(object).fetch(:scope_avatar_class, nil) + klasses << klass if klass + end + end + + def project_sidebar_context(project, user, current_ref) + context_data = project_sidebar_context_data(project, user, current_ref) + + Sidebars::Projects::Context.new(**context_data) + end + + def group_sidebar_context(group, user) + context_data = group_sidebar_context_data(group, user) + + Sidebars::Groups::Context.new(**context_data) + end + + private + + def sidebar_attributes_for_object(object) case object when Project - sidebar_project_tracking_attrs + sidebar_project_attributes when Group - sidebar_group_tracking_attrs + sidebar_group_attributes when User - sidebar_user_profile_tracking_attrs + sidebar_user_attributes else {} end end - def project_sidebar_context(project, user, current_ref) - context_data = project_sidebar_context_data(project, user, current_ref) - - Sidebars::Projects::Context.new(**context_data) + def sidebar_project_attributes + { + tracking_attrs: sidebar_project_tracking_attrs, + sidebar_qa_selector: 'project_sidebar', + scope_qa_menu_item: 'Project scope', + scope_avatar_class: 'project_avatar' + } end - def sidebar_refactor_enabled? - Feature.enabled?(:sidebar_refactor, current_user, default_enabled: :yaml) + def sidebar_group_attributes + { + tracking_attrs: sidebar_group_tracking_attrs, + sidebar_qa_selector: 'group_sidebar', + scope_qa_menu_item: 'Group scope', + scope_avatar_class: 'group_avatar' + } end - def sidebar_refactor_disabled? - !sidebar_refactor_enabled? + def sidebar_user_attributes + { + tracking_attrs: sidebar_user_profile_tracking_attrs + } end - private - def sidebar_project_tracking_attrs tracking_attrs('projects_side_navigation', 'render', 'projects_side_navigation') end @@ -54,6 +95,13 @@ module SidebarsHelper show_cluster_hint: show_gke_cluster_integration_callout?(project) } end + + def group_sidebar_context_data(group, user) + { + current_user: user, + container: group + } + end end SidebarsHelper.prepend_mod_with('SidebarsHelper') |