Commit 82ee1d29 authored by Kamil Trzcinski's avatar Kamil Trzcinski

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

parent cd4a2270
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
@subject.project,
@subject.pipeline)
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
......
......@@ -6,7 +6,7 @@ module Gitlab
private
def extended_statuses
[Stop, Play]
[Stop, Play, Cancelable, Retryable]
end
def core_status
......
......@@ -13,20 +13,12 @@ module Gitlab
'play'
end
def icon
'icon_status_skipped'
end
def to_s
'play'
end
def has_action?(current_user)
can?(current_user, :update_build, subject)
end
def action_icon
:play
'play'
end
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