mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 19:56:42 +00:00
Fix sidebar when user is slow to load (#2993)
This commit is contained in:
parent
ef18f9eac9
commit
20ee3452dc
@ -26,19 +26,13 @@ const computePanels = (hass: HomeAssistant) => {
|
|||||||
if (!panels) {
|
if (!panels) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
const isAdmin = hass.user.is_admin;
|
|
||||||
const sortValue = {
|
const sortValue = {
|
||||||
map: 1,
|
map: 1,
|
||||||
logbook: 2,
|
logbook: 2,
|
||||||
history: 3,
|
history: 3,
|
||||||
};
|
};
|
||||||
const result: Panel[] = [];
|
const result: Panel[] = Object.values(panels).filter((panel) => panel.title);
|
||||||
|
|
||||||
Object.values(panels).forEach((panel) => {
|
|
||||||
if (panel.title && (panel.component_name !== "config" || isAdmin)) {
|
|
||||||
result.push(panel);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
result.sort((a, b) => {
|
result.sort((a, b) => {
|
||||||
const aBuiltIn = a.component_name in sortValue;
|
const aBuiltIn = a.component_name in sortValue;
|
||||||
@ -133,9 +127,8 @@ class HaSidebar extends LitElement {
|
|||||||
: html``}
|
: html``}
|
||||||
</paper-listbox>
|
</paper-listbox>
|
||||||
|
|
||||||
${!hass.user.is_admin
|
${hass.user && hass.user.is_admin
|
||||||
? ""
|
? html`
|
||||||
: html`
|
|
||||||
<div>
|
<div>
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
|
|
||||||
@ -192,7 +185,8 @@ class HaSidebar extends LitElement {
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`}
|
`
|
||||||
|
: ""}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ export interface HomeAssistant {
|
|||||||
|
|
||||||
dockedSidebar: boolean;
|
dockedSidebar: boolean;
|
||||||
moreInfoEntityId: string;
|
moreInfoEntityId: string;
|
||||||
user: CurrentUser;
|
user?: CurrentUser;
|
||||||
callService: (
|
callService: (
|
||||||
domain: string,
|
domain: string,
|
||||||
service: string,
|
service: string,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user