Files
ubicloud/views/vm/index.erb
Enes Cakir e788f72654 Unify empty states in tables
Some pages display a message in the table body when empty, while others
show a full-page empty state. This PR unifies the empty states to
consistently show a message in the table body. It removes the
conditional wrapping the table. The new method of displaying the empty
state is also more consistent with the rest of the app and includes the
page header.
2025-01-16 15:50:06 +03:00

44 lines
1.5 KiB
Plaintext

<% @page_title = "Virtual Machines" %>
<div class="auto-refresh hidden" data-interval="10"></div>
<%== render(
"components/page_header",
locals: {
breadcrumbs: [%w[Projects /project], [@project_data[:name], @project_data[:path]], ["Virtual Machines", "#"]],
right_items: (!@vms.empty? && has_project_permission("Vm:create")) ? [
render("components/button", locals: { text: "Create Virtual Machine", link: "vm/create" })
] : []
}
) %>
<div class="grid gap-6">
<%== render(
"components/table_card",
locals: {
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>