mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-22 00:36:34 +00:00
Revert conditional rendering of condition (#19257)
* Fix conditionally showing `triggered by` * revert conditional rendering * Update add-automation-element-dialog.ts * Update add-automation-element-dialog.ts
This commit is contained in:
parent
c7a98fa5a1
commit
29fefa1d60
@ -46,6 +46,7 @@ export const CONDITION_GROUPS: AutomationElementGroup = {
|
|||||||
icon: mdiDotsHorizontal,
|
icon: mdiDotsHorizontal,
|
||||||
members: {
|
members: {
|
||||||
template: {},
|
template: {},
|
||||||
|
trigger: {},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
@ -143,6 +143,16 @@ class DialogAddAutomationElement extends LitElement implements HassDialog {
|
|||||||
this._domains = undefined;
|
this._domains = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _getGroups = (
|
||||||
|
type: AddAutomationElementDialogParams["type"],
|
||||||
|
group: string | undefined
|
||||||
|
): AutomationElementGroup =>
|
||||||
|
group
|
||||||
|
? isService(group)
|
||||||
|
? {}
|
||||||
|
: TYPES[type].groups[group].members!
|
||||||
|
: TYPES[type].groups;
|
||||||
|
|
||||||
private _convertToItem = (
|
private _convertToItem = (
|
||||||
key: string,
|
key: string,
|
||||||
options,
|
options,
|
||||||
@ -169,22 +179,13 @@ class DialogAddAutomationElement extends LitElement implements HassDialog {
|
|||||||
private _getFilteredItems = memoizeOne(
|
private _getFilteredItems = memoizeOne(
|
||||||
(
|
(
|
||||||
type: AddAutomationElementDialogParams["type"],
|
type: AddAutomationElementDialogParams["type"],
|
||||||
root: AddAutomationElementDialogParams["root"],
|
|
||||||
group: string | undefined,
|
group: string | undefined,
|
||||||
filter: string,
|
filter: string,
|
||||||
localize: LocalizeFunc,
|
localize: LocalizeFunc,
|
||||||
services: HomeAssistant["services"],
|
services: HomeAssistant["services"],
|
||||||
manifests?: DomainManifestLookup
|
manifests?: DomainManifestLookup
|
||||||
): ListItem[] => {
|
): ListItem[] => {
|
||||||
const groups: AutomationElementGroup = group
|
const groups = this._getGroups(type, group);
|
||||||
? isService(group)
|
|
||||||
? {}
|
|
||||||
: TYPES[type].groups[group].members!
|
|
||||||
: TYPES[type].groups;
|
|
||||||
|
|
||||||
if (type === "condition" && group === "other" && !root) {
|
|
||||||
groups.trigger = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
const flattenGroups = (grp: AutomationElementGroup) =>
|
const flattenGroups = (grp: AutomationElementGroup) =>
|
||||||
Object.entries(grp).map(([key, options]) =>
|
Object.entries(grp).map(([key, options]) =>
|
||||||
@ -213,7 +214,6 @@ class DialogAddAutomationElement extends LitElement implements HassDialog {
|
|||||||
private _getGroupItems = memoizeOne(
|
private _getGroupItems = memoizeOne(
|
||||||
(
|
(
|
||||||
type: AddAutomationElementDialogParams["type"],
|
type: AddAutomationElementDialogParams["type"],
|
||||||
root: AddAutomationElementDialogParams["root"],
|
|
||||||
group: string | undefined,
|
group: string | undefined,
|
||||||
domains: Set<string> | undefined,
|
domains: Set<string> | undefined,
|
||||||
localize: LocalizeFunc,
|
localize: LocalizeFunc,
|
||||||
@ -221,20 +221,17 @@ class DialogAddAutomationElement extends LitElement implements HassDialog {
|
|||||||
manifests?: DomainManifestLookup
|
manifests?: DomainManifestLookup
|
||||||
): ListItem[] => {
|
): ListItem[] => {
|
||||||
if (type === "action" && isService(group)) {
|
if (type === "action" && isService(group)) {
|
||||||
const result = this._services(localize, services, manifests, group);
|
let result = this._services(localize, services, manifests, group);
|
||||||
if (group === `${SERVICE_PREFIX}media_player`) {
|
if (group === `${SERVICE_PREFIX}media_player`) {
|
||||||
result.unshift(this._convertToItem("play_media", {}, type, localize));
|
result = [
|
||||||
|
this._convertToItem("play_media", {}, type, localize),
|
||||||
|
...result,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const groups: AutomationElementGroup = group
|
const groups = this._getGroups(type, group);
|
||||||
? TYPES[type].groups[group].members!
|
|
||||||
: TYPES[type].groups;
|
|
||||||
|
|
||||||
if (type === "condition" && group === "other" && !root) {
|
|
||||||
groups.trigger = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = Object.entries(groups).map(([key, options]) =>
|
const result = Object.entries(groups).map(([key, options]) =>
|
||||||
this._convertToItem(key, options, type, localize)
|
this._convertToItem(key, options, type, localize)
|
||||||
@ -459,7 +456,6 @@ class DialogAddAutomationElement extends LitElement implements HassDialog {
|
|||||||
const items = this._filter
|
const items = this._filter
|
||||||
? this._getFilteredItems(
|
? this._getFilteredItems(
|
||||||
this._params.type,
|
this._params.type,
|
||||||
this._params.root,
|
|
||||||
this._group,
|
this._group,
|
||||||
this._filter,
|
this._filter,
|
||||||
this.hass.localize,
|
this.hass.localize,
|
||||||
@ -468,7 +464,6 @@ class DialogAddAutomationElement extends LitElement implements HassDialog {
|
|||||||
)
|
)
|
||||||
: this._getGroupItems(
|
: this._getGroupItems(
|
||||||
this._params.type,
|
this._params.type,
|
||||||
this._params.root,
|
|
||||||
this._group,
|
this._group,
|
||||||
this._domains,
|
this._domains,
|
||||||
this.hass.localize,
|
this.hass.localize,
|
||||||
@ -537,7 +532,7 @@ class DialogAddAutomationElement extends LitElement implements HassDialog {
|
|||||||
rootTabbable
|
rootTabbable
|
||||||
style=${styleMap({
|
style=${styleMap({
|
||||||
width: this._width ? `${this._width}px` : "auto",
|
width: this._width ? `${this._width}px` : "auto",
|
||||||
height: this._height ? `${Math.min(670, this._height)}px` : "auto",
|
height: this._height ? `${Math.min(468, this._height)}px` : "auto",
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
${this._params.clipboardItem &&
|
${this._params.clipboardItem &&
|
||||||
@ -660,7 +655,7 @@ class DialogAddAutomationElement extends LitElement implements HassDialog {
|
|||||||
width: 24px;
|
width: 24px;
|
||||||
}
|
}
|
||||||
mwc-list {
|
mwc-list {
|
||||||
max-height: 670px;
|
max-height: 468px;
|
||||||
max-width: 100vw;
|
max-width: 100vw;
|
||||||
}
|
}
|
||||||
search-input {
|
search-input {
|
||||||
|
@ -203,7 +203,6 @@ export default class HaAutomationCondition extends LitElement {
|
|||||||
showAddAutomationElementDialog(this, {
|
showAddAutomationElementDialog(this, {
|
||||||
type: "condition",
|
type: "condition",
|
||||||
add: this._addCondition,
|
add: this._addCondition,
|
||||||
root: !this.nested,
|
|
||||||
clipboardItem: this._clipboard?.condition?.condition,
|
clipboardItem: this._clipboard?.condition?.condition,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ export interface AddAutomationElementDialogParams {
|
|||||||
type: "trigger" | "condition" | "action";
|
type: "trigger" | "condition" | "action";
|
||||||
add: (key: string) => void;
|
add: (key: string) => void;
|
||||||
clipboardItem: string | undefined;
|
clipboardItem: string | undefined;
|
||||||
root?: boolean;
|
|
||||||
group?: string;
|
group?: string;
|
||||||
}
|
}
|
||||||
const loadDialog = () => import("./add-automation-element-dialog");
|
const loadDialog = () => import("./add-automation-element-dialog");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user