diff options
author | Shinya Maeda <shinya@gitlab.com> | 2019-03-06 15:34:38 +0700 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2019-03-19 23:19:27 +0700 |
commit | aee119c0cd44edd008f3167258bf45cb94ee5522 (patch) | |
tree | 53d2134cfbff85361f4875a1aa8eed075a282657 /app/presenters/ci | |
parent | 7fb9dff43dcf56472e22be7a26805ee5fa339e8b (diff) | |
download | gitlab-ce-aee119c0cd44edd008f3167258bf45cb94ee5522.tar.gz |
Update pipeline detail view to accommodate post-merge pipelines
Commit changes
Add spec
Add changelog
fix
fix
Fix
Fix spec
Finish spec
ok
nice
ok
ok
ok
fix
Diffstat (limited to 'app/presenters/ci')
-rw-r--r-- | app/presenters/ci/pipeline_presenter.rb | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/app/presenters/ci/pipeline_presenter.rb b/app/presenters/ci/pipeline_presenter.rb index 57daf04efc6..1c1347c5a57 100644 --- a/app/presenters/ci/pipeline_presenter.rb +++ b/app/presenters/ci/pipeline_presenter.rb @@ -3,6 +3,7 @@ module Ci class PipelinePresenter < Gitlab::View::Presenter::Delegated include Gitlab::Utils::StrongMemoize + include ActionView::Helpers::UrlHelper # We use a class method here instead of a constant, allowing EE to redefine # the returned `Hash` more easily. @@ -32,5 +33,57 @@ module Ci "Pipeline is redundant and is auto-canceled by Pipeline ##{auto_canceled_by_id}" end end + + def ref_text + if pipeline.detached_merge_request_pipeline? + _("for %{link_to_merge_request} with %{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.merge_request_pipeline? + _("for %{link_to_merge_request} with %{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 + if pipeline.ref_exists? + _("for %{link_to_pipeline_ref}").html_safe % { link_to_pipeline_ref: link_to_pipeline_ref } + else + _("for %{ref}") % { ref: content_tag(:span, pipeline.ref, class: 'ref-name') } + end + end + end + + def link_to_pipeline_ref + link_to(pipeline.ref, + project_commits_path(pipeline.project, pipeline.ref), + class: "ref-name") + end + + def link_to_merge_request + return unless merge_request_presenter + + link_to(merge_request_presenter.to_reference, + project_merge_request_path(merge_request_presenter.project, merge_request_presenter), + class: 'mr-iid') + end + + def link_to_merge_request_source_branch + return unless merge_request_presenter + + link_to(merge_request_presenter.source_branch, + merge_request_presenter.source_branch_commits_path, + class: 'ref-name') + end + + def link_to_merge_request_target_branch + return unless merge_request_presenter + + link_to(merge_request_presenter.target_branch, + merge_request_presenter.target_branch_commits_path, + class: 'ref-name') + end + + private + + def merge_request_presenter + return unless pipeline.triggered_by_merge_request? + + @merge_request_presenter ||= pipeline.merge_request.present(current_user: current_user) + end end end |