mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-13 20:36:35 +00:00
Fix Lovelace Empty Menu when not advanced or admin (#11660)
This commit is contained in:
parent
099fa706a0
commit
db7cac5782
@ -276,137 +276,153 @@ class HUIRoot extends LitElement {
|
|||||||
></ha-icon-button>
|
></ha-icon-button>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
<ha-button-menu corner="BOTTOM_START">
|
${this._showButtonMenu
|
||||||
<ha-icon-button
|
? html`
|
||||||
slot="trigger"
|
<ha-button-menu corner="BOTTOM_START">
|
||||||
.label=${this.hass!.localize(
|
<ha-icon-button
|
||||||
"ui.panel.lovelace.editor.menu.open"
|
slot="trigger"
|
||||||
)}
|
|
||||||
.path=${mdiDotsVertical}
|
|
||||||
></ha-icon-button>
|
|
||||||
${this.narrow &&
|
|
||||||
this._conversation(this.hass.config.components)
|
|
||||||
? html`
|
|
||||||
<mwc-list-item
|
|
||||||
.label=${this.hass!.localize(
|
.label=${this.hass!.localize(
|
||||||
"ui.panel.lovelace.menu.start_conversation"
|
"ui.panel.lovelace.editor.menu.open"
|
||||||
)}
|
)}
|
||||||
graphic="icon"
|
.path=${mdiDotsVertical}
|
||||||
@request-selected=${this._showVoiceCommandDialog}
|
></ha-icon-button>
|
||||||
>
|
${this.narrow &&
|
||||||
<span
|
this._conversation(this.hass.config.components)
|
||||||
>${this.hass!.localize(
|
? html`
|
||||||
"ui.panel.lovelace.menu.start_conversation"
|
<mwc-list-item
|
||||||
)}</span
|
.label=${this.hass!.localize(
|
||||||
>
|
"ui.panel.lovelace.menu.start_conversation"
|
||||||
<ha-svg-icon
|
)}
|
||||||
slot="graphic"
|
graphic="icon"
|
||||||
.path=${mdiMicrophone}
|
@request-selected=${this
|
||||||
></ha-svg-icon>
|
._showVoiceCommandDialog}
|
||||||
</mwc-list-item>
|
>
|
||||||
`
|
<span
|
||||||
: ""}
|
>${this.hass!.localize(
|
||||||
${this._yamlMode
|
"ui.panel.lovelace.menu.start_conversation"
|
||||||
? html`
|
)}</span
|
||||||
<mwc-list-item
|
>
|
||||||
aria-label=${this.hass!.localize(
|
<ha-svg-icon
|
||||||
"ui.common.refresh"
|
slot="graphic"
|
||||||
)}
|
.path=${mdiMicrophone}
|
||||||
graphic="icon"
|
></ha-svg-icon>
|
||||||
@request-selected=${this._handleRefresh}
|
</mwc-list-item>
|
||||||
>
|
`
|
||||||
<span
|
: ""}
|
||||||
>${this.hass!.localize("ui.common.refresh")}</span
|
${this._yamlMode
|
||||||
>
|
? html`
|
||||||
<ha-svg-icon
|
<mwc-list-item
|
||||||
slot="graphic"
|
aria-label=${this.hass!.localize(
|
||||||
.path=${mdiRefresh}
|
"ui.common.refresh"
|
||||||
></ha-svg-icon>
|
)}
|
||||||
</mwc-list-item>
|
graphic="icon"
|
||||||
<mwc-list-item
|
@request-selected=${this._handleRefresh}
|
||||||
aria-label=${this.hass!.localize(
|
>
|
||||||
"ui.panel.lovelace.unused_entities.title"
|
<span
|
||||||
)}
|
>${this.hass!.localize(
|
||||||
graphic="icon"
|
"ui.common.refresh"
|
||||||
@request-selected=${this._handleUnusedEntities}
|
)}</span
|
||||||
>
|
>
|
||||||
<span
|
<ha-svg-icon
|
||||||
>${this.hass!.localize(
|
slot="graphic"
|
||||||
"ui.panel.lovelace.unused_entities.title"
|
.path=${mdiRefresh}
|
||||||
)}</span
|
></ha-svg-icon>
|
||||||
>
|
</mwc-list-item>
|
||||||
<ha-svg-icon
|
<mwc-list-item
|
||||||
slot="graphic"
|
aria-label=${this.hass!.localize(
|
||||||
.path=${mdiShape}
|
"ui.panel.lovelace.unused_entities.title"
|
||||||
></ha-svg-icon>
|
)}
|
||||||
</mwc-list-item>
|
graphic="icon"
|
||||||
`
|
@request-selected=${this
|
||||||
: ""}
|
._handleUnusedEntities}
|
||||||
${(this.hass.panels.lovelace?.config as LovelacePanelConfig)
|
>
|
||||||
?.mode === "yaml"
|
<span
|
||||||
? html`
|
>${this.hass!.localize(
|
||||||
<mwc-list-item
|
"ui.panel.lovelace.unused_entities.title"
|
||||||
graphic="icon"
|
)}</span
|
||||||
aria-label=${this.hass!.localize(
|
>
|
||||||
"ui.panel.lovelace.menu.reload_resources"
|
<ha-svg-icon
|
||||||
)}
|
slot="graphic"
|
||||||
@request-selected=${this._handleReloadResources}
|
.path=${mdiShape}
|
||||||
>
|
></ha-svg-icon>
|
||||||
${this.hass!.localize(
|
</mwc-list-item>
|
||||||
"ui.panel.lovelace.menu.reload_resources"
|
`
|
||||||
)}
|
: ""}
|
||||||
<ha-svg-icon
|
${(
|
||||||
slot="graphic"
|
this.hass.panels.lovelace
|
||||||
.path=${mdiRefresh}
|
?.config as LovelacePanelConfig
|
||||||
></ha-svg-icon>
|
)?.mode === "yaml"
|
||||||
</mwc-list-item>
|
? html`
|
||||||
`
|
<mwc-list-item
|
||||||
: ""}
|
graphic="icon"
|
||||||
${this.hass!.user?.is_admin && !this.hass!.config.safe_mode
|
aria-label=${this.hass!.localize(
|
||||||
? html`
|
"ui.panel.lovelace.menu.reload_resources"
|
||||||
<mwc-list-item
|
)}
|
||||||
graphic="icon"
|
@request-selected=${this
|
||||||
aria-label=${this.hass!.localize(
|
._handleReloadResources}
|
||||||
"ui.panel.lovelace.menu.configure_ui"
|
>
|
||||||
)}
|
${this.hass!.localize(
|
||||||
@request-selected=${this._handleEnableEditMode}
|
"ui.panel.lovelace.menu.reload_resources"
|
||||||
>
|
)}
|
||||||
${this.hass!.localize(
|
<ha-svg-icon
|
||||||
"ui.panel.lovelace.menu.configure_ui"
|
slot="graphic"
|
||||||
)}
|
.path=${mdiRefresh}
|
||||||
<ha-svg-icon
|
></ha-svg-icon>
|
||||||
slot="graphic"
|
</mwc-list-item>
|
||||||
.path=${mdiPencil}
|
`
|
||||||
></ha-svg-icon>
|
: ""}
|
||||||
</mwc-list-item>
|
${this.hass!.user?.is_admin &&
|
||||||
`
|
!this.hass!.config.safe_mode
|
||||||
: ""}
|
? html`
|
||||||
${this._editMode
|
<mwc-list-item
|
||||||
? html`
|
graphic="icon"
|
||||||
<a
|
aria-label=${this.hass!.localize(
|
||||||
href=${documentationUrl(this.hass, "/lovelace/")}
|
"ui.panel.lovelace.menu.configure_ui"
|
||||||
rel="noreferrer"
|
)}
|
||||||
class="menu-link"
|
@request-selected=${this
|
||||||
target="_blank"
|
._handleEnableEditMode}
|
||||||
>
|
>
|
||||||
<mwc-list-item
|
${this.hass!.localize(
|
||||||
graphic="icon"
|
"ui.panel.lovelace.menu.configure_ui"
|
||||||
aria-label=${this.hass!.localize(
|
)}
|
||||||
"ui.panel.lovelace.menu.help"
|
<ha-svg-icon
|
||||||
)}
|
slot="graphic"
|
||||||
>
|
.path=${mdiPencil}
|
||||||
${this.hass!.localize(
|
></ha-svg-icon>
|
||||||
"ui.panel.lovelace.menu.help"
|
</mwc-list-item>
|
||||||
)}
|
`
|
||||||
<ha-svg-icon
|
: ""}
|
||||||
slot="graphic"
|
${this._editMode
|
||||||
.path=${mdiHelp}
|
? html`
|
||||||
></ha-svg-icon>
|
<a
|
||||||
</mwc-list-item>
|
href=${documentationUrl(
|
||||||
</a>
|
this.hass,
|
||||||
`
|
"/lovelace/"
|
||||||
: ""}
|
)}
|
||||||
</ha-button-menu>
|
rel="noreferrer"
|
||||||
|
class="menu-link"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
<mwc-list-item
|
||||||
|
graphic="icon"
|
||||||
|
aria-label=${this.hass!.localize(
|
||||||
|
"ui.panel.lovelace.menu.help"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
${this.hass!.localize(
|
||||||
|
"ui.panel.lovelace.menu.help"
|
||||||
|
)}
|
||||||
|
<ha-svg-icon
|
||||||
|
slot="graphic"
|
||||||
|
.path=${mdiHelp}
|
||||||
|
></ha-svg-icon>
|
||||||
|
</mwc-list-item>
|
||||||
|
</a>
|
||||||
|
`
|
||||||
|
: ""}
|
||||||
|
</ha-button-menu>
|
||||||
|
`
|
||||||
|
: ""}
|
||||||
</app-toolbar>
|
</app-toolbar>
|
||||||
`}
|
`}
|
||||||
${this._editMode
|
${this._editMode
|
||||||
@ -621,6 +637,17 @@ class HUIRoot extends LitElement {
|
|||||||
return this.shadowRoot!.getElementById("view") as HTMLDivElement;
|
return this.shadowRoot!.getElementById("view") as HTMLDivElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private get _showButtonMenu(): boolean {
|
||||||
|
return (
|
||||||
|
(this.narrow && this._conversation(this.hass.config.components)) ||
|
||||||
|
this._editMode ||
|
||||||
|
(this.hass!.user?.is_admin && !this.hass!.config.safe_mode) ||
|
||||||
|
(this.hass.panels.lovelace?.config as LovelacePanelConfig)?.mode ===
|
||||||
|
"yaml" ||
|
||||||
|
this._yamlMode
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private _handleRefresh(ev: CustomEvent<RequestSelectedDetail>): void {
|
private _handleRefresh(ev: CustomEvent<RequestSelectedDetail>): void {
|
||||||
if (!shouldHandleRequestSelectedEvent(ev)) {
|
if (!shouldHandleRequestSelectedEvent(ev)) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user