1
0
mirror of https://github.com/home-assistant/core.git synced 2026-02-15 07:36:16 +00:00

Register notfound panel

This commit is contained in:
Paul Bottein
2026-02-11 10:17:04 +01:00
parent 4790161617
commit e0a32668db
2 changed files with 2 additions and 37 deletions

View File

@@ -590,6 +590,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
)
async_register_built_in_panel(hass, "profile")
async_register_built_in_panel(hass, "notfound")
@callback
def async_change_listener(
@@ -923,7 +924,7 @@ def websocket_get_panels(
if config_override
else panel.require_admin
)
if not user_is_admin and require_admin and panel_key != "home":
if not user_is_admin and require_admin:
continue
panels[panel_key] = panel.to_response(config_override)

View File

@@ -1421,39 +1421,3 @@ async def test_update_panel_hide_sidebar(
msg = await ws_client.receive_json()
assert msg["result"]["light"]["title"] == "light"
assert msg["result"]["light"]["icon"] == "mdi:lamps"
async def test_home_panel_always_visible(
hass: HomeAssistant,
ws_client: MockHAClientWebSocket,
hass_admin_user: MockUser,
) -> None:
"""Test that the home panel is always returned even with require_admin."""
# Set home panel to require_admin
await ws_client.send_json(
{
"id": 1,
"type": "frontend/update_panel",
"url_path": "home",
"require_admin": True,
}
)
msg = await ws_client.receive_json()
assert msg["success"]
# Make user non-admin
hass_admin_user.groups = []
# Home panel should still be present for non-admin
await ws_client.send_json({"id": 2, "type": "get_panels"})
msg = await ws_client.receive_json()
assert "home" in msg["result"]
# Other admin panels should be filtered out
async_register_built_in_panel(
hass, "admin_only", "Admin", "mdi:lock", require_admin=True
)
await ws_client.send_json({"id": 3, "type": "get_panels"})
msg = await ws_client.receive_json()
assert "admin_only" not in msg["result"]
assert "home" in msg["result"]