1
0
mirror of https://github.com/home-assistant/frontend.git synced 2026-04-02 00:27:49 +01:00

Fix has target check for actions (#51309)

This commit is contained in:
Bram Kragten
2026-03-31 14:37:46 +02:00
committed by GitHub
parent 9a62a9217c
commit 5cc223a582
2 changed files with 30 additions and 9 deletions

View File

@@ -95,6 +95,8 @@ import "./types/ha-automation-action-set_conversation_response";
import "./types/ha-automation-action-stop";
import "./types/ha-automation-action-wait_for_trigger";
import "./types/ha-automation-action-wait_template";
import { computeDomain } from "../../../../common/entity/compute_domain";
import { computeObjectId } from "../../../../common/entity/compute_object_id";
export const getAutomationActionType = memoizeOne(
(action: Action | undefined) => {
@@ -239,7 +241,14 @@ export default class HaAutomationActionRow extends LitElement {
private _renderRow() {
const type = getAutomationActionType(this.action);
const actionHasTarget = type === "service" && "target" in this.action;
const action = type === "service" && (this.action as ServiceAction).action;
const actionHasTarget =
action &&
"target" in
(this.hass.services?.[computeDomain(action)]?.[
computeObjectId(action)
] || {});
const target = actionHasTarget
? (this.action as ServiceAction).target
@@ -550,7 +559,10 @@ export default class HaAutomationActionRow extends LitElement {
>${this._renderRow()}</ha-automation-row
>`
: html`
<ha-expansion-panel left-chevron>
<ha-expansion-panel
left-chevron
@expanded-changed=${this._expansionPanelChanged}
>
${this._renderRow()}
</ha-expansion-panel>
`}
@@ -808,6 +820,12 @@ export default class HaAutomationActionRow extends LitElement {
}
}
private _expansionPanelChanged(ev: CustomEvent) {
if (!ev.detail.expanded) {
this._isNew = false;
}
}
private _toggleSidebar(ev: Event) {
ev?.stopPropagation();
@@ -912,9 +930,6 @@ export default class HaAutomationActionRow extends LitElement {
);
private _toggleCollapse() {
if (!this._collapsed) {
this._isNew = false;
}
this._collapsed = !this._collapsed;
}

View File

@@ -429,7 +429,10 @@ export default class HaAutomationConditionRow extends LitElement {
>${this._renderRow()}</ha-automation-row
>`
: html`
<ha-expansion-panel left-chevron>
<ha-expansion-panel
left-chevron
@expanded-changed=${this._expansionPanelChanged}
>
${this._renderRow()}
</ha-expansion-panel>
`}
@@ -754,6 +757,12 @@ export default class HaAutomationConditionRow extends LitElement {
this._isNew = true;
}
private _expansionPanelChanged(ev: CustomEvent) {
if (!ev.detail.expanded) {
this._isNew = false;
}
}
public openSidebar(condition?: Condition): void {
const sidebarCondition = condition || this.condition;
fireEvent(this, "open-sidebar", {
@@ -818,9 +827,6 @@ export default class HaAutomationConditionRow extends LitElement {
);
private _toggleCollapse() {
if (!this._collapsed) {
this._isNew = false;
}
this._collapsed = !this._collapsed;
}