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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
5059d0b8
Commit
5059d0b8
authored
Dec 08, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Incorporate permission checks into new CI statuses
[ci skip]
parent
e0ce97fb
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
60 additions
and
49 deletions
+60
-49
lib/gitlab/ci/status/build/cancelable.rb
lib/gitlab/ci/status/build/cancelable.rb
+7
-5
lib/gitlab/ci/status/build/common.rb
lib/gitlab/ci/status/build/common.rb
+5
-5
lib/gitlab/ci/status/build/play.rb
lib/gitlab/ci/status/build/play.rb
+7
-5
lib/gitlab/ci/status/build/retryable.rb
lib/gitlab/ci/status/build/retryable.rb
+7
-5
lib/gitlab/ci/status/build/stop.rb
lib/gitlab/ci/status/build/stop.rb
+7
-5
lib/gitlab/ci/status/core.rb
lib/gitlab/ci/status/core.rb
+6
-7
lib/gitlab/ci/status/extended.rb
lib/gitlab/ci/status/extended.rb
+6
-2
lib/gitlab/ci/status/factory.rb
lib/gitlab/ci/status/factory.rb
+2
-2
lib/gitlab/ci/status/pipeline/common.rb
lib/gitlab/ci/status/pipeline/common.rb
+5
-5
lib/gitlab/ci/status/pipeline/success_with_warnings.rb
lib/gitlab/ci/status/pipeline/success_with_warnings.rb
+2
-2
lib/gitlab/ci/status/stage/common.rb
lib/gitlab/ci/status/stage/common.rb
+6
-6
No files found.
lib/gitlab/ci/status/build/cancelable.rb
View file @
5059d0b8
...
@@ -3,10 +3,10 @@ module Gitlab
...
@@ -3,10 +3,10 @@ module Gitlab
module
Status
module
Status
module
Status
module
Status
class
Cancelable
<
SimpleDelegator
class
Cancelable
<
SimpleDelegator
extend
Status
::
Extended
include
Status
::
Extended
def
has_action?
(
current_user
)
def
has_action?
can?
(
current_
user
,
:update_build
,
subject
)
can?
(
user
,
:update_build
,
subject
)
end
end
def
action_icon
def
action_icon
...
@@ -14,14 +14,16 @@ module Gitlab
...
@@ -14,14 +14,16 @@ module Gitlab
end
end
def
action_path
def
action_path
cancel_namespace_project_build_path
(
subject
.
project
.
namespace
,
subject
.
project
,
subject
)
cancel_namespace_project_build_path
(
subject
.
project
.
namespace
,
subject
.
project
,
subject
)
end
end
def
action_method
def
action_method
:post
:post
end
end
def
self
.
matches?
(
build
)
def
self
.
matches?
(
build
,
user
)
build
.
cancelable?
build
.
cancelable?
end
end
end
end
...
...
lib/gitlab/ci/status/build/common.rb
View file @
5059d0b8
...
@@ -3,14 +3,14 @@ module Gitlab
...
@@ -3,14 +3,14 @@ module Gitlab
module
Status
module
Status
module
Build
module
Build
module
Common
module
Common
def
has_details?
(
current_user
)
def
has_details?
can?
(
current_
user
,
:read_build
,
subject
)
can?
(
user
,
:read_build
,
subject
)
end
end
def
details_path
def
details_path
namespace_project_build_path
(
@
subject
.
project
.
namespace
,
namespace_project_build_path
(
subject
.
project
.
namespace
,
@
subject
.
project
,
subject
.
project
,
@
subject
.
pipeline
)
subject
.
pipeline
)
end
end
end
end
end
end
...
...
lib/gitlab/ci/status/build/play.rb
View file @
5059d0b8
...
@@ -3,7 +3,7 @@ module Gitlab
...
@@ -3,7 +3,7 @@ module Gitlab
module
Status
module
Status
module
Status
module
Status
class
Play
<
SimpleDelegator
class
Play
<
SimpleDelegator
extend
Status
::
Extended
include
Status
::
Extended
def
text
def
text
'play'
'play'
...
@@ -13,8 +13,8 @@ module Gitlab
...
@@ -13,8 +13,8 @@ module Gitlab
'play'
'play'
end
end
def
has_action?
(
current_user
)
def
has_action?
can?
(
current_
user
,
:update_build
,
subject
)
can?
(
user
,
:update_build
,
subject
)
end
end
def
action_icon
def
action_icon
...
@@ -22,14 +22,16 @@ module Gitlab
...
@@ -22,14 +22,16 @@ module Gitlab
end
end
def
action_path
def
action_path
play_namespace_project_build_path
(
subject
.
project
.
namespace
,
subject
.
project
,
subject
)
play_namespace_project_build_path
(
subject
.
project
.
namespace
,
subject
.
project
,
subject
)
end
end
def
action_method
def
action_method
:post
:post
end
end
def
self
.
matches?
(
build
)
def
self
.
matches?
(
build
,
user
)
build
.
playable?
&&
!
build
.
stops_environment?
build
.
playable?
&&
!
build
.
stops_environment?
end
end
end
end
...
...
lib/gitlab/ci/status/build/retryable.rb
View file @
5059d0b8
...
@@ -3,10 +3,10 @@ module Gitlab
...
@@ -3,10 +3,10 @@ module Gitlab
module
Status
module
Status
module
Status
module
Status
class
Retryable
<
SimpleDelegator
class
Retryable
<
SimpleDelegator
extend
Status
::
Extended
include
Status
::
Extended
def
has_action?
(
current_user
)
def
has_action?
can?
(
current_
user
,
:update_build
,
subject
)
can?
(
user
,
:update_build
,
subject
)
end
end
def
action_icon
def
action_icon
...
@@ -14,14 +14,16 @@ module Gitlab
...
@@ -14,14 +14,16 @@ module Gitlab
end
end
def
action_path
def
action_path
retry_namespace_project_build_path
(
subject
.
project
.
namespace
,
subject
.
project
,
subject
)
retry_namespace_project_build_path
(
subject
.
project
.
namespace
,
subject
.
project
,
subject
)
end
end
def
action_method
def
action_method
:post
:post
end
end
def
self
.
matches?
(
build
)
def
self
.
matches?
(
build
,
user
)
build
.
retryable?
build
.
retryable?
end
end
end
end
...
...
lib/gitlab/ci/status/build/stop.rb
View file @
5059d0b8
...
@@ -3,7 +3,7 @@ module Gitlab
...
@@ -3,7 +3,7 @@ module Gitlab
module
Status
module
Status
module
Status
module
Status
class
Play
<
SimpleDelegator
class
Play
<
SimpleDelegator
extend
Status
::
Extended
include
Status
::
Extended
def
text
def
text
'stop'
'stop'
...
@@ -21,8 +21,8 @@ module Gitlab
...
@@ -21,8 +21,8 @@ module Gitlab
'stop'
'stop'
end
end
def
has_action?
(
current_user
)
def
has_action?
can?
(
current_
user
,
:update_build
,
subject
)
can?
(
user
,
:update_build
,
subject
)
end
end
def
action_icon
def
action_icon
...
@@ -30,14 +30,16 @@ module Gitlab
...
@@ -30,14 +30,16 @@ module Gitlab
end
end
def
action_path
def
action_path
play_namespace_project_build_path
(
subject
.
project
.
namespace
,
subject
.
project
,
subject
)
play_namespace_project_build_path
(
subject
.
project
.
namespace
,
subject
.
project
,
subject
)
end
end
def
action_method
def
action_method
:post
:post
end
end
def
self
.
matches?
(
build
)
def
self
.
matches?
(
build
,
user
)
build
.
playable?
&&
build
.
stops_environment?
build
.
playable?
&&
build
.
stops_environment?
end
end
end
end
...
...
lib/gitlab/ci/status/core.rb
View file @
5059d0b8
...
@@ -6,8 +6,11 @@ module Gitlab
...
@@ -6,8 +6,11 @@ module Gitlab
class
Core
class
Core
include
Gitlab
::
Routing
.
url_helpers
include
Gitlab
::
Routing
.
url_helpers
def
initialize
(
subject
)
attr_reader
:subject
,
:user
def
initialize
(
subject
,
user
)
@subject
=
subject
@subject
=
subject
@user
=
user
end
end
def
icon
def
icon
...
@@ -18,10 +21,6 @@ module Gitlab
...
@@ -18,10 +21,6 @@ module Gitlab
raise
NotImplementedError
raise
NotImplementedError
end
end
def
title
"
#{
@subject
.
class
.
name
.
demodulize
}
:
#{
label
}
"
end
# Deprecation warning: this method is here because we need to maintain
# Deprecation warning: this method is here because we need to maintain
# backwards compatibility with legacy statuses. We often do something
# backwards compatibility with legacy statuses. We often do something
# like "ci-status ci-status-#{status}" to set CSS class.
# like "ci-status ci-status-#{status}" to set CSS class.
...
@@ -33,7 +32,7 @@ module Gitlab
...
@@ -33,7 +32,7 @@ module Gitlab
self
.
class
.
name
.
demodulize
.
downcase
.
underscore
self
.
class
.
name
.
demodulize
.
downcase
.
underscore
end
end
def
has_details?
(
_user
=
nil
)
def
has_details?
false
false
end
end
...
@@ -41,7 +40,7 @@ module Gitlab
...
@@ -41,7 +40,7 @@ module Gitlab
raise
NotImplementedError
raise
NotImplementedError
end
end
def
has_action?
(
_user
=
nil
)
def
has_action?
false
false
end
end
...
...
lib/gitlab/ci/status/extended.rb
View file @
5059d0b8
...
@@ -2,8 +2,12 @@ module Gitlab
...
@@ -2,8 +2,12 @@ module Gitlab
module
Ci
module
Ci
module
Status
module
Status
module
Extended
module
Extended
def
matches?
(
_subject
,
_user
)
extend
ActiveSupport
::
Concern
raise
NotImplementedError
class_methods
do
def
matches?
(
_subject
,
_user
)
raise
NotImplementedError
end
end
end
end
end
end
end
...
...
lib/gitlab/ci/status/factory.rb
View file @
5059d0b8
...
@@ -2,7 +2,7 @@ module Gitlab
...
@@ -2,7 +2,7 @@ module Gitlab
module
Ci
module
Ci
module
Status
module
Status
class
Factory
class
Factory
def
initialize
(
subject
,
user
=
nil
)
def
initialize
(
subject
,
user
)
@subject
=
subject
@subject
=
subject
@user
=
user
@user
=
user
end
end
...
@@ -32,7 +32,7 @@ module Gitlab
...
@@ -32,7 +32,7 @@ module Gitlab
def
core_status
def
core_status
Gitlab
::
Ci
::
Status
Gitlab
::
Ci
::
Status
.
const_get
(
simple_status
.
capitalize
)
.
const_get
(
simple_status
.
capitalize
)
.
new
(
@subject
)
.
new
(
@subject
,
@user
)
.
extend
(
self
.
class
.
common_helpers
)
.
extend
(
self
.
class
.
common_helpers
)
end
end
...
...
lib/gitlab/ci/status/pipeline/common.rb
View file @
5059d0b8
...
@@ -3,14 +3,14 @@ module Gitlab
...
@@ -3,14 +3,14 @@ module Gitlab
module
Status
module
Status
module
Pipeline
module
Pipeline
module
Common
module
Common
def
has_details?
(
current_user
)
def
has_details?
can?
(
current_
user
,
:read_pipeline
,
subject
)
can?
(
user
,
:read_pipeline
,
subject
)
end
end
def
details_path
def
details_path
namespace_project_pipeline_path
(
@
subject
.
project
.
namespace
,
namespace_project_pipeline_path
(
subject
.
project
.
namespace
,
@
subject
.
project
,
subject
.
project
,
@
subject
)
subject
)
end
end
def
has_action?
def
has_action?
...
...
lib/gitlab/ci/status/pipeline/success_with_warnings.rb
View file @
5059d0b8
...
@@ -3,7 +3,7 @@ module Gitlab
...
@@ -3,7 +3,7 @@ module Gitlab
module
Status
module
Status
module
Pipeline
module
Pipeline
class
SuccessWithWarnings
<
SimpleDelegator
class
SuccessWithWarnings
<
SimpleDelegator
extend
Status
::
Extended
include
Status
::
Extended
def
text
def
text
'passed'
'passed'
...
@@ -21,7 +21,7 @@ module Gitlab
...
@@ -21,7 +21,7 @@ module Gitlab
'success_with_warnings'
'success_with_warnings'
end
end
def
self
.
matches?
(
pipeline
)
def
self
.
matches?
(
pipeline
,
user
)
pipeline
.
success?
&&
pipeline
.
has_warnings?
pipeline
.
success?
&&
pipeline
.
has_warnings?
end
end
end
end
...
...
lib/gitlab/ci/status/stage/common.rb
View file @
5059d0b8
...
@@ -3,15 +3,15 @@ module Gitlab
...
@@ -3,15 +3,15 @@ module Gitlab
module
Status
module
Status
module
Stage
module
Stage
module
Common
module
Common
def
has_details?
(
current_user
)
def
has_details?
can?
(
current_
user
,
:read_pipeline
,
subject
)
can?
(
user
,
:read_pipeline
,
subject
)
end
end
def
details_path
def
details_path
namespace_project_pipeline_path
(
@
subject
.
project
.
namespace
,
namespace_project_pipeline_path
(
subject
.
project
.
namespace
,
@
subject
.
project
,
subject
.
project
,
@
subject
.
pipeline
,
subject
.
pipeline
,
anchor:
@
subject
.
name
)
anchor:
subject
.
name
)
end
end
def
has_action?
def
has_action?
...
...
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