mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 09:16:38 +00:00
Migrate ha-paper-dialog to ha-dialog in system options dialog (#7455)
This commit is contained in:
parent
bf98a78f3d
commit
a19477d179
@ -1,5 +1,4 @@
|
|||||||
import "@polymer/paper-dialog-scrollable/paper-dialog-scrollable";
|
import "@material/mwc-button/mwc-button";
|
||||||
import "@polymer/paper-input/paper-input";
|
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
CSSResult,
|
CSSResult,
|
||||||
@ -10,16 +9,16 @@ import {
|
|||||||
internalProperty,
|
internalProperty,
|
||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import "../../components/dialog/ha-paper-dialog";
|
import "../../components/ha-dialog";
|
||||||
import "../../components/ha-circular-progress";
|
import "../../components/ha-circular-progress";
|
||||||
import "../../components/ha-switch";
|
import "../../components/ha-switch";
|
||||||
import "../../components/ha-formfield";
|
import "../../components/ha-formfield";
|
||||||
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
import type { HaSwitch } from "../../components/ha-switch";
|
import type { HaSwitch } from "../../components/ha-switch";
|
||||||
import {
|
import {
|
||||||
getConfigEntrySystemOptions,
|
getConfigEntrySystemOptions,
|
||||||
updateConfigEntrySystemOptions,
|
updateConfigEntrySystemOptions,
|
||||||
} from "../../data/config_entries";
|
} from "../../data/config_entries";
|
||||||
import type { PolymerChangedEvent } from "../../polymer-types";
|
|
||||||
import { haStyleDialog } from "../../resources/styles";
|
import { haStyleDialog } from "../../resources/styles";
|
||||||
import type { HomeAssistant } from "../../types";
|
import type { HomeAssistant } from "../../types";
|
||||||
import { ConfigEntrySystemOptionsDialogParams } from "./show-dialog-config-entry-system-options";
|
import { ConfigEntrySystemOptionsDialogParams } from "./show-dialog-config-entry-system-options";
|
||||||
@ -35,9 +34,9 @@ class DialogConfigEntrySystemOptions extends LitElement {
|
|||||||
|
|
||||||
@internalProperty() private _params?: ConfigEntrySystemOptionsDialogParams;
|
@internalProperty() private _params?: ConfigEntrySystemOptionsDialogParams;
|
||||||
|
|
||||||
@internalProperty() private _loading?: boolean;
|
@internalProperty() private _loading = false;
|
||||||
|
|
||||||
@internalProperty() private _submitting?: boolean;
|
@internalProperty() private _submitting = false;
|
||||||
|
|
||||||
public async showDialog(
|
public async showDialog(
|
||||||
params: ConfigEntrySystemOptionsDialogParams
|
params: ConfigEntrySystemOptionsDialogParams
|
||||||
@ -51,7 +50,12 @@ class DialogConfigEntrySystemOptions extends LitElement {
|
|||||||
);
|
);
|
||||||
this._loading = false;
|
this._loading = false;
|
||||||
this._disableNewEntities = systemOptions.disable_new_entities;
|
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 {
|
protected render(): TemplateResult {
|
||||||
@ -60,21 +64,17 @@ class DialogConfigEntrySystemOptions extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-paper-dialog
|
<ha-dialog
|
||||||
with-backdrop
|
open
|
||||||
opened
|
@closed=${this.closeDialog}
|
||||||
@opened-changed="${this._openedChanged}"
|
.heading=${this.hass.localize(
|
||||||
|
"ui.dialogs.config_entry_system_options.title",
|
||||||
|
"integration",
|
||||||
|
this.hass.localize(`component.${this._params.entry.domain}.title`) ||
|
||||||
|
this._params.entry.domain
|
||||||
|
)}
|
||||||
>
|
>
|
||||||
<h2>
|
<div>
|
||||||
${this.hass.localize(
|
|
||||||
"ui.dialogs.config_entry_system_options.title",
|
|
||||||
"integration",
|
|
||||||
this.hass.localize(
|
|
||||||
`component.${this._params.entry.domain}.title`
|
|
||||||
) || this._params.entry.domain
|
|
||||||
)}
|
|
||||||
</h2>
|
|
||||||
<paper-dialog-scrollable>
|
|
||||||
${this._loading
|
${this._loading
|
||||||
? html`
|
? html`
|
||||||
<div class="init-spinner">
|
<div class="init-spinner">
|
||||||
@ -112,22 +112,22 @@ class DialogConfigEntrySystemOptions extends LitElement {
|
|||||||
</ha-formfield>
|
</ha-formfield>
|
||||||
</div>
|
</div>
|
||||||
`}
|
`}
|
||||||
</paper-dialog-scrollable>
|
</div>
|
||||||
${!this._loading
|
<mwc-button
|
||||||
? html`
|
slot="secondaryAction"
|
||||||
<div class="paper-dialog-buttons">
|
@click=${this.closeDialog}
|
||||||
<mwc-button
|
.disabled=${this._submitting}
|
||||||
@click="${this._updateEntry}"
|
>
|
||||||
.disabled=${this._submitting}
|
${this.hass.localize("ui.common.cancel")}
|
||||||
>
|
</mwc-button>
|
||||||
${this.hass.localize(
|
<mwc-button
|
||||||
"ui.dialogs.config_entry_system_options.update"
|
slot="primaryAction"
|
||||||
)}
|
@click="${this._updateEntry}"
|
||||||
</mwc-button>
|
.disabled=${this._submitting || this._loading}
|
||||||
</div>
|
>
|
||||||
`
|
${this.hass.localize("ui.dialogs.config_entry_system_options.update")}
|
||||||
: ""}
|
</mwc-button>
|
||||||
</ha-paper-dialog>
|
</ha-dialog>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,19 +154,10 @@ class DialogConfigEntrySystemOptions extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _openedChanged(ev: PolymerChangedEvent<boolean>): void {
|
|
||||||
if (!(ev.detail as any).value) {
|
|
||||||
this._params = undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static get styles(): CSSResult[] {
|
static get styles(): CSSResult[] {
|
||||||
return [
|
return [
|
||||||
haStyleDialog,
|
haStyleDialog,
|
||||||
css`
|
css`
|
||||||
ha-paper-dialog {
|
|
||||||
max-width: 500px;
|
|
||||||
}
|
|
||||||
.init-spinner {
|
.init-spinner {
|
||||||
padding: 50px 100px;
|
padding: 50px 100px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user