refactor(web-app-dashboard): hide a tile through services.dashboard.enabled instead of display

services.dashboard.enabled already says whether a role takes part in the dashboard: roles_with_service lists only roles with enabled and shared as tile-reachability targets, the CSP filter adds the dashboard to frame-ancestors only when it is set, and docker_cards uses it as the card's iframe flag. A separate display key duplicated that switch and left a role with enabled false still rendering a card. docker_cards now skips the card when services.dashboard.enabled is false (a role without a dashboard binding keeps its card, and a value that is not a boolean fails loudly), so display, its validator exception and its roles_with_service filter go again; base.md documents enabled as the per-host switch.

An inventory hides a tile with applications.<role>.services.dashboard.enabled: false, which also drops the dashboard framing of that role. Unit tests cover false, true, a missing binding, a rendered string and a non-boolean; forcing the helper to always show the card fails four of them.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 5.5 committed 2026-10-29 19:00:46 +01:00
1 parent ae7f2bbcb2
commit c855efc30a
10 files changed
+48 -123

No files matched your search

@@ -44,20 +44,23 @@ class TestCardTargetKey(unittest.TestCase):
class TestCardIsDisplayed(unittest.TestCase):
def test_a_binding_without_the_key_is_displayed(self):
self.assertTrue(card_is_displayed("web-app-foo", {"enabled": True}))
self.assertTrue(card_is_displayed("web-app-foo", {"shared": True}))
def test_a_missing_binding_is_displayed(self):
self.assertTrue(card_is_displayed("web-app-foo", None))
def test_display_false_hides_the_card(self):
self.assertFalse(card_is_displayed("web-app-foo", {"display": False}))
def test_enabled_false_hides_the_card(self):
self.assertFalse(card_is_displayed("web-app-foo", {"enabled": False}))
def test_display_true_shows_the_card(self):
self.assertTrue(card_is_displayed("web-app-foo", {"display": True}))
def test_enabled_true_shows_the_card(self):
self.assertTrue(card_is_displayed("web-app-foo", {"enabled": True}))
def test_a_string_flag_fails_loudly(self):
def test_a_rendered_string_flag_is_read_as_a_boolean(self):
self.assertFalse(card_is_displayed("web-app-foo", {"enabled": "False"}))
def test_a_non_boolean_flag_fails_loudly(self):
with self.assertRaisesRegex(AnsibleError, "web-app-foo"):
card_is_displayed("web-app-foo", {"display": "false"})
card_is_displayed("web-app-foo", {"enabled": "maybe"})
if __name__ == "__main__":