2021-03-11 19:13:27 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module LearnGitlabHelper
|
2021-11-11 11:23:49 +05:30
|
|
|
def learn_gitlab_enabled?(project)
|
2021-03-11 19:13:27 +05:30
|
|
|
return false unless current_user
|
|
|
|
|
|
|
|
learn_gitlab_onboarding_available?(project)
|
|
|
|
end
|
|
|
|
|
|
|
|
def onboarding_actions_data(project)
|
|
|
|
attributes = onboarding_progress(project).attributes.symbolize_keys
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
action_urls.to_h do |action, url|
|
2021-03-11 19:13:27 +05:30
|
|
|
[
|
|
|
|
action,
|
|
|
|
url: url,
|
2021-04-17 20:07:23 +05:30
|
|
|
completed: attributes[OnboardingProgress.column_name(action)].present?,
|
|
|
|
svg: image_path("learn_gitlab/#{action}.svg")
|
2021-03-11 19:13:27 +05:30
|
|
|
]
|
2021-04-29 21:17:54 +05:30
|
|
|
end
|
2021-03-11 19:13:27 +05:30
|
|
|
end
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
def onboarding_sections_data
|
|
|
|
{
|
|
|
|
workspace: {
|
|
|
|
svg: image_path("learn_gitlab/section_workspace.svg")
|
|
|
|
},
|
|
|
|
plan: {
|
|
|
|
svg: image_path("learn_gitlab/section_plan.svg")
|
|
|
|
},
|
|
|
|
deploy: {
|
|
|
|
svg: image_path("learn_gitlab/section_deploy.svg")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def learn_gitlab_onboarding_available?(project)
|
|
|
|
OnboardingProgress.onboarding?(project.namespace) &&
|
|
|
|
LearnGitlab::Project.new(current_user).available?
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
2021-03-11 19:13:27 +05:30
|
|
|
|
|
|
|
def action_urls
|
2021-06-08 01:23:25 +05:30
|
|
|
LearnGitlab::Onboarding::ACTION_ISSUE_IDS.transform_values { |id| project_issue_url(learn_gitlab_project, id) }
|
|
|
|
.merge(LearnGitlab::Onboarding::ACTION_DOC_URLS)
|
2021-03-11 19:13:27 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def learn_gitlab_project
|
2021-06-08 01:23:25 +05:30
|
|
|
@learn_gitlab_project ||= LearnGitlab::Project.new(current_user).project
|
2021-03-11 19:13:27 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def onboarding_progress(project)
|
|
|
|
OnboardingProgress.find_by(namespace: project.namespace) # rubocop: disable CodeReuse/ActiveRecord
|
|
|
|
end
|
|
|
|
end
|