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
Léo-Paul Géneau
gitlab-ce
Commits
14a02a6a
Commit
14a02a6a
authored
Jun 14, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve design after review
parent
006b6509
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
59 additions
and
69 deletions
+59
-69
app/controllers/projects/environments_controller.rb
app/controllers/projects/environments_controller.rb
+9
-8
app/models/ability.rb
app/models/ability.rb
+13
-3
app/models/ci/build.rb
app/models/ci/build.rb
+2
-1
app/models/deployment.rb
app/models/deployment.rb
+5
-5
app/models/environment.rb
app/models/environment.rb
+2
-3
app/services/create_deployment_service.rb
app/services/create_deployment_service.rb
+4
-16
app/views/layouts/nav/_project.html.haml
app/views/layouts/nav/_project.html.haml
+1
-1
app/views/projects/deployments/_commit.html.haml
app/views/projects/deployments/_commit.html.haml
+12
-0
app/views/projects/deployments/_deployment.html.haml
app/views/projects/deployments/_deployment.html.haml
+3
-14
app/views/projects/environments/_environment.html.haml
app/views/projects/environments/_environment.html.haml
+1
-12
app/views/projects/environments/index.html.haml
app/views/projects/environments/index.html.haml
+1
-2
app/views/projects/environments/new.html.haml
app/views/projects/environments/new.html.haml
+2
-1
app/views/projects/environments/show.html.haml
app/views/projects/environments/show.html.haml
+1
-1
doc/permissions/permissions.md
doc/permissions/permissions.md
+3
-2
No files found.
app/controllers/projects/environments_controller.rb
View file @
14a02a6a
...
@@ -19,20 +19,22 @@ class Projects::EnvironmentsController < Projects::ApplicationController
...
@@ -19,20 +19,22 @@ class Projects::EnvironmentsController < Projects::ApplicationController
def
create
def
create
@environment
=
project
.
environments
.
create
(
create_params
)
@environment
=
project
.
environments
.
create
(
create_params
)
unless
@environment
.
persisted?
render
'new'
return
end
if
@environment
.
persisted?
redirect_to
namespace_project_environment_path
(
project
.
namespace
,
project
,
@environment
)
redirect_to
namespace_project_environment_path
(
project
.
namespace
,
project
,
@environment
)
else
render
'new'
end
end
end
def
destroy
def
destroy
if
@environment
.
destroy
if
@environment
.
destroy
redirect_to
namespace_project_environments_path
(
project
.
namespace
,
project
),
notice:
'Environment was successfully removed.'
flash
[
:notice
]
=
'Environment was successfully removed.'
else
else
redirect_to
namespace_project_environments_path
(
project
.
namespace
,
project
),
alert:
'Failed to remove environment.'
flash
[
:alert
]
=
'Failed to remove environment.'
end
end
redirect_to
namespace_project_environments_path
(
project
.
namespace
,
project
)
end
end
private
private
...
@@ -42,7 +44,6 @@ class Projects::EnvironmentsController < Projects::ApplicationController
...
@@ -42,7 +44,6 @@ class Projects::EnvironmentsController < Projects::ApplicationController
end
end
def
environment
def
environment
@environment
||=
project
.
environments
.
find
(
params
[
:id
].
to_s
)
@environment
||=
project
.
environments
.
find_by!
(
id:
params
[
:id
])
@environment
||
render_404
end
end
end
end
app/models/ability.rb
View file @
14a02a6a
...
@@ -18,6 +18,8 @@ class Ability
...
@@ -18,6 +18,8 @@ class Ability
when
Namespace
then
namespace_abilities
(
user
,
subject
)
when
Namespace
then
namespace_abilities
(
user
,
subject
)
when
GroupMember
then
group_member_abilities
(
user
,
subject
)
when
GroupMember
then
group_member_abilities
(
user
,
subject
)
when
ProjectMember
then
project_member_abilities
(
user
,
subject
)
when
ProjectMember
then
project_member_abilities
(
user
,
subject
)
when
Deployment
then
deployment_abilities
(
user
,
subject
)
when
Environment
then
environment_abilities
(
user
,
subject
)
when
User
then
user_abilities
when
User
then
user_abilities
else
[]
else
[]
end
.
concat
(
global_abilities
(
user
))
end
.
concat
(
global_abilities
(
user
))
...
@@ -249,9 +251,7 @@ class Ability
...
@@ -249,9 +251,7 @@ class Ability
:create_container_image
,
:create_container_image
,
:update_container_image
,
:update_container_image
,
:create_environment
,
:create_environment
,
:update_environment
,
:create_deployment
:create_deployment
,
:update_deployment
,
]
]
end
end
...
@@ -269,6 +269,8 @@ class Ability
...
@@ -269,6 +269,8 @@ class Ability
@project_master_rules
||=
project_dev_rules
+
[
@project_master_rules
||=
project_dev_rules
+
[
:push_code_to_protected_branches
,
:push_code_to_protected_branches
,
:update_project_snippet
,
:update_project_snippet
,
:update_environment
,
:update_deployment
,
:admin_milestone
,
:admin_milestone
,
:admin_project_snippet
,
:admin_project_snippet
,
:admin_project_member
,
:admin_project_member
,
...
@@ -525,6 +527,14 @@ class Ability
...
@@ -525,6 +527,14 @@ class Ability
project_abilities
(
user
,
subject
.
project
)
project_abilities
(
user
,
subject
.
project
)
end
end
def
deployment_abilities
(
user
,
subject
)
project_abilities
(
user
,
subject
.
project
)
end
def
environment_abilities
(
user
,
subject
)
project_abilities
(
user
,
subject
.
project
)
end
private
private
def
restricted_public_level?
def
restricted_public_level?
...
...
app/models/ci/build.rb
View file @
14a02a6a
...
@@ -81,7 +81,8 @@ module Ci
...
@@ -81,7 +81,8 @@ module Ci
if
build
.
environment
.
present?
if
build
.
environment
.
present?
service
=
CreateDeploymentService
.
new
(
build
.
project
,
build
.
user
,
service
=
CreateDeploymentService
.
new
(
build
.
project
,
build
.
user
,
environment:
build
.
environment
,
environment:
build
.
environment
,
sha:
build
.
sha
,
ref:
build
.
ref
,
sha:
build
.
sha
,
ref:
build
.
ref
,
tag:
build
.
tag
)
tag:
build
.
tag
)
service
.
execute
(
build
)
service
.
execute
(
build
)
end
end
...
...
app/models/deployment.rb
View file @
14a02a6a
...
@@ -6,10 +6,10 @@ class Deployment < ActiveRecord::Base
...
@@ -6,10 +6,10 @@ class Deployment < ActiveRecord::Base
belongs_to
:user
belongs_to
:user
belongs_to
:deployable
,
polymorphic:
true
belongs_to
:deployable
,
polymorphic:
true
validates
_presence_of
:sha
validates
:sha
,
presence:
true
validates
_presence_of
:ref
validates
:ref
,
presence:
true
validates
_associated
:project
validates
:project
,
associated:
true
validates
_associated
:environment
validates
:environment
,
associated:
true
delegate
:name
,
to: :environment
,
prefix:
true
delegate
:name
,
to: :environment
,
prefix:
true
...
@@ -22,7 +22,7 @@ class Deployment < ActiveRecord::Base
...
@@ -22,7 +22,7 @@ class Deployment < ActiveRecord::Base
end
end
def
short_sha
def
short_sha
Commit
::
truncate_sha
(
sha
)
Commit
.
truncate_sha
(
sha
)
end
end
def
last?
def
last?
...
...
app/models/environment.rb
View file @
14a02a6a
...
@@ -5,13 +5,12 @@ class Environment < ActiveRecord::Base
...
@@ -5,13 +5,12 @@ class Environment < ActiveRecord::Base
validates
:name
,
validates
:name
,
presence:
true
,
presence:
true
,
uniqueness:
{
scope: :project_id
},
length:
{
within:
0
..
255
},
length:
{
within:
0
..
255
},
format:
{
with:
Gitlab
::
Regex
.
environment_name_regex
,
format:
{
with:
Gitlab
::
Regex
.
environment_name_regex
,
message:
Gitlab
::
Regex
.
environment_name_regex_message
}
message:
Gitlab
::
Regex
.
environment_name_regex_message
}
validates_uniqueness_of
:name
,
scope: :project_id
validates
:project
,
associated:
true
validates_associated
:project
def
last_deployment
def
last_deployment
deployments
.
last
deployments
.
last
...
...
app/services/create_deployment_service.rb
View file @
14a02a6a
...
@@ -2,7 +2,9 @@ require_relative 'base_service'
...
@@ -2,7 +2,9 @@ require_relative 'base_service'
class
CreateDeploymentService
<
BaseService
class
CreateDeploymentService
<
BaseService
def
execute
(
deployable
=
nil
)
def
execute
(
deployable
=
nil
)
environment
=
create_or_find_environment
(
params
[
:environment
])
environment
=
project
.
environments
.
find_or_create_by
(
name:
params
[
:environment
]
)
project
.
deployments
.
create
(
project
.
deployments
.
create
(
environment:
environment
,
environment:
environment
,
...
@@ -10,21 +12,7 @@ class CreateDeploymentService < BaseService
...
@@ -10,21 +12,7 @@ class CreateDeploymentService < BaseService
tag:
params
[
:tag
],
tag:
params
[
:tag
],
sha:
params
[
:sha
],
sha:
params
[
:sha
],
user:
current_user
,
user:
current_user
,
deployable:
deployable
,
deployable:
deployable
)
)
end
end
private
def
create_or_find_environment
(
environment
)
find_environment
(
environment
)
||
create_environment
(
environment
)
end
def
create_environment
(
environment
)
project
.
environments
.
create
(
name:
environment
)
end
def
find_environment
(
environment
)
project
.
environments
.
find_by
(
name:
environment
)
end
end
end
app/views/layouts/nav/_project.html.haml
View file @
14a02a6a
...
@@ -40,7 +40,7 @@
...
@@ -40,7 +40,7 @@
Code
Code
-
if
project_nav_tab?
:pipelines
-
if
project_nav_tab?
:pipelines
=
nav_link
(
controller:
:pipelines
)
do
=
nav_link
(
controller:
[
:pipelines
,
:builds
,
:environments
]
)
do
=
link_to
project_pipelines_path
(
@project
),
title:
'Pipelines'
,
class:
'shortcuts-pipelines'
do
=
link_to
project_pipelines_path
(
@project
),
title:
'Pipelines'
,
class:
'shortcuts-pipelines'
do
%span
%span
Pipelines
Pipelines
...
...
app/views/projects/deployments/_commit.html.haml
0 → 100644
View file @
14a02a6a
%div
.branch-commit
-
if
deployment
.
ref
=
link_to
deployment
.
ref
,
namespace_project_commits_path
(
@project
.
namespace
,
@project
,
deployment
.
ref
),
class:
"monospace"
·
=
link_to
deployment
.
short_sha
,
namespace_project_commit_path
(
@project
.
namespace
,
@project
,
deployment
.
sha
),
class:
"commit-id monospace"
%p
.commit-title
%span
-
if
commit_title
=
deployment
.
commit_title
=
link_to_gfm
commit_title
,
namespace_project_commit_path
(
@project
.
namespace
,
@project
,
deployment
.
sha
),
class:
"commit-row-message"
-
else
Cant find HEAD commit for this branch
app/views/projects/deployments/_deployment.html.haml
View file @
14a02a6a
...
@@ -3,29 +3,18 @@
...
@@ -3,29 +3,18 @@
%strong
=
"#
#{
deployment
.
iid
}
"
%strong
=
"#
#{
deployment
.
iid
}
"
%td
%td
%div
.branch-commit
=
render
'projects/deployments/commit'
,
deployment:
deployment
-
if
deployment
.
ref
=
link_to
deployment
.
ref
,
namespace_project_commits_path
(
@project
.
namespace
,
@project
,
deployment
.
ref
),
class:
"monospace"
·
=
link_to
deployment
.
short_sha
,
namespace_project_commit_path
(
@project
.
namespace
,
@project
,
deployment
.
sha
),
class:
"commit-id monospace"
%p
.commit-title
%span
-
if
commit_title
=
deployment
.
commit_title
=
link_to_gfm
commit_title
,
namespace_project_commit_path
(
@project
.
namespace
,
@project
,
deployment
.
sha
),
class:
"commit-row-message"
-
else
Cant find HEAD commit for this branch
%td
%td
-
if
deployment
.
deployable
-
if
deployment
.
deployable
=
link_to
namespace_project_build_path
(
@project
.
namespace
,
@project
,
deployment
.
deployable
)
,
class:
"monospace"
do
=
link_to
namespace_project_build_path
(
@project
.
namespace
,
@project
,
deployment
.
deployable
)
do
=
"
#{
deployment
.
deployable
.
name
}
(#
#{
deployment
.
deployable
.
id
}
)"
=
"
#{
deployment
.
deployable
.
name
}
(#
#{
deployment
.
deployable
.
id
}
)"
%td
%td
#{
time_ago_with_tooltip
(
deployment
.
created_at
)
}
#{
time_ago_with_tooltip
(
deployment
.
created_at
)
}
%td
%td
-
if
can?
(
current_user
,
:update_deployment
,
@projec
t
)
&&
deployment
.
deployable
-
if
can?
(
current_user
,
:update_deployment
,
deploymen
t
)
&&
deployment
.
deployable
.pull-right
.pull-right
=
link_to
retry_namespace_project_build_path
(
@project
.
namespace
,
@project
,
deployment
.
deployable
),
method: :post
,
class:
'btn btn-build'
do
=
link_to
retry_namespace_project_build_path
(
@project
.
namespace
,
@project
,
deployment
.
deployable
),
method: :post
,
class:
'btn btn-build'
do
-
if
deployment
.
last?
-
if
deployment
.
last?
...
...
app/views/projects/environments/_environment.html.haml
View file @
14a02a6a
...
@@ -7,18 +7,7 @@
...
@@ -7,18 +7,7 @@
%td
%td
-
if
last_deployment
-
if
last_deployment
%div
.branch-commit
=
render
'projects/deployments/commit'
,
deployment:
last_deployment
-
if
last_deployment
.
ref
=
link_to
last_deployment
.
ref
,
namespace_project_commits_path
(
@project
.
namespace
,
@project
,
last_deployment
.
ref
),
class:
"monospace"
·
=
link_to
last_deployment
.
short_sha
,
namespace_project_commit_path
(
@project
.
namespace
,
@project
,
last_deployment
.
sha
),
class:
"commit-id monospace"
%p
.commit-title
%span
-
if
commit_title
=
last_deployment
.
commit_title
=
link_to_gfm
commit_title
,
namespace_project_commit_path
(
@project
.
namespace
,
@project
,
last_deployment
.
sha
),
class:
"commit-row-message"
-
else
Cant find HEAD commit for this branch
-
else
-
else
%p
.commit-title
%p
.commit-title
No deployments yet
No deployments yet
...
...
app/views/projects/environments/index.html.haml
View file @
14a02a6a
...
@@ -20,5 +20,4 @@
...
@@ -20,5 +20,4 @@
%th
Environment
%th
Environment
%th
Last deployment
%th
Last deployment
%th
Date
%th
Date
-
@environments
.
each
do
|
environment
|
=
render
@environments
=
render
'environment'
,
environment:
environment
app/views/projects/environments/new.html.haml
View file @
14a02a6a
-
@no_container
=
true
-
page_title
"New Environment"
-
page_title
"New Environment"
=
render
"projects/pipelines/head"
=
render
"projects/pipelines/head"
...
@@ -6,7 +7,7 @@
...
@@ -6,7 +7,7 @@
%h4
.prepend-top-0
%h4
.prepend-top-0
New Environment
New Environment
=
form_for
@environment
,
url:
namespace_project_environments_path
(
@project
.
namespace
,
@project
),
html:
{
id:
"new-environment-form"
,
class:
"col-lg-9 js-new-environment-form js-requires-input
"
}
do
|
f
|
=
form_for
@environment
,
url:
namespace_project_environments_path
(
@project
.
namespace
,
@project
),
html:
{
class:
"col-lg-9
"
}
do
|
f
|
=
form_errors
(
@environment
)
=
form_errors
(
@environment
)
.form-group
.form-group
=
f
.
label
:name
,
'Environment name'
,
class:
'label-light'
=
f
.
label
:name
,
'Environment name'
,
class:
'label-light'
...
...
app/views/projects/environments/show.html.haml
View file @
14a02a6a
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
.col-md-3
.col-md-3
.nav-controls
.nav-controls
-
if
can?
(
current_user
,
:update_environment
,
@
projec
t
)
-
if
can?
(
current_user
,
:update_environment
,
@
environmen
t
)
=
link_to
'Destroy'
,
namespace_project_environment_path
(
@project
.
namespace
,
@project
,
@environment
),
data:
{
confirm:
'Are you sure?'
},
class:
'btn btn-danger'
,
method: :delete
=
link_to
'Destroy'
,
namespace_project_environment_path
(
@project
.
namespace
,
@project
,
@environment
),
data:
{
confirm:
'Are you sure?'
},
class:
'btn btn-danger'
,
method: :delete
-
if
@deployments
.
blank?
-
if
@deployments
.
blank?
...
...
doc/permissions/permissions.md
View file @
14a02a6a
...
@@ -28,7 +28,7 @@ documentation](../workflow/add-user/add-user.md).
...
@@ -28,7 +28,7 @@ documentation](../workflow/add-user/add-user.md).
| Manage labels | | ✓ | ✓ | ✓ | ✓ |
| Manage labels | | ✓ | ✓ | ✓ | ✓ |
| See a commit status | | ✓ | ✓ | ✓ | ✓ |
| See a commit status | | ✓ | ✓ | ✓ | ✓ |
| See a container registry | | ✓ | ✓ | ✓ | ✓ |
| See a container registry | | ✓ | ✓ | ✓ | ✓ |
| See
a environments
| | ✓ | ✓ | ✓ | ✓ |
| See
environments
| | ✓ | ✓ | ✓ | ✓ |
| Manage merge requests | | | ✓ | ✓ | ✓ |
| Manage merge requests | | | ✓ | ✓ | ✓ |
| Create new merge request | | | ✓ | ✓ | ✓ |
| Create new merge request | | | ✓ | ✓ | ✓ |
| Create new branches | | | ✓ | ✓ | ✓ |
| Create new branches | | | ✓ | ✓ | ✓ |
...
@@ -41,7 +41,7 @@ documentation](../workflow/add-user/add-user.md).
...
@@ -41,7 +41,7 @@ documentation](../workflow/add-user/add-user.md).
| Create or update commit status | | | ✓ | ✓ | ✓ |
| Create or update commit status | | | ✓ | ✓ | ✓ |
| Update a container registry | | | ✓ | ✓ | ✓ |
| Update a container registry | | | ✓ | ✓ | ✓ |
| Remove a container registry image | | | ✓ | ✓ | ✓ |
| Remove a container registry image | | | ✓ | ✓ | ✓ |
|
Manage environments
| | | ✓ | ✓ | ✓ |
|
Create new environments
| | | ✓ | ✓ | ✓ |
| Create new milestones | | | | ✓ | ✓ |
| Create new milestones | | | | ✓ | ✓ |
| Add new team members | | | | ✓ | ✓ |
| Add new team members | | | | ✓ | ✓ |
| Push to protected branches | | | | ✓ | ✓ |
| Push to protected branches | | | | ✓ | ✓ |
...
@@ -54,6 +54,7 @@ documentation](../workflow/add-user/add-user.md).
...
@@ -54,6 +54,7 @@ documentation](../workflow/add-user/add-user.md).
| Manage runners | | | | ✓ | ✓ |
| Manage runners | | | | ✓ | ✓ |
| Manage build triggers | | | | ✓ | ✓ |
| Manage build triggers | | | | ✓ | ✓ |
| Manage variables | | | | ✓ | ✓ |
| Manage variables | | | | ✓ | ✓ |
| Delete environments | | | | ✓ | ✓ |
| Switch visibility level | | | | | ✓ |
| Switch visibility level | | | | | ✓ |
| Transfer project to another namespace | | | | | ✓ |
| Transfer project to another namespace | | | | | ✓ |
| Remove project | | | | | ✓ |
| Remove project | | | | | ✓ |
...
...
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