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.

53 lines
2.4 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
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'),
2022-08-13 15:12:31 +05:30
"ci-lint-path" => project_ci_lint_path(project),
2023-05-27 22:25:52 +05:30
"ci-troubleshooting-path" => help_page_path('ci/troubleshooting', anchor: 'common-cicd-issues'),
2021-09-30 23:02:18 +05:30
"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'),
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,
2022-11-25 23:54:43 +05:30
"pipeline_etag" => latest_commit ? graphql_etag_pipeline_sha_path(latest_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,
2022-08-27 11:52:29 +05:30
"simulate-pipeline-help-page-path" => help_page_path('ci/pipeline_editor/index', anchor: 'simulate-a-cicd-pipeline'),
2022-04-04 11:22:00 +05:30
"total-branches" => total_branches,
2022-11-25 23:54:43 +05:30
"uses-external-config" => uses_external_config?(project) ? 'true' : 'false',
2022-07-23 23:45:48 +05:30
"validate-tab-illustration-path" => image_path('illustrations/project-run-CICD-pipelines-sm.svg'),
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
2022-11-25 23:54:43 +05:30
private
def uses_external_config?(project)
ci_config_source = Gitlab::Ci::ProjectConfig.new(project: project, sha: nil).source
[:external_project_source, :remote_source].include?(ci_config_source)
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')