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
6b99848b
Commit
6b99848b
authored
Feb 08, 2019
by
Shinya Maeda
Committed by
Filipa Lacerda
Feb 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move permission check of manual actions of deployments
parent
acb939d7
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
48 additions
and
50 deletions
+48
-50
app/assets/javascripts/environments/components/container.vue
app/assets/javascripts/environments/components/container.vue
+1
-9
app/assets/javascripts/environments/components/environment_item.vue
.../javascripts/environments/components/environment_item.vue
+2
-8
app/assets/javascripts/environments/components/environments_app.vue
.../javascripts/environments/components/environments_app.vue
+0
-5
app/assets/javascripts/environments/components/environments_table.vue
...avascripts/environments/components/environments_table.vue
+0
-8
app/assets/javascripts/environments/folder/environments_folder_bundle.js
...scripts/environments/folder/environments_folder_bundle.js
+0
-2
app/assets/javascripts/environments/folder/environments_folder_view.vue
...ascripts/environments/folder/environments_folder_view.vue
+0
-5
app/assets/javascripts/environments/index.js
app/assets/javascripts/environments/index.js
+0
-2
app/helpers/environments_helper.rb
app/helpers/environments_helper.rb
+0
-1
app/serializers/deployment_entity.rb
app/serializers/deployment_entity.rb
+8
-2
app/views/projects/environments/index.html.haml
app/views/projects/environments/index.html.haml
+0
-1
changelogs/unreleased/move-permission-check-manual-actions-on-deployments.yml
...d/move-permission-check-manual-actions-on-deployments.yml
+5
-0
spec/javascripts/environments/environment_item_spec.js
spec/javascripts/environments/environment_item_spec.js
+0
-2
spec/javascripts/environments/environment_table_spec.js
spec/javascripts/environments/environment_table_spec.js
+0
-1
spec/javascripts/environments/environments_app_spec.js
spec/javascripts/environments/environments_app_spec.js
+0
-1
spec/javascripts/environments/folder/environments_folder_view_spec.js
...ipts/environments/folder/environments_folder_view_spec.js
+0
-1
spec/serializers/deployment_entity_spec.rb
spec/serializers/deployment_entity_spec.rb
+28
-2
spec/serializers/environment_serializer_spec.rb
spec/serializers/environment_serializer_spec.rb
+4
-0
No files found.
app/assets/javascripts/environments/components/container.vue
View file @
6b99848b
...
...
@@ -22,10 +22,6 @@ export default {
type
:
Object
,
required
:
true
,
},
canCreateDeployment
:
{
type
:
Boolean
,
required
:
true
,
},
canReadEnvironment
:
{
type
:
Boolean
,
required
:
true
,
...
...
@@ -51,11 +47,7 @@ export default {
<slot
name=
"emptyState"
></slot>
<div
v-if=
"!isLoading && environments.length > 0"
class=
"table-holder"
>
<environment-table
:environments=
"environments"
:can-create-deployment=
"canCreateDeployment"
:can-read-environment=
"canReadEnvironment"
/>
<environment-table
:environments=
"environments"
:can-read-environment=
"canReadEnvironment"
/>
<table-pagination
v-if=
"pagination && pagination.totalPages > 1"
...
...
app/assets/javascripts/environments/components/environment_item.vue
View file @
6b99848b
...
...
@@ -47,12 +47,6 @@ export default {
default
:
()
=>
({}),
},
canCreateDeployment
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
canReadEnvironment
:
{
type
:
Boolean
,
required
:
false
,
...
...
@@ -151,7 +145,7 @@ export default {
},
actions
()
{
if
(
!
this
.
model
||
!
this
.
model
.
last_deployment
||
!
this
.
canCreateDeployment
)
{
if
(
!
this
.
model
||
!
this
.
model
.
last_deployment
)
{
return
[];
}
...
...
@@ -561,7 +555,7 @@ export default {
/>
<rollback-component
v-if=
"canRetry
&& canCreateDeployment
"
v-if=
"canRetry"
:is-last-deployment=
"isLastDeployment"
:retry-url=
"retryUrl"
/>
...
...
app/assets/javascripts/environments/components/environments_app.vue
View file @
6b99848b
...
...
@@ -24,10 +24,6 @@ export default {
type
:
Boolean
,
required
:
true
,
},
canCreateDeployment
:
{
type
:
Boolean
,
required
:
true
,
},
canReadEnvironment
:
{
type
:
Boolean
,
required
:
true
,
...
...
@@ -106,7 +102,6 @@ export default {
:is-loading=
"isLoading"
:environments=
"state.environments"
:pagination=
"state.paginationInformation"
:can-create-deployment=
"canCreateDeployment"
:can-read-environment=
"canReadEnvironment"
@
onChangePage=
"onChangePage"
>
...
...
app/assets/javascripts/environments/components/environments_table.vue
View file @
6b99848b
...
...
@@ -23,12 +23,6 @@ export default {
required
:
false
,
default
:
false
,
},
canCreateDeployment
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
},
methods
:
{
folderUrl
(
model
)
{
...
...
@@ -64,7 +58,6 @@ export default {
is=
"environment-item"
:key=
"`environment-item-$
{i}`"
:model="model"
:can-create-deployment="canCreateDeployment"
:can-read-environment="canReadEnvironment"
/>
...
...
@@ -79,7 +72,6 @@ export default {
v-for=
"(children, index) in model.children"
:key=
"`env-item-$
{i}-${index}`"
:model="children"
:can-create-deployment="canCreateDeployment"
:can-read-environment="canReadEnvironment"
/>
...
...
app/assets/javascripts/environments/folder/environments_folder_bundle.js
View file @
6b99848b
...
...
@@ -18,7 +18,6 @@ export default () =>
endpoint
:
environmentsData
.
environmentsDataEndpoint
,
folderName
:
environmentsData
.
environmentsDataFolderName
,
cssContainerClass
:
environmentsData
.
cssClass
,
canCreateDeployment
:
parseBoolean
(
environmentsData
.
environmentsDataCanCreateDeployment
),
canReadEnvironment
:
parseBoolean
(
environmentsData
.
environmentsDataCanReadEnvironment
),
};
},
...
...
@@ -28,7 +27,6 @@ export default () =>
endpoint
:
this
.
endpoint
,
folderName
:
this
.
folderName
,
cssContainerClass
:
this
.
cssContainerClass
,
canCreateDeployment
:
this
.
canCreateDeployment
,
canReadEnvironment
:
this
.
canReadEnvironment
,
},
});
...
...
app/assets/javascripts/environments/folder/environments_folder_view.vue
View file @
6b99848b
...
...
@@ -23,10 +23,6 @@ export default {
type
:
String
,
required
:
true
,
},
canCreateDeployment
:
{
type
:
Boolean
,
required
:
true
,
},
canReadEnvironment
:
{
type
:
Boolean
,
required
:
true
,
...
...
@@ -55,7 +51,6 @@ export default {
:is-loading=
"isLoading"
:environments=
"state.environments"
:pagination=
"state.paginationInformation"
:can-create-deployment=
"canCreateDeployment"
:can-read-environment=
"canReadEnvironment"
@
onChangePage=
"onChangePage"
/>
...
...
app/assets/javascripts/environments/index.js
View file @
6b99848b
...
...
@@ -20,7 +20,6 @@ export default () =>
helpPagePath
:
environmentsData
.
helpPagePath
,
cssContainerClass
:
environmentsData
.
cssClass
,
canCreateEnvironment
:
parseBoolean
(
environmentsData
.
canCreateEnvironment
),
canCreateDeployment
:
parseBoolean
(
environmentsData
.
canCreateDeployment
),
canReadEnvironment
:
parseBoolean
(
environmentsData
.
canReadEnvironment
),
};
},
...
...
@@ -32,7 +31,6 @@ export default () =>
helpPagePath
:
this
.
helpPagePath
,
cssContainerClass
:
this
.
cssContainerClass
,
canCreateEnvironment
:
this
.
canCreateEnvironment
,
canCreateDeployment
:
this
.
canCreateDeployment
,
canReadEnvironment
:
this
.
canReadEnvironment
,
},
});
...
...
app/helpers/environments_helper.rb
View file @
6b99848b
...
...
@@ -11,7 +11,6 @@ module EnvironmentsHelper
{
"endpoint"
=>
folder_project_environments_path
(
@project
,
@folder
,
format: :json
),
"folder-name"
=>
@folder
,
"can-create-deployment"
=>
can?
(
current_user
,
:create_deployment
,
@project
).
to_s
,
"can-read-environment"
=>
can?
(
current_user
,
:read_environment
,
@project
).
to_s
}
end
...
...
app/serializers/deployment_entity.rb
View file @
6b99848b
...
...
@@ -24,6 +24,12 @@ class DeploymentEntity < Grape::Entity
expose
:user
,
using:
UserEntity
expose
:commit
,
using:
CommitEntity
expose
:deployable
,
using:
JobEntity
expose
:manual_actions
,
using:
JobEntity
expose
:scheduled_actions
,
using:
JobEntity
expose
:manual_actions
,
using:
JobEntity
,
if:
->
(
*
)
{
can_create_deployment?
}
expose
:scheduled_actions
,
using:
JobEntity
,
if:
->
(
*
)
{
can_create_deployment?
}
private
def
can_create_deployment?
can?
(
request
.
current_user
,
:create_deployment
,
request
.
project
)
end
end
app/views/projects/environments/index.html.haml
View file @
6b99848b
...
...
@@ -2,7 +2,6 @@
-
page_title
_
(
"Environments"
)
#environments-list-view
{
data:
{
environments_data:
environments_list_data
,
"can-create-deployment"
=>
can?
(
current_user
,
:create_deployment
,
@project
).
to_s
,
"can-read-environment"
=>
can?
(
current_user
,
:read_environment
,
@project
).
to_s
,
"can-create-environment"
=>
can?
(
current_user
,
:create_environment
,
@project
).
to_s
,
"new-environment-path"
=>
new_project_environment_path
(
@project
),
...
...
changelogs/unreleased/move-permission-check-manual-actions-on-deployments.yml
0 → 100644
View file @
6b99848b
---
title
:
Move permission check of manual actions of deployments
merge_request
:
24660
author
:
type
:
other
spec/javascripts/environments/environment_item_spec.js
View file @
6b99848b
...
...
@@ -25,7 +25,6 @@ describe('Environment item', () => {
component
=
new
EnvironmentItem
({
propsData
:
{
model
:
mockItem
,
canCreateDeployment
:
false
,
canReadEnvironment
:
true
,
service
:
{},
},
...
...
@@ -117,7 +116,6 @@ describe('Environment item', () => {
component
=
new
EnvironmentItem
({
propsData
:
{
model
:
environment
,
canCreateDeployment
:
true
,
canReadEnvironment
:
true
,
service
:
{},
},
...
...
spec/javascripts/environments/environment_table_spec.js
View file @
6b99848b
...
...
@@ -26,7 +26,6 @@ describe('Environment table', () => {
vm
=
mountComponent
(
Component
,
{
environments
:
[
mockItem
],
canCreateDeployment
:
false
,
canReadEnvironment
:
true
,
});
...
...
spec/javascripts/environments/environments_app_spec.js
View file @
6b99848b
...
...
@@ -9,7 +9,6 @@ describe('Environment', () => {
const
mockData
=
{
endpoint
:
'
environments.json
'
,
canCreateEnvironment
:
true
,
canCreateDeployment
:
true
,
canReadEnvironment
:
true
,
cssContainerClass
:
'
container
'
,
newEnvironmentPath
:
'
environments/new
'
,
...
...
spec/javascripts/environments/folder/environments_folder_view_spec.js
View file @
6b99848b
...
...
@@ -13,7 +13,6 @@ describe('Environments Folder View', () => {
const
mockData
=
{
endpoint
:
'
environments.json
'
,
folderName
:
'
review
'
,
canCreateDeployment
:
true
,
canReadEnvironment
:
true
,
cssContainerClass
:
'
container
'
,
};
...
...
spec/serializers/deployment_entity_spec.rb
View file @
6b99848b
require
'spec_helper'
describe
DeploymentEntity
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
developer
}
let
(
:developer
)
{
create
(
:user
)
}
let
(
:reporter
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:request
)
{
double
(
'request'
)
}
let
(
:deployment
)
{
create
(
:deployment
)
}
let
(
:deployment
)
{
create
(
:deployment
,
deployable:
build
,
project:
project
)
}
let
(
:build
)
{
create
(
:ci_build
,
:manual
,
pipeline:
pipeline
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
,
user:
user
)
}
let
(
:entity
)
{
described_class
.
new
(
deployment
,
request:
request
)
}
subject
{
entity
.
as_json
}
before
do
project
.
add_developer
(
developer
)
project
.
add_reporter
(
reporter
)
allow
(
request
).
to
receive
(
:current_user
).
and_return
(
user
)
allow
(
request
).
to
receive
(
:project
).
and_return
(
project
)
end
it
'exposes internal deployment id'
do
...
...
@@ -23,6 +31,24 @@ describe DeploymentEntity do
expect
(
subject
).
to
include
(
:created_at
)
end
context
'when the pipeline has another manual action'
do
let
(
:other_build
)
{
create
(
:ci_build
,
:manual
,
name:
'another deploy'
,
pipeline:
pipeline
)
}
let!
(
:other_deployment
)
{
create
(
:deployment
,
deployable:
other_build
)
}
it
'returns another manual action'
do
expect
(
subject
[
:manual_actions
].
count
).
to
eq
(
1
)
expect
(
subject
[
:manual_actions
].
first
[
:name
]).
to
eq
(
'another deploy'
)
end
context
'when user is a reporter'
do
let
(
:user
)
{
reporter
}
it
'returns another manual action'
do
expect
(
subject
[
:manual_actions
]).
not_to
be_present
end
end
end
describe
'scheduled_actions'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
,
user:
user
)
}
...
...
spec/serializers/environment_serializer_spec.rb
View file @
6b99848b
...
...
@@ -10,6 +10,10 @@ describe EnvironmentSerializer do
.
represent
(
resource
)
end
before
do
project
.
add_developer
(
user
)
end
context
'when there is a single object provided'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:deployable
)
{
create
(
:ci_build
)
}
...
...
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