2021-03-29 11:09:30 -04:00
|
|
|
# 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
|
|
|
|
|
2021-04-20 08:09:30 -04:00
|
|
|
def project_sidebar_context(project, user, current_ref)
|
|
|
|
context_data = project_sidebar_context_data(project, user, current_ref)
|
|
|
|
|
|
|
|
Sidebars::Projects::Context.new(**context_data)
|
2021-04-12 08:09:15 -04:00
|
|
|
end
|
|
|
|
|
2021-03-29 11:09:30 -04:00
|
|
|
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
|
2021-04-12 08:09:15 -04:00
|
|
|
|
2021-04-20 08:09:30 -04:00
|
|
|
def project_sidebar_context_data(project, user, current_ref)
|
2021-04-12 08:09:15 -04:00
|
|
|
{
|
|
|
|
current_user: user,
|
2021-04-15 14:09:01 -04:00
|
|
|
container: project,
|
2021-04-20 08:09:30 -04:00
|
|
|
learn_gitlab_experiment_enabled: learn_gitlab_experiment_enabled?(project),
|
2021-04-30 17:10:23 -04:00
|
|
|
learn_gitlab_experiment_tracking_category: learn_gitlab_experiment_tracking_category,
|
2021-04-27 08:10:12 -04:00
|
|
|
current_ref: current_ref,
|
2021-04-29 05:10:11 -04:00
|
|
|
jira_issues_integration: project_jira_issues_integration?,
|
2021-04-30 11:09:50 -04:00
|
|
|
can_view_pipeline_editor: can_view_pipeline_editor?(project),
|
|
|
|
show_cluster_hint: show_gke_cluster_integration_callout?(project)
|
2021-04-12 08:09:15 -04:00
|
|
|
}
|
|
|
|
end
|
2021-03-29 11:09:30 -04:00
|
|
|
end
|
2021-04-29 11:10:07 -04:00
|
|
|
|
|
|
|
SidebarsHelper.prepend_if_ee('EE::SidebarsHelper')
|