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,7 +275,9 @@ export class MoreInfoDialog extends LitElement {
@click=${this._goToHistory} @click=${this._goToHistory}
></ha-icon-button> ></ha-icon-button>
` `
: null} : nothing}
${isAdmin
? html`
<ha-icon-button <ha-icon-button
slot="actionItems" slot="actionItems"
.label=${this.hass.localize( .label=${this.hass.localize(
@ -284,8 +286,7 @@ export class MoreInfoDialog extends LitElement {
.path=${mdiCogOutline} .path=${mdiCogOutline}
@click=${this._goToSettings} @click=${this._goToSettings}
></ha-icon-button> ></ha-icon-button>
${isAdmin <ha-button-menu
? html`<ha-button-menu
corner="BOTTOM_END" corner="BOTTOM_END"
menuCorner="END" menuCorner="END"
slot="actionItems" slot="actionItems"
@ -313,7 +314,7 @@ export class MoreInfoDialog extends LitElement {
></ha-svg-icon> ></ha-svg-icon>
</ha-list-item> </ha-list-item>
` `
: null} : nothing}
${this.shouldShowEditIcon(domain, stateObj) ${this.shouldShowEditIcon(domain, stateObj)
? html` ? html`
<ha-list-item <ha-list-item
@ -329,7 +330,7 @@ export class MoreInfoDialog extends LitElement {
></ha-svg-icon> ></ha-svg-icon>
</ha-list-item> </ha-list-item>
` `
: null} : nothing}
<ha-list-item <ha-list-item
graphic="icon" graphic="icon"
@request-selected=${this._goToRelated} @request-selected=${this._goToRelated}
@ -342,10 +343,11 @@ export class MoreInfoDialog extends LitElement {
.path=${mdiInformationOutline} .path=${mdiInformationOutline}
></ha-svg-icon> ></ha-svg-icon>
</ha-list-item> </ha-list-item>
</ha-button-menu>` </ha-button-menu>
: null}
` `
: null} : nothing}
`
: 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>