Commit 058e5957 authored by Shinya Maeda's avatar Shinya Maeda

Delete/Update basic implementation

parent 5fbf4069
...@@ -12,7 +12,7 @@ class Projects::ClustersController < Projects::ApplicationController ...@@ -12,7 +12,7 @@ class Projects::ClustersController < Projects::ApplicationController
def index def index
if cluster if cluster
redirect_to action: 'edit' redirect_to edit_namespace_project_cluster_path(project.namespace, project, cluster.id)
else else
redirect_to action: 'new' redirect_to action: 'new'
end end
...@@ -86,10 +86,16 @@ class Projects::ClustersController < Projects::ApplicationController ...@@ -86,10 +86,16 @@ class Projects::ClustersController < Projects::ApplicationController
end end
def update def update
cluster.update(schedule_params) cluster.update(enabled: params['enabled'])
cluster.service.update(active: params['enabled'])
render :edit render :edit
end end
def destroy
cluster.destroy
redirect_to action: 'index'
end
private private
def cluster def cluster
......
...@@ -2,3 +2,6 @@ edit/show cluster ...@@ -2,3 +2,6 @@ edit/show cluster
%br %br
= @cluster.inspect = @cluster.inspect
= @cluster.service.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
...@@ -183,10 +183,9 @@ constraints(ProjectUrlConstrainer.new) do ...@@ -183,10 +183,9 @@ constraints(ProjectUrlConstrainer.new) do
end end
end end
resources :clusters, except: [:edit, :show, :destroy] do resources :clusters, except: [:show] do
collection do collection do
get :login get :login
get :edit
end end
end end
......
...@@ -29,7 +29,7 @@ class CreateCiClusters < ActiveRecord::Migration ...@@ -29,7 +29,7 @@ class CreateCiClusters < ActiveRecord::Migration
t.datetime_with_timezone :updated_at, null: false t.datetime_with_timezone :updated_at, null: false
end end
# TODO: fk, index, encypt # TODO: fk, index, attr_encrypted
add_foreign_key :ci_clusters, :projects add_foreign_key :ci_clusters, :projects
add_foreign_key :ci_clusters, :users, column: :owner_id add_foreign_key :ci_clusters, :users, column: :owner_id
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment