Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
cd4a2270
Commit
cd4a2270
authored
Dec 08, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve actions
parent
007255ed
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
110 additions
and
18 deletions
+110
-18
app/models/ci/build.rb
app/models/ci/build.rb
+4
-0
lib/gitlab/ci/status/build/common.rb
lib/gitlab/ci/status/build/common.rb
+8
-18
lib/gitlab/ci/status/build/factory.rb
lib/gitlab/ci/status/build/factory.rb
+4
-0
lib/gitlab/ci/status/build/play.rb
lib/gitlab/ci/status/build/play.rb
+47
-0
lib/gitlab/ci/status/build/stop.rb
lib/gitlab/ci/status/build/stop.rb
+47
-0
No files found.
app/models/ci/build.rb
View file @
cd4a2270
...
@@ -127,6 +127,10 @@ module Ci
...
@@ -127,6 +127,10 @@ module Ci
end
end
end
end
def
cancelable?
active?
end
def
retryable?
def
retryable?
project
.
builds_enabled?
&&
commands
.
present?
&&
complete?
project
.
builds_enabled?
&&
commands
.
present?
&&
complete?
end
end
...
...
lib/gitlab/ci/status/build/common.rb
View file @
cd4a2270
...
@@ -13,33 +13,23 @@ module Gitlab
...
@@ -13,33 +13,23 @@ module Gitlab
@subject
.
pipeline
)
@subject
.
pipeline
)
end
end
def
action_type
case
when
@subject
.
playable?
then
:playable
when
@subject
.
active?
then
:cancel
when
@subject
.
retryable?
then
:retry
end
end
def
has_action?
(
current_user
)
def
has_action?
(
current_user
)
action_type
&&
can?
(
current_user
,
:update_build
,
@subject
)
(
subject
.
cancelable?
||
subject
.
retryable?
)
&&
can?
(
current_user
,
:update_build
,
@subject
)
end
end
def
action_icon
def
action_icon
case
action_type
case
when
:playable
then
'remove'
when
subject
.
cancelable?
then
'icon_play'
when
:cancel
then
'icon_play'
when
subject
.
retryable?
then
'repeat'
when
:retry
then
'repeat'
end
end
end
end
def
action_path
def
action_path
case
action_type
case
when
:playable
when
subject
.
cancelable?
play_namespace_project_build_path
(
subject
.
project
.
namespace
,
subject
.
project
,
subject
)
when
:cancel
cancel_namespace_project_build_path
(
subject
.
project
.
namespace
,
subject
.
project
,
subject
)
cancel_namespace_project_build_path
(
subject
.
project
.
namespace
,
subject
.
project
,
subject
)
when
:retry
when
subject
.
retryable?
retry_namespace_project_build_path
(
subject
.
project
.
namespace
,
subject
.
project
,
subject
)
retry_namespace_project_build_path
(
subject
.
project
.
namespace
,
subject
.
project
,
subject
)
end
end
end
end
...
...
lib/gitlab/ci/status/build/factory.rb
View file @
cd4a2270
...
@@ -5,6 +5,10 @@ module Gitlab
...
@@ -5,6 +5,10 @@ module Gitlab
class
Factory
<
Status
::
Factory
class
Factory
<
Status
::
Factory
private
private
def
extended_statuses
[
Stop
,
Play
]
end
def
core_status
def
core_status
super
.
extend
(
Status
::
Build
::
Common
)
super
.
extend
(
Status
::
Build
::
Common
)
end
end
...
...
lib/gitlab/ci/status/build/play.rb
0 → 100644
View file @
cd4a2270
module
Gitlab
module
Ci
module
Status
module
Status
class
Play
<
SimpleDelegator
extend
Status
::
Extended
def
text
'play'
end
def
label
'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
end
def
action_path
play_namespace_project_build_path
(
subject
.
project
.
namespace
,
subject
.
project
,
subject
)
end
def
action_method
:post
end
def
self
.
matches?
(
build
)
build
.
playable?
&&
!
build
.
stops_environment?
end
end
end
end
end
end
lib/gitlab/ci/status/build/stop.rb
0 → 100644
View file @
cd4a2270
module
Gitlab
module
Ci
module
Status
module
Status
class
Play
<
SimpleDelegator
extend
Status
::
Extended
def
text
'stop'
end
def
label
'stop'
end
def
icon
'icon_status_skipped'
end
def
to_s
'stop'
end
def
has_action?
(
current_user
)
can?
(
current_user
,
:update_build
,
subject
)
end
def
action_icon
:play
end
def
action_path
play_namespace_project_build_path
(
subject
.
project
.
namespace
,
subject
.
project
,
subject
)
end
def
action_method
:post
end
def
self
.
matches?
(
build
)
build
.
playable?
&&
build
.
stops_environment?
end
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment