Compare commits

..

1 Commits

Author SHA1 Message Date
Aidan Timson
4ba952374d Migrate onboarding dialog(s) to wa 2026-02-05 15:42:04 +00:00
8 changed files with 153 additions and 170 deletions

View File

@@ -1,18 +1,32 @@
import { LitElement, css, html, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import { customElement, property, state } from "lit/decorators";
import type { LocalizeFunc } from "../../common/translations/localize";
import { fireEvent } from "../../common/dom/fire_event";
import { createCloseHeading } from "../../components/ha-dialog";
import type { HomeAssistant } from "../../types";
import "../../components/ha-wa-dialog";
@customElement("app-dialog")
class DialogApp extends LitElement {
@property({ attribute: false }) public hass!: HomeAssistant;
@property({ attribute: false }) public localize?: LocalizeFunc;
public async showDialog(params): Promise<void> {
@state() private _open = false;
public async showDialog(params: {
localize: LocalizeFunc;
hass: HomeAssistant;
}): Promise<void> {
this.hass = params.hass;
this.localize = params.localize;
this._open = true;
}
public async closeDialog(): Promise<void> {
public closeDialog(): void {
this._open = false;
}
private _dialogClosed(): void {
this.localize = undefined;
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
@@ -21,15 +35,14 @@ class DialogApp extends LitElement {
if (!this.localize) {
return nothing;
}
return html`<ha-dialog
open
hideActions
@closed=${this.closeDialog}
.heading=${createCloseHeading(
undefined,
this.localize("ui.panel.page-onboarding.welcome.download_app") ||
"Click here to download the app"
)}
return html`<ha-wa-dialog
.hass=${this.hass}
.open=${this._open}
width="medium"
header-title=${this.localize(
"ui.panel.page-onboarding.welcome.download_app"
) || "Click here to download the app"}
@closed=${this._dialogClosed}
>
<div>
<div class="app-qr">
@@ -69,13 +82,10 @@ class DialogApp extends LitElement {
</a>
</div>
</div>
</ha-dialog>`;
</ha-wa-dialog>`;
}
static styles = css`
ha-dialog {
--mdc-dialog-min-width: min(500px, 90vw);
}
.app-qr {
display: flex;
justify-content: space-between;

View File

@@ -1,9 +1,9 @@
import { mdiOpenInNew } from "@mdi/js";
import { LitElement, css, html, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import { customElement, property, state } from "lit/decorators";
import { fireEvent } from "../../common/dom/fire_event";
import type { LocalizeFunc } from "../../common/translations/localize";
import { createCloseHeading } from "../../components/ha-dialog";
import "../../components/ha-wa-dialog";
import "../../components/ha-list";
import "../../components/ha-list-item";
@@ -11,11 +11,18 @@ import "../../components/ha-list-item";
class DialogCommunity extends LitElement {
@property({ attribute: false }) public localize?: LocalizeFunc;
@state() private _open = false;
public async showDialog(params): Promise<void> {
this.localize = params.localize;
this._open = true;
}
public async closeDialog(): Promise<void> {
public closeDialog(): void {
this._open = false;
}
private _dialogClosed(): void {
this.localize = undefined;
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
@@ -24,14 +31,13 @@ class DialogCommunity extends LitElement {
if (!this.localize) {
return nothing;
}
return html`<ha-dialog
open
hideActions
@closed=${this.closeDialog}
.heading=${createCloseHeading(
undefined,
this.localize("ui.panel.page-onboarding.welcome.community")
return html`<ha-wa-dialog
.open=${this._open}
width="small"
header-title=${this.localize(
"ui.panel.page-onboarding.welcome.community"
)}
@closed=${this._dialogClosed}
>
<ha-list>
<a
@@ -97,12 +103,11 @@ class DialogCommunity extends LitElement {
</ha-list-item>
</a>
</ha-list>
</ha-dialog>`;
</ha-wa-dialog>`;
}
static styles = css`
ha-dialog {
--mdc-dialog-min-width: min(400px, 90vw);
ha-wa-dialog {
--dialog-content-padding: 0;
}
ha-list-item {

View File

@@ -1,11 +1,12 @@
import { fireEvent } from "../../common/dom/fire_event";
import type { LocalizeFunc } from "../../common/translations/localize";
import type { HomeAssistant } from "../../types";
export const loadAppDialog = () => import("./app-dialog");
export const showAppDialog = (
element: HTMLElement,
params: { localize: LocalizeFunc }
params: { localize: LocalizeFunc; hass: HomeAssistant }
): void => {
fireEvent(element, "show-dialog", {
dialogTag: "app-dialog",

View File

@@ -60,7 +60,7 @@ class OnboardingWelcomeLinks extends LitElement {
}
private _openApp(): void {
showAppDialog(this, { localize: this.localize });
showAppDialog(this, { localize: this.localize, hass: this.hass });
}
static styles = css`

View File

@@ -8,7 +8,7 @@ import { computeStateDomain } from "../../../../common/entity/compute_state_doma
import { computeStateName } from "../../../../common/entity/compute_state_name";
import { supportsFeature } from "../../../../common/entity/supports-feature";
import "../../../../components/ha-button";
import "../../../../components/ha-dialog-footer";
import { createCloseHeading } from "../../../../components/ha-dialog";
import "../../../../components/ha-select";
import type {
HaSelectOption,
@@ -16,7 +16,6 @@ import type {
} from "../../../../components/ha-select";
import "../../../../components/ha-textarea";
import type { HaTextArea } from "../../../../components/ha-textarea";
import "../../../../components/ha-wa-dialog";
import { showAutomationEditor } from "../../../../data/automation";
import { MediaPlayerEntityFeature } from "../../../../data/media-player";
import { convertTextToSpeech } from "../../../../data/tts";
@@ -31,8 +30,6 @@ export class DialogTryTts extends LitElement {
@state() private _loadingExample = false;
@state() private _open = false;
@state() private _params?: TryTtsDialogParams;
@query("#message") private _messageInput?: HaTextArea;
@@ -53,14 +50,9 @@ export class DialogTryTts extends LitElement {
public showDialog(params: TryTtsDialogParams) {
this._params = params;
this._open = true;
}
public closeDialog() {
this._open = false;
}
private _dialogClosed() {
this._params = undefined;
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
@@ -90,20 +82,20 @@ export class DialogTryTts extends LitElement {
});
return html`
<ha-wa-dialog
.hass=${this.hass}
.open=${this._open}
header-title=${this.hass.localize(
"ui.panel.config.cloud.account.tts.dialog.header"
<ha-dialog
open
@closed=${this.closeDialog}
scrimClickAction
escapeKeyAction
.heading=${createCloseHeading(
this.hass,
this.hass.localize("ui.panel.config.cloud.account.tts.dialog.header")
)}
width="medium"
@closed=${this._dialogClosed}
>
<div>
<ha-textarea
autogrow
id="message"
autofocus
.label=${this.hass.localize(
"ui.panel.config.cloud.account.tts.dialog.message"
)}
@@ -126,33 +118,26 @@ export class DialogTryTts extends LitElement {
>
</ha-select>
</div>
<ha-dialog-footer slot="footer">
<ha-button
appearance="plain"
slot="secondaryAction"
.disabled=${target === "browser"}
@click=${this._createAutomation}
>
<ha-svg-icon slot="start" .path=${mdiRobot}></ha-svg-icon>
${this.hass.localize(
"ui.panel.config.cloud.account.tts.dialog.create_automation"
)}
</ha-button>
<ha-button
slot="primaryAction"
@click=${this._playExample}
.disabled=${this._loadingExample}
>
<ha-svg-icon
slot="start"
.path=${mdiPlayCircleOutline}
></ha-svg-icon>
${this.hass.localize(
"ui.panel.config.cloud.account.tts.dialog.play"
)}
</ha-button>
</ha-dialog-footer>
</ha-wa-dialog>
<ha-button
slot="primaryAction"
@click=${this._playExample}
.disabled=${this._loadingExample}
>
<ha-svg-icon slot="start" .path=${mdiPlayCircleOutline}></ha-svg-icon>
${this.hass.localize("ui.panel.config.cloud.account.tts.dialog.play")}
</ha-button>
<ha-button
appearance="plain"
slot="secondaryAction"
.disabled=${target === "browser"}
@click=${this._createAutomation}
>
<ha-svg-icon slot="start" .path=${mdiRobot}></ha-svg-icon>
${this.hass.localize(
"ui.panel.config.cloud.account.tts.dialog.create_automation"
)}
</ha-button>
</ha-dialog>
`;
}
@@ -238,6 +223,9 @@ export class DialogTryTts extends LitElement {
return [
haStyleDialog,
css`
ha-dialog {
--mdc-dialog-max-width: 500px;
}
ha-textarea,
ha-select {
display: block;

View File

@@ -6,9 +6,8 @@ import { formatDateTime } from "../../../../common/datetime/format_date_time";
import { fireEvent } from "../../../../common/dom/fire_event";
import "../../../../components/ha-alert";
import "../../../../components/ha-button";
import "../../../../components/ha-dialog-footer";
import { createCloseHeading } from "../../../../components/ha-dialog";
import "../../../../components/ha-icon-button";
import "../../../../components/ha-wa-dialog";
import { haStyleDialog } from "../../../../resources/styles";
import type { HomeAssistant } from "../../../../types";
import { obfuscateUrl } from "../../../../util/url";
@@ -20,21 +19,13 @@ class DialogCloudAlreadyConnected extends LitElement {
@state() private _params?: CloudAlreadyConnectedDialogParams;
@state() private _open = false;
@state() private _obfuscateIp = true;
public showDialog(params: CloudAlreadyConnectedDialogParams) {
this._params = params;
this._open = true;
}
public closeDialog() {
this._open = false;
}
private _dialogClosed() {
this._open = false;
this._params?.closeDialog?.();
this._params = undefined;
this._obfuscateIp = true;
@@ -48,14 +39,15 @@ class DialogCloudAlreadyConnected extends LitElement {
const { details } = this._params;
return html`
<ha-wa-dialog
.hass=${this.hass}
.open=${this._open}
header-title=${this.hass.localize(
"ui.panel.config.cloud.dialog_already_connected.heading"
<ha-dialog
open
@closed=${this.closeDialog}
.heading=${createCloseHeading(
this.hass,
this.hass.localize(
"ui.panel.config.cloud.dialog_already_connected.heading"
)
)}
@closed=${this._dialogClosed}
width="medium"
>
<div class="intro">
<span>
@@ -139,21 +131,19 @@ class DialogCloudAlreadyConnected extends LitElement {
)}
</ha-alert>
<ha-dialog-footer slot="footer">
<ha-button
slot="secondaryAction"
appearance="plain"
@click=${this.closeDialog}
>
${this.hass!.localize("ui.common.cancel")}
</ha-button>
<ha-button slot="primaryAction" @click=${this._logInHere}>
${this.hass!.localize(
"ui.panel.config.cloud.dialog_already_connected.login_here"
)}
</ha-button>
</ha-dialog-footer>
</ha-wa-dialog>
<ha-button
appearance="plain"
@click=${this.closeDialog}
slot="secondaryAction"
>
${this.hass!.localize("ui.common.cancel")}
</ha-button>
<ha-button @click=${this._logInHere} slot="primaryAction">
${this.hass!.localize(
"ui.panel.config.cloud.dialog_already_connected.login_here"
)}
</ha-button>
</ha-dialog>
`;
}
@@ -170,6 +160,9 @@ class DialogCloudAlreadyConnected extends LitElement {
return [
haStyleDialog,
css`
ha-dialog {
--mdc-dialog-max-width: 535px;
}
.intro b {
display: block;
margin-top: 16px;

View File

@@ -3,11 +3,10 @@ import { css, html, LitElement, nothing } from "lit";
import { customElement, state } from "lit/decorators";
import { formatDateTime } from "../../../../common/datetime/format_date_time";
import { fireEvent } from "../../../../common/dom/fire_event";
import "../../../../components/ha-dialog-footer";
import { createCloseHeading } from "../../../../components/ha-dialog";
import { haStyleDialog } from "../../../../resources/styles";
import type { HomeAssistant } from "../../../../types";
import "../../../../components/ha-button";
import "../../../../components/ha-wa-dialog";
import type { CloudCertificateParams as CloudCertificateDialogParams } from "./show-dialog-cloud-certificate";
@customElement("dialog-cloud-certificate")
@@ -16,19 +15,11 @@ class DialogCloudCertificate extends LitElement {
@state() private _params?: CloudCertificateDialogParams;
@state() private _open = false;
public showDialog(params: CloudCertificateDialogParams) {
this._params = params;
this._open = true;
}
public closeDialog() {
this._open = false;
}
private _dialogClosed() {
this._open = false;
this._params = undefined;
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
@@ -40,14 +31,16 @@ class DialogCloudCertificate extends LitElement {
const { certificateInfo } = this._params;
return html`
<ha-wa-dialog
.hass=${this.hass}
.open=${this._open}
header-title=${this.hass.localize(
"ui.panel.config.cloud.dialog_certificate.certificate_information"
<ha-dialog
open
hideActions
@closed=${this.closeDialog}
.heading=${createCloseHeading(
this.hass,
this.hass.localize(
"ui.panel.config.cloud.dialog_certificate.certificate_information"
)
)}
@closed=${this._dialogClosed}
width="medium"
>
<div>
<p>
@@ -81,14 +74,12 @@ class DialogCloudCertificate extends LitElement {
</ul>
</div>
<ha-dialog-footer slot="footer">
<ha-button slot="primaryAction" @click=${this.closeDialog}>
${this.hass!.localize(
"ui.panel.config.cloud.dialog_certificate.close"
)}
</ha-button>
</ha-dialog-footer>
</ha-wa-dialog>
<ha-button @click=${this.closeDialog} slot="primaryAction">
${this.hass!.localize(
"ui.panel.config.cloud.dialog_certificate.close"
)}
</ha-button>
</ha-dialog>
`;
}
@@ -96,6 +87,9 @@ class DialogCloudCertificate extends LitElement {
return [
haStyleDialog,
css`
ha-dialog {
--mdc-dialog-max-width: 535px;
}
.break-word {
overflow-wrap: break-word;
}

View File

@@ -3,7 +3,7 @@ import type { CSSResultGroup } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, state } from "lit/decorators";
import { fireEvent } from "../../../../common/dom/fire_event";
import "../../../../components/ha-dialog-footer";
import { createCloseHeading } from "../../../../components/ha-dialog";
import { showConfirmationDialog } from "../../../../dialogs/generic/show-dialog-box";
import { haStyle, haStyleDialog } from "../../../../resources/styles";
import type { HomeAssistant } from "../../../../types";
@@ -12,7 +12,6 @@ import type { WebhookDialogParams } from "./show-dialog-manage-cloudhook";
import "../../../../components/ha-button";
import "../../../../components/ha-copy-textfield";
import "../../../../components/ha-wa-dialog";
@customElement("dialog-manage-cloudhook")
export class DialogManageCloudhook extends LitElement {
@@ -20,19 +19,11 @@ export class DialogManageCloudhook extends LitElement {
@state() private _params?: WebhookDialogParams;
@state() private _open = false;
public showDialog(params: WebhookDialogParams) {
this._params = params;
this._open = true;
}
public closeDialog() {
this._open = false;
}
private _dialogClosed() {
this._open = false;
this._params = undefined;
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
@@ -50,15 +41,17 @@ export class DialogManageCloudhook extends LitElement {
)
: documentationUrl(this.hass!, `/integrations/${webhook.domain}/`);
return html`
<ha-wa-dialog
.hass=${this.hass}
.open=${this._open}
header-title=${this.hass!.localize(
"ui.panel.config.cloud.dialog_cloudhook.webhook_for",
{ name: webhook.name }
<ha-dialog
open
hideActions
@closed=${this.closeDialog}
.heading=${createCloseHeading(
this.hass!,
this.hass!.localize(
"ui.panel.config.cloud.dialog_cloudhook.webhook_for",
{ name: webhook.name }
)
)}
@closed=${this._dialogClosed}
width="large"
>
<div>
<p>
@@ -94,25 +87,21 @@ export class DialogManageCloudhook extends LitElement {
></ha-copy-textfield>
</div>
<ha-dialog-footer slot="footer">
<ha-button
slot="secondaryAction"
href=${docsUrl}
target="_blank"
rel="noreferrer"
appearance="plain"
>
${this.hass!.localize(
"ui.panel.config.cloud.dialog_cloudhook.view_documentation"
)}
</ha-button>
<ha-button slot="primaryAction" @click=${this.closeDialog}>
${this.hass!.localize(
"ui.panel.config.cloud.dialog_cloudhook.close"
)}
</ha-button>
</ha-dialog-footer>
</ha-wa-dialog>
<ha-button
href=${docsUrl}
target="_blank"
rel="noreferrer"
slot="secondaryAction"
appearance="plain"
>
${this.hass!.localize(
"ui.panel.config.cloud.dialog_cloudhook.view_documentation"
)}
</ha-button>
<ha-button @click=${this.closeDialog} slot="primaryAction">
${this.hass!.localize("ui.panel.config.cloud.dialog_cloudhook.close")}
</ha-button>
</ha-dialog>
`;
}
@@ -140,6 +129,9 @@ export class DialogManageCloudhook extends LitElement {
haStyle,
haStyleDialog,
css`
ha-dialog {
width: 650px;
}
button.link {
color: var(--primary-color);
text-decoration: none;