summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2017-09-27 22:17:41 +0900
committerShinya Maeda <shinya@gitlab.com>2017-09-27 22:17:41 +0900
commit058e595788118fb129d3003989a3728de9ae7e39 (patch)
tree2e778ebefaf14f5847f1cc20fa9963a12a46bc97
parent5fbf4069f6bc17dcc1ceeb81c28498b872882a6a (diff)
downloadgitlab-ce-058e595788118fb129d3003989a3728de9ae7e39.tar.gz
Delete/Update basic implementation
-rw-r--r--app/controllers/projects/clusters_controller.rb10
-rw-r--r--app/views/projects/clusters/edit.html.haml3
-rw-r--r--config/routes/project.rb3
-rw-r--r--db/migrate/20170924094327_create_ci_clusters.rb2
4 files changed, 13 insertions, 5 deletions
diff --git a/app/controllers/projects/clusters_controller.rb b/app/controllers/projects/clusters_controller.rb
index b6e2b2a723b..cb753a8b098 100644
--- a/app/controllers/projects/clusters_controller.rb
+++ b/app/controllers/projects/clusters_controller.rb
@@ -12,7 +12,7 @@ class Projects::ClustersController < Projects::ApplicationController
def index
if cluster
- redirect_to action: 'edit'
+ redirect_to edit_namespace_project_cluster_path(project.namespace, project, cluster.id)
else
redirect_to action: 'new'
end
@@ -86,10 +86,16 @@ class Projects::ClustersController < Projects::ApplicationController
end
def update
- cluster.update(schedule_params)
+ cluster.update(enabled: params['enabled'])
+ cluster.service.update(active: params['enabled'])
render :edit
end
+ def destroy
+ cluster.destroy
+ redirect_to action: 'index'
+ end
+
private
def cluster
diff --git a/app/views/projects/clusters/edit.html.haml b/app/views/projects/clusters/edit.html.haml
index 79d5ff4b59b..b01b9905ca7 100644
--- a/app/views/projects/clusters/edit.html.haml
+++ b/app/views/projects/clusters/edit.html.haml
@@ -2,3 +2,6 @@ edit/show cluster
%br
= @cluster.inspect
= @cluster.service.inspect
+= link_to "Enable", namespace_project_cluster_path(@project.namespace, @project, @cluster.id, enabled: 'true'), method: :put
+= link_to "Disable", namespace_project_cluster_path(@project.namespace, @project, @cluster.id, enabled: 'false'), method: :put
+= link_to "Soft-delete the cluster", namespace_project_cluster_path(@project.namespace, @project, @cluster.id), method: :delete
diff --git a/config/routes/project.rb b/config/routes/project.rb
index 23c3f87df81..c6dab9a4f33 100644
--- a/config/routes/project.rb
+++ b/config/routes/project.rb
@@ -183,10 +183,9 @@ constraints(ProjectUrlConstrainer.new) do
end
end
- resources :clusters, except: [:edit, :show, :destroy] do
+ resources :clusters, except: [:show] do
collection do
get :login
- get :edit
end
end
diff --git a/db/migrate/20170924094327_create_ci_clusters.rb b/db/migrate/20170924094327_create_ci_clusters.rb
index dce3298cde2..c919c5da2c4 100644
--- a/db/migrate/20170924094327_create_ci_clusters.rb
+++ b/db/migrate/20170924094327_create_ci_clusters.rb
@@ -29,7 +29,7 @@ class CreateCiClusters < ActiveRecord::Migration
t.datetime_with_timezone :updated_at, null: false
end
- # TODO: fk, index, encypt
+ # TODO: fk, index, attr_encrypted
add_foreign_key :ci_clusters, :projects
add_foreign_key :ci_clusters, :users, column: :owner_id