Skip to content

Commit 254857b

Browse files
piitayabramkragten
andauthored
Improve sidebar and dashboard management logic (#28019)
Co-authored-by: Bram Kragten <[email protected]>
1 parent 1648be6 commit 254857b

File tree

12 files changed

+347
-340
lines changed

12 files changed

+347
-340
lines changed

src/components/ha-icon-overflow-menu.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class HaIconOverflowMenu extends LitElement {
6666
.path=${item.path}
6767
></ha-svg-icon>
6868
${item.label}
69-
</ha-md-menu-item> `
69+
</ha-md-menu-item>`
7070
)}
7171
</ha-md-button-menu>`
7272
: html`
@@ -103,6 +103,7 @@ export class HaIconOverflowMenu extends LitElement {
103103
:host {
104104
display: flex;
105105
justify-content: flex-end;
106+
cursor: initial;
106107
}
107108
div[role="separator"] {
108109
border-right: 1px solid var(--divider-color);

src/components/ha-items-display-editor.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface DisplayItem {
2727
label: string;
2828
description?: string;
2929
disableSorting?: boolean;
30+
disableHiding?: boolean;
3031
}
3132

3233
export interface DisplayValue {
@@ -101,6 +102,7 @@ export class HaItemDisplayEditor extends LitElement {
101102
icon,
102103
iconPath,
103104
disableSorting,
105+
disableHiding,
104106
} = item;
105107
return html`
106108
<ha-md-list-item
@@ -155,18 +157,21 @@ export class HaItemDisplayEditor extends LitElement {
155157
</div>
156158
`
157159
: nothing}
158-
<ha-icon-button
159-
.path=${isVisible ? mdiEye : mdiEyeOff}
160-
slot="end"
161-
.label=${this.hass.localize(
162-
`ui.components.items-display-editor.${isVisible ? "hide" : "show"}`,
163-
{
164-
label: label,
165-
}
166-
)}
167-
.value=${value}
168-
@click=${this._toggle}
169-
></ha-icon-button>
160+
${!isVisible || !disableHiding
161+
? html`<ha-icon-button
162+
.path=${isVisible ? mdiEye : mdiEyeOff}
163+
slot="end"
164+
.label=${this.hass.localize(
165+
`ui.components.items-display-editor.${isVisible ? "hide" : "show"}`,
166+
{
167+
label: label,
168+
}
169+
)}
170+
.value=${value}
171+
@click=${this._toggle}
172+
.disabled=${disableHiding || false}
173+
></ha-icon-button>`
174+
: nothing}
170175
${isVisible && !disableSorting
171176
? html`
172177
<ha-svg-icon

src/components/ha-md-menu-item.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ export class HaMdMenuItem extends MenuItemEl {
3636
::slotted([slot="headline"]) {
3737
text-wrap: nowrap;
3838
}
39+
:host([disabled]) {
40+
opacity: 1;
41+
--md-menu-item-label-text-color: var(--disabled-text-color);
42+
--md-menu-item-leading-icon-color: var(--disabled-text-color);
43+
}
3944
`,
4045
];
4146
}

src/components/ha-navigation-picker.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { fireEvent } from "../common/dom/fire_event";
66
import { titleCase } from "../common/string/title-case";
77
import { fetchConfig } from "../data/lovelace/config/types";
88
import type { LovelaceViewRawConfig } from "../data/lovelace/config/view";
9-
import { getDefaultPanelUrlPath } from "../data/panel";
9+
import { getPanelIcon, getPanelTitle } from "../data/panel";
1010
import type { HomeAssistant, PanelInfo, ValueChangedEvent } from "../types";
1111
import "./ha-combo-box";
1212
import type { HaComboBox } from "./ha-combo-box";
@@ -43,13 +43,8 @@ const createViewNavigationItem = (
4343

4444
const createPanelNavigationItem = (hass: HomeAssistant, panel: PanelInfo) => ({
4545
path: `/${panel.url_path}`,
46-
icon: panel.icon ?? "mdi:view-dashboard",
47-
title:
48-
panel.url_path === getDefaultPanelUrlPath(hass)
49-
? hass.localize("panel.states")
50-
: hass.localize(`panel.${panel.title}`) ||
51-
panel.title ||
52-
(panel.url_path ? titleCase(panel.url_path) : ""),
46+
icon: getPanelIcon(panel) || "mdi:view-dashboard",
47+
title: getPanelTitle(hass, panel) || "",
5348
});
5449

5550
@customElement("ha-navigation-picker")

0 commit comments

Comments
 (0)