diff --git a/src/components/ha-sidebar.ts b/src/components/ha-sidebar.ts index 48ebff59e5..98d0a5e097 100644 --- a/src/components/ha-sidebar.ts +++ b/src/components/ha-sidebar.ts @@ -26,19 +26,13 @@ const computePanels = (hass: HomeAssistant) => { if (!panels) { return []; } - const isAdmin = hass.user.is_admin; + const sortValue = { map: 1, logbook: 2, history: 3, }; - const result: Panel[] = []; - - Object.values(panels).forEach((panel) => { - if (panel.title && (panel.component_name !== "config" || isAdmin)) { - result.push(panel); - } - }); + const result: Panel[] = Object.values(panels).filter((panel) => panel.title); result.sort((a, b) => { const aBuiltIn = a.component_name in sortValue; @@ -133,9 +127,8 @@ class HaSidebar extends LitElement { : html``} - ${!hass.user.is_admin - ? "" - : html` + ${hass.user && hass.user.is_admin + ? html`
@@ -192,7 +185,8 @@ class HaSidebar extends LitElement {
- `} + ` + : ""} `; } diff --git a/src/types.ts b/src/types.ts index 317f12f2bc..099fe66574 100644 --- a/src/types.ts +++ b/src/types.ts @@ -137,7 +137,7 @@ export interface HomeAssistant { dockedSidebar: boolean; moreInfoEntityId: string; - user: CurrentUser; + user?: CurrentUser; callService: ( domain: string, service: string,