Skip to content

Commit

Permalink
20240103.1 (#19258)
Browse files Browse the repository at this point in the history
  • Loading branch information
bramkragten authored Jan 3, 2024
2 parents 0bc69fb + 336214d commit 4ea7d82
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 27 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "home-assistant-frontend"
version = "20240103.0"
version = "20240103.1"
license = {text = "Apache-2.0"}
description = "The Home Assistant frontend"
readme = "README.md"
Expand Down
1 change: 1 addition & 0 deletions src/data/condition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const CONDITION_GROUPS: AutomationElementGroup = {
icon: mdiDotsHorizontal,
members: {
template: {},
trigger: {},
},
},
} as const;
43 changes: 19 additions & 24 deletions src/panels/config/automation/add-automation-element-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,16 @@ class DialogAddAutomationElement extends LitElement implements HassDialog {
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 = (
key: string,
options,
Expand All @@ -169,22 +179,13 @@ class DialogAddAutomationElement extends LitElement implements HassDialog {
private _getFilteredItems = memoizeOne(
(
type: AddAutomationElementDialogParams["type"],
root: AddAutomationElementDialogParams["root"],
group: string | undefined,
filter: string,
localize: LocalizeFunc,
services: HomeAssistant["services"],
manifests?: DomainManifestLookup
): ListItem[] => {
const groups: AutomationElementGroup = group
? isService(group)
? {}
: TYPES[type].groups[group].members!
: TYPES[type].groups;

if (type === "condition" && group === "other" && !root) {
groups.trigger = {};
}
const groups = this._getGroups(type, group);

const flattenGroups = (grp: AutomationElementGroup) =>
Object.entries(grp).map(([key, options]) =>
Expand Down Expand Up @@ -213,28 +214,24 @@ class DialogAddAutomationElement extends LitElement implements HassDialog {
private _getGroupItems = memoizeOne(
(
type: AddAutomationElementDialogParams["type"],
root: AddAutomationElementDialogParams["root"],
group: string | undefined,
domains: Set<string> | undefined,
localize: LocalizeFunc,
services: HomeAssistant["services"],
manifests?: DomainManifestLookup
): ListItem[] => {
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`) {
result.unshift(this._convertToItem("play_media", {}, type, localize));
result = [
this._convertToItem("play_media", {}, type, localize),
...result,
];
}
return result;
}

const groups: AutomationElementGroup = group
? TYPES[type].groups[group].members!
: TYPES[type].groups;

if (type === "condition" && group === "other" && !root) {
groups.trigger = {};
}
const groups = this._getGroups(type, group);

const result = Object.entries(groups).map(([key, options]) =>
this._convertToItem(key, options, type, localize)
Expand Down Expand Up @@ -459,7 +456,6 @@ class DialogAddAutomationElement extends LitElement implements HassDialog {
const items = this._filter
? this._getFilteredItems(
this._params.type,
this._params.root,
this._group,
this._filter,
this.hass.localize,
Expand All @@ -468,7 +464,6 @@ class DialogAddAutomationElement extends LitElement implements HassDialog {
)
: this._getGroupItems(
this._params.type,
this._params.root,
this._group,
this._domains,
this.hass.localize,
Expand Down Expand Up @@ -537,7 +532,7 @@ class DialogAddAutomationElement extends LitElement implements HassDialog {
rootTabbable
style=${styleMap({
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 &&
Expand Down Expand Up @@ -660,7 +655,7 @@ class DialogAddAutomationElement extends LitElement implements HassDialog {
width: 24px;
}
mwc-list {
max-height: 670px;
max-height: 468px;
max-width: 100vw;
}
search-input {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ export default class HaAutomationCondition extends LitElement {
showAddAutomationElementDialog(this, {
type: "condition",
add: this._addCondition,
root: !this.nested,
clipboardItem: this._clipboard?.condition?.condition,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export interface AddAutomationElementDialogParams {
type: "trigger" | "condition" | "action";
add: (key: string) => void;
clipboardItem: string | undefined;
root?: boolean;
group?: string;
}
const loadDialog = () => import("./add-automation-element-dialog");
Expand Down

0 comments on commit 4ea7d82

Please sign in to comment.