Only show more info settings button for admin users (#15689)

Only show settings button for admin users
This commit is contained in:
Paul Bottein 2023-03-03 12:24:01 +01:00 committed by GitHub
parent 84affcce33
commit 19efe9dcdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,7 +8,7 @@ import {
mdiPencilOutline, mdiPencilOutline,
} from "@mdi/js"; } from "@mdi/js";
import type { HassEntity } from "home-assistant-js-websocket"; import type { HassEntity } from "home-assistant-js-websocket";
import { css, html, LitElement, PropertyValues } from "lit"; import { css, html, LitElement, nothing, PropertyValues } from "lit";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state } from "lit/decorators";
import { cache } from "lit/directives/cache"; import { cache } from "lit/directives/cache";
import { dynamicElement } from "../../common/dom/dynamic-element-directive"; import { dynamicElement } from "../../common/dom/dynamic-element-directive";
@ -211,7 +211,7 @@ export class MoreInfoDialog extends LitElement {
protected render() { protected render() {
if (!this._entityId) { if (!this._entityId) {
return null; return nothing;
} }
const entityId = this._entityId; const entityId = this._entityId;
const stateObj = this.hass.states[entityId] as HassEntity | undefined; const stateObj = this.hass.states[entityId] as HassEntity | undefined;
@ -261,7 +261,7 @@ export class MoreInfoDialog extends LitElement {
> >
${title} ${title}
</div>` </div>`
: null} : nothing}
${isInfoView ${isInfoView
? html` ? html`
${this.shouldShowHistory(domain) ${this.shouldShowHistory(domain)
@ -275,77 +275,79 @@ export class MoreInfoDialog extends LitElement {
@click=${this._goToHistory} @click=${this._goToHistory}
></ha-icon-button> ></ha-icon-button>
` `
: null} : nothing}
<ha-icon-button
slot="actionItems"
.label=${this.hass.localize(
"ui.dialogs.more_info_control.settings"
)}
.path=${mdiCogOutline}
@click=${this._goToSettings}
></ha-icon-button>
${isAdmin ${isAdmin
? html`<ha-button-menu ? html`
corner="BOTTOM_END"
menuCorner="END"
slot="actionItems"
@closed=${stopPropagation}
fixed
>
<ha-icon-button <ha-icon-button
slot="trigger" slot="actionItems"
.label=${this.hass.localize("ui.common.menu")} .label=${this.hass.localize(
.path=${mdiDotsVertical} "ui.dialogs.more_info_control.settings"
></ha-icon-button>
${deviceId
? html`
<ha-list-item
graphic="icon"
@request-selected=${this._goToDevice}
>
${this.hass.localize(
"ui.dialogs.more_info_control.device_info"
)}
<ha-svg-icon
slot="graphic"
.path=${mdiDevices}
></ha-svg-icon>
</ha-list-item>
`
: null}
${this.shouldShowEditIcon(domain, stateObj)
? html`
<ha-list-item
graphic="icon"
@request-selected=${this._goToEdit}
>
${this.hass.localize(
"ui.dialogs.more_info_control.edit"
)}
<ha-svg-icon
slot="graphic"
.path=${mdiPencilOutline}
></ha-svg-icon>
</ha-list-item>
`
: null}
<ha-list-item
graphic="icon"
@request-selected=${this._goToRelated}
>
${this.hass.localize(
"ui.dialogs.more_info_control.related"
)} )}
<ha-svg-icon .path=${mdiCogOutline}
slot="graphic" @click=${this._goToSettings}
.path=${mdiInformationOutline} ></ha-icon-button>
></ha-svg-icon> <ha-button-menu
</ha-list-item> corner="BOTTOM_END"
</ha-button-menu>` menuCorner="END"
: null} slot="actionItems"
@closed=${stopPropagation}
fixed
>
<ha-icon-button
slot="trigger"
.label=${this.hass.localize("ui.common.menu")}
.path=${mdiDotsVertical}
></ha-icon-button>
${deviceId
? html`
<ha-list-item
graphic="icon"
@request-selected=${this._goToDevice}
>
${this.hass.localize(
"ui.dialogs.more_info_control.device_info"
)}
<ha-svg-icon
slot="graphic"
.path=${mdiDevices}
></ha-svg-icon>
</ha-list-item>
`
: nothing}
${this.shouldShowEditIcon(domain, stateObj)
? html`
<ha-list-item
graphic="icon"
@request-selected=${this._goToEdit}
>
${this.hass.localize(
"ui.dialogs.more_info_control.edit"
)}
<ha-svg-icon
slot="graphic"
.path=${mdiPencilOutline}
></ha-svg-icon>
</ha-list-item>
`
: nothing}
<ha-list-item
graphic="icon"
@request-selected=${this._goToRelated}
>
${this.hass.localize(
"ui.dialogs.more_info_control.related"
)}
<ha-svg-icon
slot="graphic"
.path=${mdiInformationOutline}
></ha-svg-icon>
</ha-list-item>
</ha-button-menu>
`
: nothing}
` `
: null} : nothing}
</ha-header-bar> </ha-header-bar>
</div> </div>
<div <div
@ -396,7 +398,7 @@ export class MoreInfoDialog extends LitElement {
itemType="entity" itemType="entity"
></ha-related-items> ></ha-related-items>
` `
: null : nothing
)} )}
</div> </div>
</ha-dialog> </ha-dialog>