summaryrefslogtreecommitdiff
path: root/app/views/projects/environments
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-10-06 13:45:45 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2016-10-06 13:45:45 +0200
commitc319cc5ab5064459aaf803ee719a08e9663726ea (patch)
treeaa9a89d332a14bb3db668a73a9865dfe2b7742a6 /app/views/projects/environments
parentfd4e0703e81de31aaabdfc983b013382841fcaa3 (diff)
downloadgitlab-ce-c319cc5ab5064459aaf803ee719a08e9663726ea.tar.gz
Make environments to be close able
Diffstat (limited to 'app/views/projects/environments')
-rw-r--r--app/views/projects/environments/_environment.html.haml2
-rw-r--r--app/views/projects/environments/index.html.haml32
-rw-r--r--app/views/projects/environments/show.html.haml7
3 files changed, 22 insertions, 19 deletions
diff --git a/app/views/projects/environments/_environment.html.haml b/app/views/projects/environments/_environment.html.haml
index 2e9c395f08a..205392b1e81 100644
--- a/app/views/projects/environments/_environment.html.haml
+++ b/app/views/projects/environments/_environment.html.haml
@@ -21,4 +21,4 @@
#{time_ago_with_tooltip(last_deployment.created_at)}
%td.hidden-xs
- = render 'projects/deployments/actions', deployment: last_deployment
+ = render 'projects/deployments/actions', deployment: last_deployment, allow_close: environment.opened?
diff --git a/app/views/projects/environments/index.html.haml b/app/views/projects/environments/index.html.haml
index 949f0855777..702cccd6ab3 100644
--- a/app/views/projects/environments/index.html.haml
+++ b/app/views/projects/environments/index.html.haml
@@ -3,26 +3,26 @@
= render "projects/pipelines/head"
%div{ class: container_class }
- - if can?(current_user, :create_environment, @project) && !@environments.blank?
- .top-area
- %ul.nav-links
- %li{class: ('active' if @scope.nil?)}
- = link_to project_environments_path(@project) do
- Availabe
- %span.badge.js-avaibale-environments-count
- = number_with_delimiter(@available_environments_count)
-
- %li{class: ('active' if @scope == 'stopped')}
- = link_to project_environments_path(@project, scope: :stopped) do
- Stopped
- %span.badge.js-stopped-environments-count
- = number_with_delimiter(@stopped_environments_count)
+ .top-area
+ %ul.nav-links
+ %li{class: ('active' if @scope.nil?)}
+ = link_to project_environments_path(@project) do
+ Availabe
+ %span.badge.js-avaibale-environments-count
+ = number_with_delimiter(@all_environments.opened.count)
- .nav-controls
+ %li{class: ('active' if @scope == 'closed')}
+ = link_to project_environments_path(@project, scope: :stopped) do
+ Stopped
+ %span.badge.js-stopped-environments-count
+ = number_with_delimiter(@all_environments.closed.count)
+
+ .nav-controls
+ - if can?(current_user, :create_environment, @project) && !@all_environments.blank?
= link_to new_namespace_project_environment_path(@project.namespace, @project), class: 'btn btn-create' do
New environment
- - if @environments.blank?
+ - if @all_environments.blank?
.blank-state.blank-state-no-icon
%h2.blank-state-title
You don't have any environments right now.
diff --git a/app/views/projects/environments/show.html.haml b/app/views/projects/environments/show.html.haml
index 5ca35bb92b1..5f4a0ef082c 100644
--- a/app/views/projects/environments/show.html.haml
+++ b/app/views/projects/environments/show.html.haml
@@ -2,6 +2,8 @@
- page_title "Environments"
= render "projects/pipelines/head"
+- last_deployment = @environment.last_deployment
+
%div{ class: container_class }
.top-area
.col-md-9
@@ -10,8 +12,9 @@
.nav-controls
- if can?(current_user, :update_environment, @environment)
= link_to 'Edit', edit_namespace_project_environment_path(@project.namespace, @project, @environment), class: 'btn'
- / TODO: Confirm if the method is :delete
- = link_to 'Close', namespace_project_environment_path(@project.namespace, @project, @environment), data: { confirm: 'Are you sure you want to delete this environment?' }, class: 'btn btn-danger', method: :delete
+ - if @environment.opened? && last_deployment.try(:close_action)
+ = link_to 'Close', [:play, @project.namespace.becomes(Namespace), @project, last_deployment.close_action], data: { confirm: 'Are you sure you want to close this environment?' }, class: 'btn btn-danger', method: :post
+ = link_to 'Destroy', namespace_project_environment_path(@project.namespace, @project, @environment), data: { confirm: 'Are you sure you want to delete this environment?' }, class: 'btn btn-danger', method: :delete
- if @deployments.blank?
.blank-state.blank-state-no-icon