mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
feat(instances): the top of a VM's page in one card
The top of a VM's page was one line of values between pipes, an icon for the guest agent and a hidden snapshot count, then a row of big action icons; the host links sat in a bar fixed to the bottom of the window, over the content. One card now holds it all (design chosen by the owner from four): - the name with the state badge, the title under it, and where the VM is: its host and the host's VM list for administrators, the VM list for owners; - OS details (with a connected guest agent) and Refresh; - the guest agent's state in words and the snapshot count; - CPU, memory, each disk with its device name and size, and the IPv4 addresses, labelled; - the page's sections as small labelled pills in the card's footer: one row from 992 px, wrapping below. The page has no other heading: base.html's heading area is a block it leaves out. Each section below it (Power, Access, Resize, Snapshot, Settings, Stats, Destroy) is a card of the same kind, so the page reads as one design (owner's choice of two): its sub-tabs as a small underlined nav in the card's header, its panes in the card's body without their own borders. Buttons are of normal size in the theme's primary colour, and those that cannot be undone (Power Cycle, Force Off, Destroy) in the danger colour. The Stats charts lose their coloured borders. instance_tabs.js finds the Settings tabs by their tablist role. The bottom bar and its setting (VIEW_INSTANCE_DETAIL_BOTTOM_BAR) are removed, and with it the CSS that kept the old Settings tabs on one line.
This commit is contained in:
parent
d97ec5afd2
commit
935a0e9bdc
30 changed files with 327 additions and 275 deletions
|
|
@ -34,7 +34,7 @@ SUPERUSER_ONLY = {"vcpu hotplug", "video model", "guest agent"}
|
|||
class PageControls:
|
||||
def setUp(self):
|
||||
AppSettings.objects.filter(
|
||||
key__in=["SHOW_ACCESS_ROOT_PASSWORD", "SHOW_ACCESS_SSH_KEYS", "VIEW_INSTANCE_DETAIL_BOTTOM_BAR"]
|
||||
key__in=["SHOW_ACCESS_ROOT_PASSWORD", "SHOW_ACCESS_SSH_KEYS"]
|
||||
).update(value="True")
|
||||
self.compute = Compute.objects.create(
|
||||
name="ctl-compute", hostname="127.0.0.1:1", login="root", password="", type=1
|
||||
|
|
@ -124,6 +124,24 @@ class PageControlsTestCase(PageControls, TestCase):
|
|||
)
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
|
||||
def test_the_header_names_the_vm_its_place_and_resources(self):
|
||||
"""Host links for administrators, the VM list for its owner; the
|
||||
guest agent's state in words; each disk with its device name."""
|
||||
disks = [{"dev": "vda", "size": 2 << 30}, {"dev": "vdb", "size": 1 << 30}]
|
||||
with patch.object(Instance, "disks", new_callable=PropertyMock, return_value=disks), \
|
||||
patch.object(Instance, "guest_agent", new_callable=PropertyMock, return_value=True), \
|
||||
patch.object(Instance, "guest_agent_ready", new_callable=PropertyMock, return_value=False):
|
||||
self.controls(get_user_model().objects.create_superuser("hdr-admin", "a@example.com", "x"))
|
||||
admin_page = lxml_html.fromstring(self.last_page)
|
||||
self.controls(self.user("hdr-owner", owner={}))
|
||||
owner_page = lxml_html.fromstring(self.last_page)
|
||||
links = "//nav[@aria-label='Location']/a"
|
||||
self.assertEqual([a.text_content().strip() for a in admin_page.xpath(links)], ["ctl-compute", "Instances"])
|
||||
self.assertEqual([a.text_content().strip() for a in owner_page.xpath(links)], ["Instances"])
|
||||
self.assertIn("Guest agent not connected", self.last_page)
|
||||
self.assertIn("vda 2.0\xa0GB · vdb 1.0\xa0GB", self.last_page)
|
||||
self.assertEqual(owner_page.xpath("normalize-space(//dt[.='IPv4']/following-sibling::dd)"), "—")
|
||||
|
||||
def test_superuser_sees_every_control(self):
|
||||
superuser = get_user_model().objects.create_superuser("ctl_super", "ctl_super@example.com", "x")
|
||||
self.assertEqual(
|
||||
|
|
|
|||
|
|
@ -142,7 +142,8 @@ class SnapshotTabTestCase(TestCase):
|
|||
self.assertEqual(
|
||||
flags, sorted([libvirt.VIR_DOMAIN_SNAPSHOT_LIST_INTERNAL, libvirt.VIR_DOMAIN_SNAPSHOT_LIST_EXTERNAL])
|
||||
)
|
||||
self.assertEqual(doc.xpath("//i[contains(@title, 'snapshot(s)')]/@title"), ["There are 2 snapshot(s)"])
|
||||
self.assertEqual(doc.xpath("normalize-space(//span[contains(., ' snapshots')][not(*[contains(., ' snapshots')])])"),
|
||||
"2 snapshots")
|
||||
|
||||
def test_a_failed_job_query_still_renders_the_tab(self):
|
||||
# the actions themselves check for jobs again and refuse if that fails
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue