From a19477d1791ed7f4ee79b389d4a8571e4e9688f0 Mon Sep 17 00:00:00 2001 From: Josh McCarty Date: Tue, 27 Oct 2020 07:24:52 -0700 Subject: [PATCH] Migrate ha-paper-dialog to ha-dialog in system options dialog (#7455) --- .../dialog-config-entry-system-options.ts | 83 +++++++++---------- 1 file changed, 37 insertions(+), 46 deletions(-) diff --git a/src/dialogs/config-entry-system-options/dialog-config-entry-system-options.ts b/src/dialogs/config-entry-system-options/dialog-config-entry-system-options.ts index d7a2ad6fbc..54ab1c7f41 100644 --- a/src/dialogs/config-entry-system-options/dialog-config-entry-system-options.ts +++ b/src/dialogs/config-entry-system-options/dialog-config-entry-system-options.ts @@ -1,5 +1,4 @@ -import "@polymer/paper-dialog-scrollable/paper-dialog-scrollable"; -import "@polymer/paper-input/paper-input"; +import "@material/mwc-button/mwc-button"; import { css, CSSResult, @@ -10,16 +9,16 @@ import { internalProperty, TemplateResult, } from "lit-element"; -import "../../components/dialog/ha-paper-dialog"; +import "../../components/ha-dialog"; import "../../components/ha-circular-progress"; import "../../components/ha-switch"; import "../../components/ha-formfield"; +import { fireEvent } from "../../common/dom/fire_event"; import type { HaSwitch } from "../../components/ha-switch"; import { getConfigEntrySystemOptions, updateConfigEntrySystemOptions, } from "../../data/config_entries"; -import type { PolymerChangedEvent } from "../../polymer-types"; import { haStyleDialog } from "../../resources/styles"; import type { HomeAssistant } from "../../types"; import { ConfigEntrySystemOptionsDialogParams } from "./show-dialog-config-entry-system-options"; @@ -35,9 +34,9 @@ class DialogConfigEntrySystemOptions extends LitElement { @internalProperty() private _params?: ConfigEntrySystemOptionsDialogParams; - @internalProperty() private _loading?: boolean; + @internalProperty() private _loading = false; - @internalProperty() private _submitting?: boolean; + @internalProperty() private _submitting = false; public async showDialog( params: ConfigEntrySystemOptionsDialogParams @@ -51,7 +50,12 @@ class DialogConfigEntrySystemOptions extends LitElement { ); this._loading = false; this._disableNewEntities = systemOptions.disable_new_entities; - await this.updateComplete; + } + + public closeDialog(): void { + this._error = ""; + this._params = undefined; + fireEvent(this, "dialog-closed", { dialog: this.localName }); } protected render(): TemplateResult { @@ -60,21 +64,17 @@ class DialogConfigEntrySystemOptions extends LitElement { } return html` - -

- ${this.hass.localize( - "ui.dialogs.config_entry_system_options.title", - "integration", - this.hass.localize( - `component.${this._params.entry.domain}.title` - ) || this._params.entry.domain - )} -

- +
${this._loading ? html`
@@ -112,22 +112,22 @@ class DialogConfigEntrySystemOptions extends LitElement {
`} - - ${!this._loading - ? html` -
- - ${this.hass.localize( - "ui.dialogs.config_entry_system_options.update" - )} - -
- ` - : ""} - +
+ + ${this.hass.localize("ui.common.cancel")} + + + ${this.hass.localize("ui.dialogs.config_entry_system_options.update")} + + `; } @@ -154,19 +154,10 @@ class DialogConfigEntrySystemOptions extends LitElement { } } - private _openedChanged(ev: PolymerChangedEvent): void { - if (!(ev.detail as any).value) { - this._params = undefined; - } - } - static get styles(): CSSResult[] { return [ haStyleDialog, css` - ha-paper-dialog { - max-width: 500px; - } .init-spinner { padding: 50px 100px; text-align: center;