transfer cluster ownership and make styling consistent

This commit is contained in:
Chris
2025-05-28 16:29:11 -07:00
parent 5a3f243568
commit 3fbf53191e
7 changed files with 67 additions and 10 deletions

View File

@@ -9,8 +9,8 @@
- [ ] Make accidental deletions harder
- [ ] Allow creating a one off pod even if there are no services or deployments yet.
- [ ] Automatically detect node architecture for build target
- [ ] The IP Address being reported in the DNS mapper is the private, instead of public, IP address.
- [ ] Failing to add webhooks to projects in different organizations.
- [ ] Github filtering across organizations is not working
- [ ] Explore allowing local PC's on DHCP to be a host
- [ ] Button to kill a build
- [ ] Button to kill a build
- [ ] Deployments API

View File

@@ -2,7 +2,7 @@ class ClustersController < ApplicationController
before_action :set_cluster, only: [
:show, :edit, :update, :destroy,
:test_connection, :download_kubeconfig, :logs, :download_yaml,
:retry_install
:retry_install, :transfer_ownership
]
# GET /clusters
@@ -159,6 +159,11 @@ class ClustersController < ApplicationController
end
end
def transfer_ownership
@cluster.update(account_id: params[:cluster][:account_id])
redirect_to cluster_url(@cluster), notice: "Cluster ownership transferred successfully"
end
private
# Use callbacks to share common setup or constraints between actions.

View File

@@ -29,8 +29,17 @@
</div>
</div>
<div>
<h2 class="text-lg font-bold">Delete Add-on</h2>
<%= button_to "Uninstall", add_on_path(@add_on), method: :delete, class: "btn btn-error" %>
<h2 class="text-2xl font-bold">Danger zone</h2>
<hr class="mt-3 mb-4 border-t border-base-300" />
<div class="mt-6">
<%= button_to @add_on, method: :delete, class: "btn btn-error btn-outline group mt-2", form: { data: { turbo_confirm: t("are_you_sure") } } do %>
<iconify-icon icon="lucide:trash" height="20" class="text-error group-hover:text-error-content"></iconify-icon>
Delete Add-on
<% end %>
<div class="mt-2 text-sm text-gray-500">
This will uninstall the add-on from the cluster (equivalent to `helm uninstall`)
</div>
</div>
</div>
</div>
<% end %>

View File

@@ -0,0 +1,36 @@
<dialog aria-label="Modal" class="modal" id="transfer_ownership_modal">
<div class="modal-box bg-base-300">
<form method="dialog">
<button aria-label="Close modal" class="btn btn-circle btn-ghost btn-sm absolute right-2 top-2">
<iconify-icon icon="lucide:x" height="16"></iconify-icon>
</button>
</form>
<div class="mb-8 w-full text-xl font-bold">Transfer Ownership</div>
<div class="my-4">
<%= form_with model: cluster, url: transfer_ownership_cluster_path(cluster), method: :post do |f| %>
<div class="form-control">
<label class="label" for="cluster_account_id">
<span class="label-text">Transfer to Account</span>
</label>
<%= f.select(
:account_id,
current_user
.accounts
.select { |account| account.id != cluster.account_id }
.map { |account| [account.name, account.id] },
{ include_blank: true },
required: true,
class: "select select-bordered w-full"
) %>
</div>
<div class="form-footer">
<%= f.submit "Transfer", class: "btn btn-primary" %>
<button class="btn btn-outline" onclick="transfer_ownership_modal.close()">Cancel</button>
</div>
<% end %>
</div>
</div>
<form method="dialog" class="modal-backdrop">
<button>close</button>
</form>
</dialog>

View File

@@ -11,10 +11,17 @@
<div>
<h2 class="text-2xl font-bold">Danger zone</h2>
<hr class="mt-3 mb-4 border-t border-base-300" />
<div class="mt-6">
<%= render "clusters/transfer_ownership", cluster: @cluster %>
<button class="btn btn-warning btn-outline mt-2 group" onclick="transfer_ownership_modal.showModal()">
<iconify-icon icon="lucide:hand-helping" height="20" class="text-warning group-hover:text-black"></iconify-icon>
Transfer Ownership
</button>
</div>
<div class="mt-6">
<%= button_to @cluster, method: :delete, class: "btn btn-error btn-outline mt-2", form: { data: { turbo_confirm: t("are_you_sure") } } do %>
<iconify-icon icon="lucide:trash" height="20" class="text-error-content"></iconify-icon>
<%= button_to @cluster, method: :delete, class: "btn btn-error btn-outline group mt-2", form: { data: { turbo_confirm: t("are_you_sure") } } do %>
<iconify-icon icon="lucide:trash" height="20" class="text-error group-hover:text-error-content"></iconify-icon>
Delete Cluster
<% end %>
<div class="mt-2 text-sm text-gray-500">

View File

@@ -17,10 +17,9 @@
<div>
<h2 class="text-2xl font-bold">Danger zone</h2>
<hr class="mt-3 mb-4 border-t border-base-300" />
<div class="mt-6">
<%= button_to @project, method: :delete, class: "btn btn-error btn-outline mt-2", form: { data: { turbo_confirm: t("are_you_sure") } } do %>
<iconify-icon icon="lucide:trash" height="20" class="text-error-content"></iconify-icon>
<%= button_to @project, method: :delete, class: "btn btn-error btn-outline group mt-2", form: { data: { turbo_confirm: t("are_you_sure") } } do %>
<iconify-icon icon="lucide:trash" height="20" class="text-error group-hover:text-error-content"></iconify-icon>
Delete Project
<% end %>
</div>

View File

@@ -72,6 +72,7 @@ Rails.application.routes.draw do
end
resources :clusters do
member do
post :transfer_ownership
get :download_kubeconfig
get :download_yaml
get :logs