Class: Ci::PipelinePresenter
Class Method Summary
collapse
-
.failure_reasons ⇒ Object
We use a class method here instead of a constant, allowing EE to redefine the returned ‘Hash` more easily.
Instance Method Summary
collapse
#initialize
#delegator_override, #delegator_override_with, #delegator_target, validator, validators, verify!
#__subject__, #can?, #declarative_policy_delegate, #is_a?, #path_with_line_numbers, #present, #url_builder, #web_path, #web_url
#can?
includes_helpers, redirect_legacy_paths, url_helpers
Class Method Details
.failure_reasons ⇒ Object
We use a class method here instead of a constant, allowing EE to redefine the returned ‘Hash` more easily.
11
12
13
14
15
16
17
18
19
20
|
# File 'app/presenters/ci/pipeline_presenter.rb', line 11
def self.failure_reasons
{ unknown_failure: 'The reason for the pipeline failure is unknown.',
config_error: 'The pipeline failed due to an error on the CI/CD configuration file.',
external_validation_failure: 'The external pipeline validation failed.',
user_not_verified: 'The pipeline failed due to the user not being verified',
size_limit_exceeded: 'The pipeline size limit was exceeded.',
job_activity_limit_exceeded: 'The pipeline job activity limit was exceeded.',
deployments_limit_exceeded: 'The pipeline deployments limit was exceeded.',
project_deleted: 'The project associated with this pipeline was deleted.' }
end
|
Instance Method Details
#coverage ⇒ Object
62
63
64
65
66
|
# File 'app/presenters/ci/pipeline_presenter.rb', line 62
def coverage
return unless pipeline.coverage.present?
'%.2f' % pipeline.coverage
end
|
#downloadable_path_for_report_type(file_type) ⇒ Object
112
113
114
115
116
117
118
119
120
121
|
# File 'app/presenters/ci/pipeline_presenter.rb', line 112
def downloadable_path_for_report_type(file_type)
if (job_artifact = batch_lookup_report_artifact_for_file_type(file_type)) &&
can?(current_user, :read_build, job_artifact.job)
download_project_job_artifacts_path(
job_artifact.project,
job_artifact.job,
file_type: file_type,
proxy: true)
end
end
|
#event_type_name ⇒ Object
55
56
57
58
59
|
# File 'app/presenters/ci/pipeline_presenter.rb', line 55
def event_type_name
localized_names.fetch(pipeline.merge_request_event_type, s_('Pipeline|Pipeline'))
end
|
#failed_builds ⇒ Object
25
26
27
28
29
30
31
|
# File 'app/presenters/ci/pipeline_presenter.rb', line 25
def failed_builds
return [] unless can?(current_user, :read_build, pipeline)
strong_memoize(:failed_builds) do
pipeline.builds.latest.failed
end
end
|
#failure_reason ⇒ Object
34
35
36
37
38
39
|
# File 'app/presenters/ci/pipeline_presenter.rb', line 34
def failure_reason
return unless pipeline.failure_reason?
self.class.failure_reasons[pipeline.failure_reason.to_sym] ||
pipeline.failure_reason
end
|
#link_to_merge_request ⇒ Object
96
97
98
99
100
101
102
|
# File 'app/presenters/ci/pipeline_presenter.rb', line 96
def link_to_merge_request
return unless merge_request_presenter
ApplicationController.helpers.link_to(merge_request_presenter.to_reference,
project_merge_request_path(merge_request_presenter.project, merge_request_presenter),
class: 'mr-iid')
end
|
#link_to_merge_request_source_branch ⇒ Object
104
105
106
|
# File 'app/presenters/ci/pipeline_presenter.rb', line 104
def link_to_merge_request_source_branch
merge_request_presenter&.source_branch_link
end
|
#link_to_merge_request_target_branch ⇒ Object
108
109
110
|
# File 'app/presenters/ci/pipeline_presenter.rb', line 108
def link_to_merge_request_target_branch
merge_request_presenter&.target_branch_link
end
|
#link_to_pipeline_ref ⇒ Object
90
91
92
93
94
|
# File 'app/presenters/ci/pipeline_presenter.rb', line 90
def link_to_pipeline_ref
ApplicationController.helpers.link_to(pipeline.ref,
project_commits_path(pipeline.project, pipeline.ref),
class: "ref-name gl-link gl-bg-blue-50 gl-rounded-base gl-px-2")
end
|
#localized_names ⇒ Object
47
48
49
50
51
52
53
|
# File 'app/presenters/ci/pipeline_presenter.rb', line 47
def localized_names
{
merge_train: s_('Pipeline|Merge train pipeline'),
merged_result: s_('Pipeline|Merged result pipeline'),
detached: s_('Pipeline|Merge request pipeline')
}.freeze
end
|
#ref_text ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'app/presenters/ci/pipeline_presenter.rb', line 68
def ref_text
if pipeline.detached_merge_request_pipeline?
_("Related merge request %{link_to_merge_request} to merge %{link_to_merge_request_source_branch}")
.html_safe % {
link_to_merge_request: link_to_merge_request,
link_to_merge_request_source_branch: link_to_merge_request_source_branch
}
elsif pipeline.merged_result_pipeline?
_("Related merge request %{link_to_merge_request} to merge %{link_to_merge_request_source_branch} into %{link_to_merge_request_target_branch}")
.html_safe % {
link_to_merge_request: link_to_merge_request,
link_to_merge_request_source_branch: link_to_merge_request_source_branch,
link_to_merge_request_target_branch: link_to_merge_request_target_branch
}
elsif pipeline.ref && pipeline.ref_exists?
_("For %{link_to_pipeline_ref}")
.html_safe % { link_to_pipeline_ref: link_to_pipeline_ref }
elsif pipeline.ref
_("For %{ref}").html_safe % { ref: plain_ref_name }
end
end
|
#status_title ⇒ Object
41
42
43
44
45
|
# File 'app/presenters/ci/pipeline_presenter.rb', line 41
def status_title
if auto_canceled?
"Pipeline is redundant and is auto-canceled by Pipeline ##{auto_canceled_by_id}"
end
end
|