Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-04-21 02:50:22 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-04-21 02:50:22 +0300
commit9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch)
tree70467ae3692a0e35e5ea56bcb803eb512a10bedb /app/helpers/sidebars_helper.rb
parent4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff)
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'app/helpers/sidebars_helper.rb')
-rw-r--r--app/helpers/sidebars_helper.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/app/helpers/sidebars_helper.rb b/app/helpers/sidebars_helper.rb
new file mode 100644
index 00000000000..31dfe21671a
--- /dev/null
+++ b/app/helpers/sidebars_helper.rb
@@ -0,0 +1,45 @@
+# frozen_string_literal: true
+
+module SidebarsHelper
+ def sidebar_tracking_attributes_by_object(object)
+ case object
+ when Project
+ sidebar_project_tracking_attrs
+ when Group
+ sidebar_group_tracking_attrs
+ when User
+ sidebar_user_profile_tracking_attrs
+ 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)
+ end
+
+ private
+
+ def sidebar_project_tracking_attrs
+ tracking_attrs('projects_side_navigation', 'render', 'projects_side_navigation')
+ end
+
+ def sidebar_group_tracking_attrs
+ tracking_attrs('groups_side_navigation', 'render', 'groups_side_navigation')
+ end
+
+ def sidebar_user_profile_tracking_attrs
+ tracking_attrs('user_side_navigation', 'render', 'user_side_navigation')
+ end
+
+ def project_sidebar_context_data(project, user, current_ref)
+ {
+ current_user: user,
+ container: project,
+ learn_gitlab_experiment_enabled: learn_gitlab_experiment_enabled?(project),
+ current_ref: current_ref
+ }
+ end
+end