Fix device config tooltips (#24780)

* Device config tooltips

* Update src/panels/config/devices/ha-config-device-page.ts

Co-authored-by: Petar Petrov <MindFreeze@users.noreply.github.com>

---------

Co-authored-by: Petar Petrov <MindFreeze@users.noreply.github.com>
This commit is contained in:
Simon Lamon 2025-03-26 08:32:14 +01:00 committed by GitHub
parent 9cfcd21a93
commit fb11c21518
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -448,30 +448,18 @@ export class HaConfigDevicePage extends LitElement {
${this._related.automation.map((automation) => {
const entityState = this.hass.states[automation];
return entityState
? html`<ha-tooltip
placement="left"
.disabled=${!!entityState.attributes.id}
.content=${this.hass.localize(
"ui.panel.config.devices.cant_edit"
? html`<a
href=${ifDefined(
entityState.attributes.id
? `/config/automation/edit/${encodeURIComponent(entityState.attributes.id)}`
: `/config/automation/show/${entityState.entity_id}`
)}
>
<a
href=${ifDefined(
entityState.attributes.id
? `/config/automation/edit/${encodeURIComponent(entityState.attributes.id)}`
: undefined
)}
>
<ha-list-item
hasMeta
.automation=${entityState}
.disabled=${!entityState.attributes.id}
>
${computeStateName(entityState)}
<ha-icon-next slot="meta"></ha-icon-next>
</ha-list-item>
</a>
</ha-tooltip>`
<ha-list-item hasMeta .automation=${entityState}>
${computeStateName(entityState)}
<ha-icon-next slot="meta"></ha-icon-next>
</ha-list-item>
</a>`
: nothing;
})}
</div>
@ -536,34 +524,30 @@ export class HaConfigDevicePage extends LitElement {
<div class="items">
${this._related.scene.map((scene) => {
const entityState = this.hass.states[scene];
return entityState
return entityState && entityState.attributes.id
? html`
<a
href=${`/config/scene/edit/${entityState.attributes.id}`}
>
<ha-list-item hasMeta .scene=${entityState}>
${computeStateName(entityState)}
<ha-icon-next slot="meta"></ha-icon-next>
</ha-list-item>
</a>
`
: html`
<ha-tooltip
placement="left"
.disabled=${!!entityState.attributes.id}
.content=${this.hass.localize(
"ui.panel.config.devices.cant_edit"
)}
>
<a
href=${ifDefined(
entityState.attributes.id
? `/config/scene/edit/${entityState.attributes.id}`
: undefined
)}
>
<ha-list-item
hasMeta
.scene=${entityState}
.disabled=${!entityState.attributes.id}
>
${computeStateName(entityState)}
<ha-icon-next slot="meta"></ha-icon-next>
</ha-list-item>
</a>
<ha-list-item hasMeta .scene=${entityState}>
${computeStateName(entityState)}
<ha-icon-next slot="meta"></ha-icon-next>
</ha-list-item>
</ha-tooltip>
`
: nothing;
`;
})}
</div>
`