Commit 1b6c2c3c authored by Kamil Trzcinski's avatar Kamil Trzcinski Committed by Grzegorz Bizon

Introduce `cancelable` and `returnable` [ci skip]

parent 516dc7a5
module Gitlab
module Ci
module Status
module Status
class Cancelable < SimpleDelegator
extend Status::Extended
def has_action?(current_user)
can?(current_user, :update_build, subject)
end
def action_icon
'remove'
end
def action_path
cancel_namespace_project_build_path(subject.project.namespace, subject.project, subject)
end
def action_method
:post
end
def self.matches?(build)
build.cancelable?
end
end
end
end
end
end
...@@ -12,31 +12,6 @@ module Gitlab ...@@ -12,31 +12,6 @@ module Gitlab
@subject.project, @subject.project,
@subject.pipeline) @subject.pipeline)
end end
def has_action?(current_user)
(subject.cancelable? || subject.retryable?) &&
can?(current_user, :update_build, @subject)
end
def action_icon
case
when subject.cancelable? then 'icon_play'
when subject.retryable? then 'repeat'
end
end
def action_path
case
when subject.cancelable?
cancel_namespace_project_build_path(subject.project.namespace, subject.project, subject)
when subject.retryable?
retry_namespace_project_build_path(subject.project.namespace, subject.project, subject)
end
end
def action_method
:post
end
end end
end end
end end
......
...@@ -6,7 +6,7 @@ module Gitlab ...@@ -6,7 +6,7 @@ module Gitlab
private private
def extended_statuses def extended_statuses
[Stop, Play] [Stop, Play, Cancelable, Retryable]
end end
def core_status def core_status
......
...@@ -13,20 +13,12 @@ module Gitlab ...@@ -13,20 +13,12 @@ module Gitlab
'play' 'play'
end end
def icon
'icon_status_skipped'
end
def to_s
'play'
end
def has_action?(current_user) def has_action?(current_user)
can?(current_user, :update_build, subject) can?(current_user, :update_build, subject)
end end
def action_icon def action_icon
:play 'play'
end end
def action_path def action_path
......
module Gitlab
module Ci
module Status
module Status
class Retryable < SimpleDelegator
extend Status::Extended
def has_action?(current_user)
can?(current_user, :update_build, subject)
end
def action_icon
'repeat'
end
def action_path
retry_namespace_project_build_path(subject.project.namespace, subject.project, subject)
end
def action_method
:post
end
def self.matches?(build)
build.retryable?
end
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment