debian-mirror-gitlab/app/helpers/ci/pipeline_editor_helper.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

43 lines
1.9 KiB
Ruby
Raw Normal View History

2021-01-29 00:20:46 +05:30
# frozen_string_literal: true
module Ci
module PipelineEditorHelper
include ChecksCollaboration
def can_view_pipeline_editor?(project)
2021-04-17 20:07:23 +05:30
can_collaborate_with_project?(project)
2021-01-29 00:20:46 +05:30
end
2021-04-29 21:17:54 +05:30
def js_pipeline_editor_data(project)
2021-09-30 23:02:18 +05:30
initial_branch = params[:branch_name]
latest_commit = project.repository.commit(initial_branch) || project.commit
commit_sha = latest_commit ? latest_commit.sha : ''
2022-04-04 11:22:00 +05:30
total_branches = project.repository_exists? ? project.repository.branch_count : 0
2021-04-29 21:17:54 +05:30
{
"ci-config-path": project.ci_config_path_or_default,
2021-09-30 23:02:18 +05:30
"ci-examples-help-page-path" => help_page_path('ci/examples/index'),
"ci-help-page-path" => help_page_path('ci/index'),
"default-branch" => project.default_branch_or_main,
2021-04-29 21:17:54 +05:30
"empty-state-illustration-path" => image_path('illustrations/empty-state/empty-dag-md.svg'),
2021-09-30 23:02:18 +05:30
"initial-branch-name" => initial_branch,
2022-07-16 23:28:13 +05:30
"includes-help-page-path" => help_page_path('ci/yaml/includes'),
2022-06-21 17:19:12 +05:30
"lint-help-page-path" => help_page_path('ci/lint', anchor: 'check-cicd-syntax'),
"lint-unavailable-help-page-path" => help_page_path('ci/pipeline_editor/index', anchor: 'configuration-validation-currently-not-available-message'),
2021-10-27 15:23:28 +05:30
"needs-help-page-path" => help_page_path('ci/yaml/index', anchor: 'needs'),
2021-04-29 21:17:54 +05:30
"new-merge-request-path" => namespace_project_new_merge_request_path,
2021-09-30 23:02:18 +05:30
"pipeline_etag" => latest_commit ? graphql_etag_pipeline_sha_path(commit_sha) : '',
2021-06-08 01:23:25 +05:30
"pipeline-page-path" => project_pipelines_path(project),
2021-04-29 21:17:54 +05:30
"project-path" => project.path,
"project-full-path" => project.full_path,
"project-namespace" => project.namespace.full_path,
2021-09-30 23:02:18 +05:30
"runner-help-page-path" => help_page_path('ci/runners/index'),
2022-04-04 11:22:00 +05:30
"total-branches" => total_branches,
2021-10-27 15:23:28 +05:30
"yml-help-page-path" => help_page_path('ci/yaml/index')
2021-04-29 21:17:54 +05:30
}
end
2021-01-29 00:20:46 +05:30
end
end
2021-04-29 21:17:54 +05:30
2021-06-08 01:23:25 +05:30
Ci::PipelineEditorHelper.prepend_mod_with('Ci::PipelineEditorHelper')