summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRydkin Maxim <maks.rydkin@gmail.com>2017-03-21 01:05:52 +0300
committerRydkin Maxim <maks.rydkin@gmail.com>2017-04-04 21:11:25 +0300
commit63dbdb9f52d1aa56cbf1e15022623c306083fdd1 (patch)
tree3522813727c995ca4130a2332912e12c55b61d4a
parent4f748f74bc561ed6cc37f2c57077e72c0cda8c9a (diff)
downloadgitlab-ce-63dbdb9f52d1aa56cbf1e15022623c306083fdd1.tar.gz
add presenter for status badge
-rw-r--r--app/helpers/ci_status_helper.rb2
-rw-r--r--app/presenters/ci/pipeline_status_badge_presenter.rb13
-rw-r--r--app/serializers/pipeline_entity.rb2
3 files changed, 15 insertions, 2 deletions
diff --git a/app/helpers/ci_status_helper.rb b/app/helpers/ci_status_helper.rb
index 88e18500430..da4826567d4 100644
--- a/app/helpers/ci_status_helper.rb
+++ b/app/helpers/ci_status_helper.rb
@@ -123,6 +123,6 @@ module CiStatusHelper
end
def status_title(pipeline)
- "This pipeline is redundant as a newer pipeline exists (canceled by ##{pipeline.auto_canceled_by_id} pipeline)" if pipeline.auto_canceled_by_id? && pipeline.canceled?
+ Ci::PipelineStatusBadgePresenter.new(pipeline).status_title
end
end
diff --git a/app/presenters/ci/pipeline_status_badge_presenter.rb b/app/presenters/ci/pipeline_status_badge_presenter.rb
new file mode 100644
index 00000000000..bc6601c8a7f
--- /dev/null
+++ b/app/presenters/ci/pipeline_status_badge_presenter.rb
@@ -0,0 +1,13 @@
+module Ci
+ class PipelineStatusBadgePresenter < Gitlab::View::Presenter::Delegated
+ presents :pipeline
+
+ def auto_canceled?
+ canceled? && auto_canceled_by_id?
+ end
+
+ def status_title
+ "Pipeline is redundant and is auto-canceled by Pipeline ##{pipeline.auto_canceled_by_id}" if auto_canceled?
+ end
+ end
+end
diff --git a/app/serializers/pipeline_entity.rb b/app/serializers/pipeline_entity.rb
index 6dc84c925fe..82ee960f530 100644
--- a/app/serializers/pipeline_entity.rb
+++ b/app/serializers/pipeline_entity.rb
@@ -84,6 +84,6 @@ class PipelineEntity < Grape::Entity
end
def status_tooltip
- "This pipeline is redundant as a newer pipeline exists (canceled by ##{pipeline.auto_canceled_by_id} pipeline)" if pipeline.auto_canceled_by_id? && pipeline.canceled?
+ Ci::PipelineStatusBadgePresenter.new(pipeline).status_title
end
end