mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-25 05:47:20 +00:00
Ensure we have all mandatory action keys present in action editor (#8424)
This commit is contained in:
parent
d76af2cb61
commit
741ac679a0
@ -49,10 +49,15 @@ export class HuiActionEditor extends LitElement {
|
||||
return config.url_path || "";
|
||||
}
|
||||
|
||||
get _service(): string {
|
||||
const config = this.config as CallServiceActionConfig;
|
||||
return config.service || "";
|
||||
}
|
||||
|
||||
private _serviceAction = memoizeOne(
|
||||
(config: CallServiceActionConfig): ServiceAction => {
|
||||
return {
|
||||
service: config.service || "",
|
||||
service: this._service,
|
||||
data: config.service_data,
|
||||
target: config.target,
|
||||
};
|
||||
@ -155,8 +160,25 @@ export class HuiActionEditor extends LitElement {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
let data;
|
||||
switch (value) {
|
||||
case "url": {
|
||||
data = { url_path: this._url_path };
|
||||
break;
|
||||
}
|
||||
case "call-service": {
|
||||
data = { service: this._service };
|
||||
break;
|
||||
}
|
||||
case "navigate": {
|
||||
data = { navigation_path: this._navigation_path };
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fireEvent(this, "value-changed", {
|
||||
value: { action: value },
|
||||
value: { action: value, ...data },
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -120,13 +120,13 @@ const actionConfigStructConfirmation = union([
|
||||
|
||||
const actionConfigStructUrl = object({
|
||||
action: literal("url"),
|
||||
url_path: optional(string()),
|
||||
url_path: string(),
|
||||
confirmation: optional(actionConfigStructConfirmation),
|
||||
});
|
||||
|
||||
const actionConfigStructService = object({
|
||||
action: literal("call-service"),
|
||||
service: optional(string()),
|
||||
service: string(),
|
||||
service_data: optional(object()),
|
||||
target: optional(
|
||||
object({
|
||||
@ -140,7 +140,7 @@ const actionConfigStructService = object({
|
||||
|
||||
const actionConfigStructNavigate = object({
|
||||
action: literal("navigate"),
|
||||
navigation_path: optional(string()),
|
||||
navigation_path: string(),
|
||||
confirmation: optional(actionConfigStructConfirmation),
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user