1
0
mirror of https://github.com/home-assistant/frontend.git synced 2026-05-08 17:28:46 +01:00

Allow adding variable action in the automation UI (#16502)

This commit is contained in:
Paul Bottein
2023-05-11 11:19:36 +02:00
committed by GitHub
parent 72403f4276
commit 450565799e
3 changed files with 15 additions and 4 deletions
+7 -1
View File
@@ -1,5 +1,6 @@
import {
mdiAbTesting,
mdiApplicationVariableOutline,
mdiArrowDecision,
mdiCallSplit,
mdiCodeBraces,
@@ -30,4 +31,9 @@ export const ACTION_TYPES = {
device_id: mdiDevices,
stop: mdiHandBackRight,
parallel: mdiShuffleDisabled,
};
variables: mdiApplicationVariableOutline,
} as const;
export const YAML_ONLY_ACTION_TYPES = new Set<keyof typeof ACTION_TYPES>([
"variables",
]);
@@ -8,8 +8,8 @@ import {
mdiPlay,
mdiPlayCircleOutline,
mdiRenameBox,
mdiStopCircleOutline,
mdiSort,
mdiStopCircleOutline,
} from "@mdi/js";
import { UnsubscribeFunc } from "home-assistant-js-websocket";
import { css, CSSResultGroup, html, LitElement, PropertyValues } from "lit";
@@ -25,7 +25,7 @@ import "../../../../components/ha-card";
import "../../../../components/ha-expansion-panel";
import "../../../../components/ha-icon-button";
import type { HaYamlEditor } from "../../../../components/ha-yaml-editor";
import { ACTION_TYPES } from "../../../../data/action";
import { ACTION_TYPES, YAML_ONLY_ACTION_TYPES } from "../../../../data/action";
import { validateConfig } from "../../../../data/config";
import {
EntityRegistryEntry,
@@ -134,7 +134,9 @@ export default class HaAutomationActionRow extends LitElement {
if (!changedProperties.has("action")) {
return;
}
this._uiModeAvailable = getType(this.action) !== undefined;
const type = getType(this.action);
this._uiModeAvailable =
type !== undefined && !YAML_ONLY_ACTION_TYPES.has(type as any);
if (!this._uiModeAvailable && !this._yamlMode) {
this._yamlMode = true;
}
+3
View File
@@ -2566,6 +2566,9 @@
},
"parallel": {
"label": "Run in parallel"
},
"variables": {
"label": "Define variables"
}
}
}