mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-18 23:06:40 +00:00
Correct types for script automation editors (#9184)
This commit is contained in:
parent
1f65328f2d
commit
7e2bf920e1
@ -75,7 +75,7 @@ declare global {
|
||||
export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
|
||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||
|
||||
@property() public automationId!: string;
|
||||
@property() public automationId: string | null = null;
|
||||
|
||||
@property() public automations!: AutomationEntity[];
|
||||
|
||||
@ -178,14 +178,14 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
|
||||
aria-label=${this.hass.localize(
|
||||
"ui.panel.config.automation.picker.delete_automation"
|
||||
)}
|
||||
class=${classMap({ warning: this.automationId })}
|
||||
class=${classMap({ warning: Boolean(this.automationId) })}
|
||||
graphic="icon"
|
||||
>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.automation.picker.delete_automation"
|
||||
)}
|
||||
<ha-svg-icon
|
||||
class=${classMap({ warning: this.automationId })}
|
||||
class=${classMap({ warning: Boolean(this.automationId) })}
|
||||
slot="graphic"
|
||||
.path=${mdiDelete}
|
||||
>
|
||||
@ -349,7 +349,10 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
|
||||
|
||||
private async _loadConfig() {
|
||||
try {
|
||||
const config = await getAutomationConfig(this.hass, this.automationId);
|
||||
const config = await getAutomationConfig(
|
||||
this.hass,
|
||||
this.automationId as string
|
||||
);
|
||||
|
||||
// Normalize data: ensure trigger, action and condition are lists
|
||||
// Happens when people copy paste their automations into the config
|
||||
@ -470,7 +473,7 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
|
||||
}
|
||||
|
||||
private async _delete() {
|
||||
await deleteAutomation(this.hass, this.automationId);
|
||||
await deleteAutomation(this.hass, this.automationId as string);
|
||||
history.back();
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ import { configSections } from "../ha-panel-config";
|
||||
export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
|
||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||
|
||||
@property() public scriptEntityId!: string;
|
||||
@property() public scriptEntityId: string | null = null;
|
||||
|
||||
@property() public route!: Route;
|
||||
|
||||
@ -161,12 +161,12 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
|
||||
aria-label=${this.hass.localize(
|
||||
"ui.panel.config.script.editor.delete_script"
|
||||
)}
|
||||
class=${classMap({ warning: this.scriptEntityId })}
|
||||
class=${classMap({ warning: Boolean(this.scriptEntityId) })}
|
||||
graphic="icon"
|
||||
>
|
||||
${this.hass.localize("ui.panel.config.script.editor.delete_script")}
|
||||
<ha-svg-icon
|
||||
class=${classMap({ warning: this.scriptEntityId })}
|
||||
class=${classMap({ warning: Boolean(this.scriptEntityId) })}
|
||||
slot="graphic"
|
||||
.path=${mdiDelete}
|
||||
>
|
||||
@ -470,7 +470,7 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
|
||||
|
||||
private async _runScript(ev) {
|
||||
ev.stopPropagation();
|
||||
await triggerScript(this.hass, this.scriptEntityId);
|
||||
await triggerScript(this.hass, this.scriptEntityId as string);
|
||||
showToast(this, {
|
||||
message: this.hass.localize(
|
||||
"ui.notification_toast.triggered",
|
||||
@ -620,7 +620,10 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
|
||||
}
|
||||
|
||||
private async _delete() {
|
||||
await deleteScript(this.hass, computeObjectId(this.scriptEntityId));
|
||||
await deleteScript(
|
||||
this.hass,
|
||||
computeObjectId(this.scriptEntityId as string)
|
||||
);
|
||||
history.back();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user