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
Tatuya Kamada
gitlab-ce
Commits
4f00b93d
Commit
4f00b93d
authored
Jun 11, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add deployment views
parent
907c0e67
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
74 additions
and
33 deletions
+74
-33
app/controllers/projects/environments_controller.rb
app/controllers/projects/environments_controller.rb
+28
-1
app/services/create_deployment_service.rb
app/services/create_deployment_service.rb
+2
-9
app/views/projects/deployments/_deployment.html.haml
app/views/projects/deployments/_deployment.html.haml
+6
-8
app/views/projects/environments/_environment.html.haml
app/views/projects/environments/_environment.html.haml
+4
-5
app/views/projects/environments/index.html.haml
app/views/projects/environments/index.html.haml
+7
-4
app/views/projects/environments/new.html.haml
app/views/projects/environments/new.html.haml
+15
-0
app/views/projects/environments/show.html.haml
app/views/projects/environments/show.html.haml
+10
-5
app/views/projects/pipelines/_head.html.haml
app/views/projects/pipelines/_head.html.haml
+1
-0
config/routes.rb
config/routes.rb
+1
-1
No files found.
app/controllers/projects/environments_controller.rb
View file @
4f00b93d
class
Projects::EnvironmentsController
<
Projects
::
ApplicationController
layout
'project'
before_action
:authorize_read_environment!
before_action
:environment
,
only:
[
:show
]
before_action
:environment
,
only:
[
:show
,
:destroy
]
def
index
@environments
=
project
.
environments
end
def
show
@deployments
=
environment
.
deployments
.
order
(
id: :desc
).
page
(
params
[
:page
]).
per
(
30
)
end
def
new
@environment
=
project
.
environments
.
new
end
def
create
@environment
=
project
.
environments
.
create
(
create_params
)
unless
@environment
.
persisted?
render
'new'
return
end
redirect_to
namespace_project_environment_path
(
project
.
namespace
,
project
,
@environment
)
end
def
destroy
if
@environment
.
destroy
redirect_to
namespace_project_environments_path
(
project
.
namespace
,
project
),
notice:
'Environment was successfully removed.'
else
redirect_to
namespace_project_environments_path
(
project
.
namespace
,
project
),
alert:
'Failed to remove environment.'
end
end
private
def
create_params
params
.
require
(
:environment
).
permit
(
:name
)
end
def
environment
@environment
||=
project
.
environments
.
find
(
params
[
:id
].
to_s
)
@environment
||
render_404
...
...
app/services/create_deployment_service.rb
View file @
4f00b93d
...
...
@@ -2,7 +2,8 @@ require_relative 'base_service'
class
CreateDeploymentService
<
BaseService
def
execute
(
deployable
)
environment
=
find_or_create_environment
(
params
[
:environment
])
environment
=
find_environment
(
params
[
:environment
])
return
error
(
'no environment'
)
unless
environmnet
deployment
=
create_deployment
(
environment
,
deployable
)
if
deployment
.
persisted?
...
...
@@ -14,14 +15,6 @@ class CreateDeploymentService < BaseService
private
def
find_or_create_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
...
...
app/views/projects/deployments/_deployment.html.haml
View file @
4f00b93d
%tr
.deployment
%td
%strong
=
"#
#{
environment
.
id
}
"
%strong
=
"#
#{
deployment
.
i
id
}
"
%td
%div
.branch-commit
-
if
deployment
.
ref
=
link_to
las
t
.
ref
,
namespace_project_commits_path
(
@project
.
namespace
,
@project
,
deployment
.
ref
),
class:
"monospace"
=
link_to
deploymen
t
.
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"
...
...
@@ -18,15 +18,13 @@
%td
-
if
deployment
.
deployable
=
link_to
[
@project
.
namespace
.
becomes
(
Namespace
),
@project
,
deployment
.
deployable
]
,
class:
"monospace"
do
=
link_to
namespace_project_build_path
(
@project
.
namespace
,
@project
,
deployment
.
deployable
)
,
class:
"monospace"
do
=
"
#{
deployment
.
deployable
.
name
}
(#
#{
deployment
.
deployable
.
id
}
)"
%td
%p
%i
.fa.fa-calendar
#{
time_ago_with_tooltip
(
deployment
.
created_at
)
}
#{
time_ago_with_tooltip
(
deployment
.
created_at
)
}
%td
-
if
can?
(
current_user
,
:update_deployment
,
@project
)
&&
deployment
.
deployable
=
link_to
[
@project
.
namespace
.
becomes
(
Namespace
),
@project
,
deployment
.
deployable
,
:retry
],
method: :post
,
title:
'Retry'
,
class:
'btn btn-build'
.pull-right
=
link_to
'Retry'
,
retry_namespace_project_build_path
(
@project
.
namespace
,
@project
,
deployment
.
deployable
),
method: :post
,
class:
'btn btn-build'
app/views/projects/environments/_environment.html.haml
View file @
4f00b93d
...
...
@@ -9,7 +9,7 @@
-
if
last_deployment
%div
.branch-commit
-
if
last_deployment
.
ref
=
link_to
last
.
ref
,
namespace_project_commits_path
(
@project
.
namespace
,
@project
,
last_deployment
.
ref
),
class:
"monospace"
=
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"
...
...
@@ -24,9 +24,8 @@
No deployments yet
%td
%p
%i
.fa.fa-calendar
#{
time_ago_with_tooltip
(
last_deployment
.
created_at
)
}
-
if
last_deployment
%p
#{
time_ago_with_tooltip
(
last_deployment
.
created_at
)
}
%td
app/views/projects/environments/index.html.haml
View file @
4f00b93d
...
...
@@ -3,16 +3,19 @@
=
render
"projects/pipelines/head"
%div
{
class:
(
container_class
)
}
.gray-content-block
Environments for this project
-
if
can?
(
current_user
,
:create_environment
,
@project
)
.top-area
.nav-controls
=
link_to
new_namespace_project_environment_path
(
@project
.
namespace
,
@project
),
class:
'btn btn-create'
do
New environment
%ul
.content-list
%ul
.content-list
.environments
-
if
@environments
.
blank?
%li
.nothing-here-block
No environments to show
-
else
.table-holder
%table
.table
.builds
%table
.table
%tbody
%th
Environment
%th
Last deployment
...
...
app/views/projects/environments/new.html.haml
0 → 100644
View file @
4f00b93d
-
page_title
"New Environment"
%h3
.page-title
New Environment
%hr
=
form_for
@environment
,
url:
namespace_project_environments_path
(
@project
.
namespace
,
@project
),
html:
{
id:
"new-environment-form"
,
class:
"form-horizontal js-new-environment-form js-requires-input"
}
do
|
f
|
=
form_errors
(
@environment
)
.form-group
=
f
.
label
:ref
,
'Name'
,
class:
'control-label'
.col-sm-10
=
f
.
text_field
:name
,
required:
true
,
tabindex:
2
,
class:
'form-control'
.form-actions
=
f
.
submit
'Create'
,
class:
'btn btn-create'
,
tabindex:
3
=
link_to
'Cancel'
,
namespace_project_environments_path
(
@project
.
namespace
,
@project
),
class:
'btn btn-cancel'
app/views/projects/environments/show.html.haml
View file @
4f00b93d
...
...
@@ -3,21 +3,26 @@
=
render
"projects/pipelines/head"
%div
{
class:
(
container_class
)
}
.gray-content-block
Latest deployments for
%strong
=
@environment
.
name
.top-area
.col-md-9
%h3
=
@environment
.
name
.
titleize
.col-md-3
.nav-controls
=
link_to
'Destroy'
,
namespace_project_environment_path
(
@project
.
namespace
,
@project
,
@environment
),
data:
{
confirm:
'Are you sure?'
},
class:
'btn btn-danger'
,
method: :post
%ul
.content-list
-
if
@deployments
.
blank?
%li
.nothing-here-block
No deployment
for specific environment
.nothing-here-block
No deployment
s for
#{
@environment
.
name
}
-
else
.table-holder
%table
.table.builds
%thead
%tr
%th
ID
%th
Commit
%th
Context
%th
Build
%th
Date
%th
...
...
app/views/projects/pipelines/_head.html.haml
View file @
4f00b93d
...
...
@@ -19,3 +19,4 @@
=
link_to
project_environments_path
(
@project
),
title:
'Environments'
,
class:
'shortcuts-environments'
do
%span
Environments
%span
.badge.count.environments_counter
=
number_with_delimiter
(
@project
.
environments
.
count
)
config/routes.rb
View file @
4f00b93d
...
...
@@ -704,7 +704,7 @@ Rails.application.routes.draw do
end
end
resources
:environments
,
only:
[
:index
,
:show
]
resources
:environments
,
only:
[
:index
,
:show
,
:new
,
:create
,
:destroy
]
resources
:builds
,
only:
[
:index
,
:show
],
constraints:
{
id:
/\d+/
}
do
collection
do
...
...
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