mirror of
https://github.com/home-assistant/frontend.git
synced 2025-12-20 02:38:53 +00:00
Migrate dialog-download-decrypted-backup to ha-wa-dialog (#28442)
* Migrate dialog-download-decrypted-backup.ts from ha-md-dialog to ha-wa-dialog * Fixes from other migrations
This commit is contained in:
@@ -1,18 +1,12 @@
|
|||||||
import { mdiClose } from "@mdi/js";
|
|
||||||
import type { CSSResultGroup } from "lit";
|
import type { CSSResultGroup } from "lit";
|
||||||
import { LitElement, css, html, nothing } from "lit";
|
import { LitElement, css, html, nothing } from "lit";
|
||||||
import { customElement, property, query, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { fireEvent } from "../../../../common/dom/fire_event";
|
import { fireEvent } from "../../../../common/dom/fire_event";
|
||||||
import "../../../../components/ha-dialog-header";
|
|
||||||
import "../../../../components/ha-icon-button";
|
|
||||||
import "../../../../components/ha-icon-next";
|
|
||||||
import "../../../../components/ha-md-dialog";
|
|
||||||
import type { HaMdDialog } from "../../../../components/ha-md-dialog";
|
|
||||||
import "../../../../components/ha-md-list";
|
|
||||||
import "../../../../components/ha-md-list-item";
|
|
||||||
import "../../../../components/ha-svg-icon";
|
|
||||||
import "../../../../components/ha-password-field";
|
|
||||||
import "../../../../components/ha-alert";
|
import "../../../../components/ha-alert";
|
||||||
|
import "../../../../components/ha-button";
|
||||||
|
import "../../../../components/ha-dialog-footer";
|
||||||
|
import "../../../../components/ha-wa-dialog";
|
||||||
|
import "../../../../components/ha-password-field";
|
||||||
import {
|
import {
|
||||||
canDecryptBackupOnDownload,
|
canDecryptBackupOnDownload,
|
||||||
getPreferredAgentForDownload,
|
getPreferredAgentForDownload,
|
||||||
@@ -27,58 +21,49 @@ import type { DownloadDecryptedBackupDialogParams } from "./show-dialog-download
|
|||||||
class DialogDownloadDecryptedBackup extends LitElement implements HassDialog {
|
class DialogDownloadDecryptedBackup extends LitElement implements HassDialog {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
@state() private _opened = false;
|
@state() private _open = false;
|
||||||
|
|
||||||
@state() private _params?: DownloadDecryptedBackupDialogParams;
|
@state() private _params?: DownloadDecryptedBackupDialogParams;
|
||||||
|
|
||||||
@query("ha-md-dialog") private _dialog?: HaMdDialog;
|
|
||||||
|
|
||||||
@state() private _encryptionKey = "";
|
@state() private _encryptionKey = "";
|
||||||
|
|
||||||
@state() private _error = "";
|
@state() private _error = "";
|
||||||
|
|
||||||
public showDialog(params: DownloadDecryptedBackupDialogParams): void {
|
public showDialog(params: DownloadDecryptedBackupDialogParams): void {
|
||||||
this._opened = true;
|
this._open = true;
|
||||||
this._params = params;
|
this._params = params;
|
||||||
}
|
}
|
||||||
|
|
||||||
public closeDialog() {
|
public closeDialog() {
|
||||||
this._dialog?.close();
|
this._open = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _dialogClosed() {
|
private _dialogClosed() {
|
||||||
if (this._opened) {
|
if (this._open) {
|
||||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||||
}
|
}
|
||||||
this._opened = false;
|
this._open = false;
|
||||||
this._params = undefined;
|
this._params = undefined;
|
||||||
this._encryptionKey = "";
|
this._encryptionKey = "";
|
||||||
this._error = "";
|
this._error = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
if (!this._opened || !this._params) {
|
if (!this._params) {
|
||||||
return nothing;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-md-dialog open @closed=${this._dialogClosed} disable-cancel-action>
|
<ha-wa-dialog
|
||||||
<ha-dialog-header slot="headline">
|
.hass=${this.hass}
|
||||||
<ha-icon-button
|
.open=${this._open}
|
||||||
slot="navigationIcon"
|
header-title=${this.hass.localize(
|
||||||
@click=${this.closeDialog}
|
|
||||||
.label=${this.hass.localize("ui.common.close")}
|
|
||||||
.path=${mdiClose}
|
|
||||||
></ha-icon-button>
|
|
||||||
<span slot="title">
|
|
||||||
${this.hass.localize(
|
|
||||||
"ui.panel.config.backup.dialogs.download.title"
|
"ui.panel.config.backup.dialogs.download.title"
|
||||||
)}
|
)}
|
||||||
</span>
|
prevent-scrim-close
|
||||||
</ha-dialog-header>
|
@closed=${this._dialogClosed}
|
||||||
|
>
|
||||||
<div slot="content">
|
|
||||||
<p>
|
<p>
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.backup.dialogs.download.description"
|
"ui.panel.config.backup.dialogs.download.description"
|
||||||
@@ -110,19 +95,22 @@ class DialogDownloadDecryptedBackup extends LitElement implements HassDialog {
|
|||||||
${this._error
|
${this._error
|
||||||
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
? html`<ha-alert alert-type="error">${this._error}</ha-alert>`
|
||||||
: nothing}
|
: nothing}
|
||||||
</div>
|
<ha-dialog-footer slot="footer">
|
||||||
<div slot="actions">
|
<ha-button
|
||||||
<ha-button appearance="plain" @click=${this._cancel}>
|
slot="secondaryAction"
|
||||||
|
appearance="plain"
|
||||||
|
@click=${this._cancel}
|
||||||
|
>
|
||||||
${this.hass.localize("ui.common.cancel")}
|
${this.hass.localize("ui.common.cancel")}
|
||||||
</ha-button>
|
</ha-button>
|
||||||
|
|
||||||
<ha-button @click=${this._submit}>
|
<ha-button slot="primaryAction" @click=${this._submit}>
|
||||||
${this.hass.localize(
|
${this.hass.localize(
|
||||||
"ui.panel.config.backup.dialogs.download.download"
|
"ui.panel.config.backup.dialogs.download.download"
|
||||||
)}
|
)}
|
||||||
</ha-button>
|
</ha-button>
|
||||||
</div>
|
</ha-dialog-footer>
|
||||||
</ha-md-dialog>
|
</ha-wa-dialog>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,17 +179,8 @@ class DialogDownloadDecryptedBackup extends LitElement implements HassDialog {
|
|||||||
haStyle,
|
haStyle,
|
||||||
haStyleDialog,
|
haStyleDialog,
|
||||||
css`
|
css`
|
||||||
ha-md-dialog {
|
ha-wa-dialog {
|
||||||
--dialog-content-padding: 8px 24px;
|
--dialog-content-padding: var(--ha-space-2) var(--ha-space-6);
|
||||||
max-width: 500px;
|
|
||||||
}
|
|
||||||
@media all and (max-width: 450px), all and (max-height: 500px) {
|
|
||||||
ha-md-dialog {
|
|
||||||
max-width: none;
|
|
||||||
}
|
|
||||||
div[slot="content"] {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
button.link {
|
button.link {
|
||||||
|
|||||||
Reference in New Issue
Block a user