diff --git a/computes/templates/computes/host_nav.html b/computes/templates/computes/host_nav.html new file mode 100644 index 00000000..9b4de4c1 --- /dev/null +++ b/computes/templates/computes/host_nav.html @@ -0,0 +1,28 @@ +{% load i18n %} +{% load bootstrap_icons %} +{# The host's sections. section: the one this page belongs to; detail: the page is an item of it (a pool, a network), not the section's own page #} + diff --git a/computes/templates/computes/instances.html b/computes/templates/computes/instances.html index 0a83eee4..01c1b5f7 100644 --- a/computes/templates/computes/instances.html +++ b/computes/templates/computes/instances.html @@ -20,31 +20,7 @@
- + {% include "computes/host_nav.html" with section="instances" %}
diff --git a/computes/templates/overview.html b/computes/templates/overview.html index 5160d075..efc5a40e 100644 --- a/computes/templates/overview.html +++ b/computes/templates/overview.html @@ -9,31 +9,7 @@ {% block content %}
- + {% include "computes/host_nav.html" with section="overview" %}
diff --git a/computes/tests/test_host_nav.py b/computes/tests/test_host_nav.py new file mode 100644 index 00000000..c181631d --- /dev/null +++ b/computes/tests/test_host_nav.py @@ -0,0 +1,25 @@ +"""The host pages' shared section links.""" + +from django.template.loader import render_to_string +from django.test import TestCase +from lxml import html + +from computes.models import Compute + + +class HostNavTestCase(TestCase): + def setUp(self): + self.compute = Compute.objects.create(name="c", hostname="192.0.2.1", login="u", password="p", type=1) + + def links(self, **context): + nav = html.fromstring(render_to_string("computes/host_nav.html", {"compute": self.compute, **context})) + return {link.text_content().strip(): (link.get("class"), link.get("aria-current")) for link in nav.iter("a")} + + def test_the_section_s_own_page_is_the_current_page(self): + links = self.links(section="storages") + self.assertEqual(len(links), 7) + self.assertEqual(links["Storages"], ("nav-link active", "page")) + self.assertEqual(links["Overview"], ("nav-link", None)) + + def test_an_item_of_a_section_marks_the_section_without_being_its_page(self): + self.assertEqual(self.links(section="networks", detail=True)["Networks"], ("nav-link active", "true")) diff --git a/interfaces/templates/interface.html b/interfaces/templates/interface.html index 21ff5f29..9083a795 100644 --- a/interfaces/templates/interface.html +++ b/interfaces/templates/interface.html @@ -9,29 +9,7 @@ {% block content %} diff --git a/interfaces/templates/interfaces.html b/interfaces/templates/interfaces.html index fce57db4..6a2bd0e3 100644 --- a/interfaces/templates/interfaces.html +++ b/interfaces/templates/interfaces.html @@ -14,31 +14,7 @@ {% block content %} diff --git a/networks/templates/network.html b/networks/templates/network.html index e67f3ea5..88efedc9 100644 --- a/networks/templates/network.html +++ b/networks/templates/network.html @@ -10,29 +10,7 @@ {% block content %} diff --git a/networks/templates/networks.html b/networks/templates/networks.html index 6d3abb9d..fdd4d6d1 100644 --- a/networks/templates/networks.html +++ b/networks/templates/networks.html @@ -11,31 +11,7 @@ {% block content %} diff --git a/nwfilters/templates/nwfilter.html b/nwfilters/templates/nwfilter.html index 8e2be12c..0e77cfd8 100644 --- a/nwfilters/templates/nwfilter.html +++ b/nwfilters/templates/nwfilter.html @@ -10,29 +10,7 @@ {% block content %} diff --git a/nwfilters/templates/nwfilters.html b/nwfilters/templates/nwfilters.html index 2aaeb655..c9753d2d 100644 --- a/nwfilters/templates/nwfilters.html +++ b/nwfilters/templates/nwfilters.html @@ -15,31 +15,7 @@ {% block content %} diff --git a/storages/templates/storage.html b/storages/templates/storage.html index a9598b98..b10ce6a6 100644 --- a/storages/templates/storage.html +++ b/storages/templates/storage.html @@ -14,29 +14,7 @@
diff --git a/storages/templates/storages.html b/storages/templates/storages.html index b629c408..86c2a40f 100644 --- a/storages/templates/storages.html +++ b/storages/templates/storages.html @@ -11,31 +11,7 @@ {% block content %} diff --git a/virtsecrets/templates/secrets.html b/virtsecrets/templates/secrets.html index 6bc6be4e..dd78bbd7 100644 --- a/virtsecrets/templates/secrets.html +++ b/virtsecrets/templates/secrets.html @@ -14,31 +14,7 @@ {% block content %}