Correct types for script automation editors (#9184)

This commit is contained in:
Bram Kragten
2021-05-17 16:57:43 +02:00
committed by GitHub
parent 1f65328f2d
commit 7e2bf920e1
2 changed files with 16 additions and 10 deletions

View File

@@ -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();
}