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
9c0a8cb5
Commit
9c0a8cb5
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
3acf4323
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 @
9c0a8cb5
...
...
@@ -3,10 +3,10 @@ module Gitlab
module
Status
module
Status
class
Cancelable
<
SimpleDelegator
extend
Status
::
Extended
include
Status
::
Extended
def
has_action?
(
current_user
)
can?
(
current_
user
,
:update_build
,
subject
)
def
has_action?
can?
(
user
,
:update_build
,
subject
)
end
def
action_icon
...
...
@@ -14,14 +14,16 @@ module Gitlab
end
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
def
action_method
:post
end
def
self
.
matches?
(
build
)
def
self
.
matches?
(
build
,
user
)
build
.
cancelable?
end
end
...
...
lib/gitlab/ci/status/build/common.rb
View file @
9c0a8cb5
...
...
@@ -3,14 +3,14 @@ module Gitlab
module
Status
module
Build
module
Common
def
has_details?
(
current_user
)
can?
(
current_
user
,
:read_build
,
subject
)
def
has_details?
can?
(
user
,
:read_build
,
subject
)
end
def
details_path
namespace_project_build_path
(
@
subject
.
project
.
namespace
,
@
subject
.
project
,
@
subject
.
pipeline
)
namespace_project_build_path
(
subject
.
project
.
namespace
,
subject
.
project
,
subject
.
pipeline
)
end
end
end
...
...
lib/gitlab/ci/status/build/play.rb
View file @
9c0a8cb5
...
...
@@ -3,7 +3,7 @@ module Gitlab
module
Status
module
Status
class
Play
<
SimpleDelegator
extend
Status
::
Extended
include
Status
::
Extended
def
text
'play'
...
...
@@ -13,8 +13,8 @@ module Gitlab
'play'
end
def
has_action?
(
current_user
)
can?
(
current_
user
,
:update_build
,
subject
)
def
has_action?
can?
(
user
,
:update_build
,
subject
)
end
def
action_icon
...
...
@@ -22,14 +22,16 @@ module Gitlab
end
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
def
action_method
:post
end
def
self
.
matches?
(
build
)
def
self
.
matches?
(
build
,
user
)
build
.
playable?
&&
!
build
.
stops_environment?
end
end
...
...
lib/gitlab/ci/status/build/retryable.rb
View file @
9c0a8cb5
...
...
@@ -3,10 +3,10 @@ module Gitlab
module
Status
module
Status
class
Retryable
<
SimpleDelegator
extend
Status
::
Extended
include
Status
::
Extended
def
has_action?
(
current_user
)
can?
(
current_
user
,
:update_build
,
subject
)
def
has_action?
can?
(
user
,
:update_build
,
subject
)
end
def
action_icon
...
...
@@ -14,14 +14,16 @@ module Gitlab
end
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
def
action_method
:post
end
def
self
.
matches?
(
build
)
def
self
.
matches?
(
build
,
user
)
build
.
retryable?
end
end
...
...
lib/gitlab/ci/status/build/stop.rb
View file @
9c0a8cb5
...
...
@@ -3,7 +3,7 @@ module Gitlab
module
Status
module
Status
class
Play
<
SimpleDelegator
extend
Status
::
Extended
include
Status
::
Extended
def
text
'stop'
...
...
@@ -21,8 +21,8 @@ module Gitlab
'stop'
end
def
has_action?
(
current_user
)
can?
(
current_
user
,
:update_build
,
subject
)
def
has_action?
can?
(
user
,
:update_build
,
subject
)
end
def
action_icon
...
...
@@ -30,14 +30,16 @@ module Gitlab
end
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
def
action_method
:post
end
def
self
.
matches?
(
build
)
def
self
.
matches?
(
build
,
user
)
build
.
playable?
&&
build
.
stops_environment?
end
end
...
...
lib/gitlab/ci/status/core.rb
View file @
9c0a8cb5
...
...
@@ -6,8 +6,11 @@ module Gitlab
class
Core
include
Gitlab
::
Routing
.
url_helpers
def
initialize
(
subject
)
attr_reader
:subject
,
:user
def
initialize
(
subject
,
user
)
@subject
=
subject
@user
=
user
end
def
icon
...
...
@@ -18,10 +21,6 @@ module Gitlab
raise
NotImplementedError
end
def
title
"
#{
@subject
.
class
.
name
.
demodulize
}
:
#{
label
}
"
end
# Deprecation warning: this method is here because we need to maintain
# backwards compatibility with legacy statuses. We often do something
# like "ci-status ci-status-#{status}" to set CSS class.
...
...
@@ -33,7 +32,7 @@ module Gitlab
self
.
class
.
name
.
demodulize
.
downcase
.
underscore
end
def
has_details?
(
_user
=
nil
)
def
has_details?
false
end
...
...
@@ -41,7 +40,7 @@ module Gitlab
raise
NotImplementedError
end
def
has_action?
(
_user
=
nil
)
def
has_action?
false
end
...
...
lib/gitlab/ci/status/extended.rb
View file @
9c0a8cb5
...
...
@@ -2,8 +2,12 @@ module Gitlab
module
Ci
module
Status
module
Extended
def
matches?
(
_subject
,
_user
)
raise
NotImplementedError
extend
ActiveSupport
::
Concern
class_methods
do
def
matches?
(
_subject
,
_user
)
raise
NotImplementedError
end
end
end
end
...
...
lib/gitlab/ci/status/factory.rb
View file @
9c0a8cb5
...
...
@@ -2,7 +2,7 @@ module Gitlab
module
Ci
module
Status
class
Factory
def
initialize
(
subject
,
user
=
nil
)
def
initialize
(
subject
,
user
)
@subject
=
subject
@user
=
user
end
...
...
@@ -32,7 +32,7 @@ module Gitlab
def
core_status
Gitlab
::
Ci
::
Status
.
const_get
(
simple_status
.
capitalize
)
.
new
(
@subject
)
.
new
(
@subject
,
@user
)
.
extend
(
self
.
class
.
common_helpers
)
end
...
...
lib/gitlab/ci/status/pipeline/common.rb
View file @
9c0a8cb5
...
...
@@ -3,14 +3,14 @@ module Gitlab
module
Status
module
Pipeline
module
Common
def
has_details?
(
current_user
)
can?
(
current_
user
,
:read_pipeline
,
subject
)
def
has_details?
can?
(
user
,
:read_pipeline
,
subject
)
end
def
details_path
namespace_project_pipeline_path
(
@
subject
.
project
.
namespace
,
@
subject
.
project
,
@
subject
)
namespace_project_pipeline_path
(
subject
.
project
.
namespace
,
subject
.
project
,
subject
)
end
def
has_action?
...
...
lib/gitlab/ci/status/pipeline/success_with_warnings.rb
View file @
9c0a8cb5
...
...
@@ -3,7 +3,7 @@ module Gitlab
module
Status
module
Pipeline
class
SuccessWithWarnings
<
SimpleDelegator
extend
Status
::
Extended
include
Status
::
Extended
def
text
'passed'
...
...
@@ -21,7 +21,7 @@ module Gitlab
'success_with_warnings'
end
def
self
.
matches?
(
pipeline
)
def
self
.
matches?
(
pipeline
,
user
)
pipeline
.
success?
&&
pipeline
.
has_warnings?
end
end
...
...
lib/gitlab/ci/status/stage/common.rb
View file @
9c0a8cb5
...
...
@@ -3,15 +3,15 @@ module Gitlab
module
Status
module
Stage
module
Common
def
has_details?
(
current_user
)
can?
(
current_
user
,
:read_pipeline
,
subject
)
def
has_details?
can?
(
user
,
:read_pipeline
,
subject
)
end
def
details_path
namespace_project_pipeline_path
(
@
subject
.
project
.
namespace
,
@
subject
.
project
,
@
subject
.
pipeline
,
anchor:
@
subject
.
name
)
namespace_project_pipeline_path
(
subject
.
project
.
namespace
,
subject
.
project
,
subject
.
pipeline
,
anchor:
subject
.
name
)
end
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