This uses the new part plugin to simplify and optimize render calls with locals. ```ruby render(:template, locals: {foo: 'bar'}) part(:template, foo: 'bar') ``` This simplifies a large number of calls in Clover, since rendering with locals is one of the most common method calls in the templates. The main advantage of this is simplicity, but the part method is also more optimized, and will be even more optimized when we upgrade to Ruby 3.4. Diff best reviewed with: ``` git diff -b --color-words --word-diff-regex='\\w+|[^[:space:]]' ```
40 lines
1.4 KiB
Plaintext
40 lines
1.4 KiB
Plaintext
<% @page_title = "Virtual Machines" %>
|
|
<div class="auto-refresh hidden" data-interval="10"></div>
|
|
|
|
<%== part(
|
|
"components/page_header",
|
|
breadcrumbs: [%w[Projects /project], [@project_data[:name], @project_data[:path]], ["Virtual Machines", "#"]],
|
|
right_items: (!@vms.empty? && has_project_permission("Vm:create")) ? [
|
|
part("components/button", text: "Create Virtual Machine", link: "vm/create")
|
|
] : []
|
|
) %>
|
|
|
|
<div class="grid gap-6">
|
|
<%== part(
|
|
"components/table_card",
|
|
headers: ["Name", "Location", "Size", "Storage Size", "State", "IP Address"],
|
|
rows: @vms.map do |vm|
|
|
[
|
|
[
|
|
[vm[:name], {link: @project_data[:path] + vm[:path]}],
|
|
vm[:location],
|
|
vm[:size],
|
|
(vm[:storage_size_gib] > 0) ? "#{vm[:storage_size_gib]} GB" : "-",
|
|
["vm_state_label", {component: { state: vm[:state] }}],
|
|
[vm[:ip4] || vm[:ip6] || "Not assigned yet", {copyable: true}]
|
|
],
|
|
{id: "vm-#{vm[:id]}"}
|
|
]
|
|
end,
|
|
empty_state: {
|
|
icon: "hero-server-stack",
|
|
title: "No virtual machines",
|
|
description: "You don't have permission to create virtual machines."
|
|
}.merge(has_project_permission("Vm:create") ? {
|
|
description: "Get started by creating a new virtual machine.",
|
|
button_link: "#{@project_data[:path]}/vm/create",
|
|
button_title: "Create Virtual Machine"
|
|
} : {})
|
|
) %>
|
|
</div>
|