From e8f1a860055db1e5ace62abe2ecf65df68d907fb Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Thu, 24 Aug 2023 12:08:34 +0200 Subject: [PATCH] Remove name and core config steps from onboarding (#17670) --- src/onboarding/onboarding-core-config.ts | 35 ++++--- src/onboarding/onboarding-name.ts | 111 ----------------------- src/translations/en.json | 4 +- 3 files changed, 21 insertions(+), 129 deletions(-) delete mode 100644 src/onboarding/onboarding-name.ts diff --git a/src/onboarding/onboarding-core-config.ts b/src/onboarding/onboarding-core-config.ts index 3ea32cd556..67ca87b9a9 100644 --- a/src/onboarding/onboarding-core-config.ts +++ b/src/onboarding/onboarding-core-config.ts @@ -28,7 +28,6 @@ import { onboardCoreConfigStep } from "../data/onboarding"; import type { HomeAssistant, ValueChangedEvent } from "../types"; import { getLocalLanguage } from "../util/common-translation"; import "./onboarding-location"; -import "./onboarding-name"; @customElement("onboarding-core-config") class OnboardingCoreConfig extends LitElement { @@ -38,8 +37,6 @@ class OnboardingCoreConfig extends LitElement { @state() private _working = false; - @state() private _name?: ConfigUpdateValues["location_name"]; - @state() private _location?: [number, number]; @state() private _elevation?: string; @@ -56,14 +53,9 @@ class OnboardingCoreConfig extends LitElement { @state() private _error?: string; + @state() private _skipCore = false; + protected render(): TemplateResult { - if (!this._name) { - return html``; - } if (!this._location) { return html``; } + if (this._skipCore) { + return html`
+ +
`; + } return html` ${ this._error @@ -289,10 +286,6 @@ class OnboardingCoreConfig extends LitElement { this[`_${target.name}`] = target.value; } - private _nameChanged(ev: CustomEvent) { - this._name = ev.detail.value; - } - private async _locationChanged(ev) { this._location = ev.detail.value.location; this._country = ev.detail.value.country; @@ -303,6 +296,11 @@ class OnboardingCoreConfig extends LitElement { ev.detail.value.timezone || Intl.DateTimeFormat?.().resolvedOptions?.().timeZone; this._unitSystem = ev.detail.value.unit_system; + if (this._country) { + this._skipCore = true; + this._save(ev); + return; + } await this.updateComplete; setTimeout( () => this.renderRoot.querySelector("ha-textfield")!.focus(), @@ -324,7 +322,9 @@ class OnboardingCoreConfig extends LitElement { this._working = true; try { await saveCoreConfig(this.hass, { - location_name: this._name, + location_name: this.onboardingLocalize( + "ui.panel.page-onboarding.core-config.location_name_default" + ), latitude: this._location[0], longitude: this._location[1], elevation: Number(this._elevationValue), @@ -340,6 +340,7 @@ class OnboardingCoreConfig extends LitElement { result, }); } catch (err: any) { + this._skipCore = false; this._working = false; this._error = err.message; } @@ -380,6 +381,10 @@ class OnboardingCoreConfig extends LitElement { margin-top: 16px; } + .center { + justify-content: center; + } + .row > * { margin: 0 8px; } diff --git a/src/onboarding/onboarding-name.ts b/src/onboarding/onboarding-name.ts deleted file mode 100644 index 6d8d023137..0000000000 --- a/src/onboarding/onboarding-name.ts +++ /dev/null @@ -1,111 +0,0 @@ -import "@material/mwc-button/mwc-button"; -import { CSSResultGroup, LitElement, TemplateResult, css, html } from "lit"; -import { customElement, property } from "lit/decorators"; -import { fireEvent } from "../common/dom/fire_event"; -import type { LocalizeFunc } from "../common/translations/localize"; -import "../components/ha-alert"; -import "../components/ha-formfield"; -import "../components/ha-radio"; -import "../components/ha-textfield"; -import "../components/map/ha-locations-editor"; -import { ConfigUpdateValues } from "../data/core"; -import type { HomeAssistant } from "../types"; - -@customElement("onboarding-name") -class OnboardingName extends LitElement { - @property({ attribute: false }) public hass!: HomeAssistant; - - @property() public onboardingLocalize!: LocalizeFunc; - - private _name?: ConfigUpdateValues["location_name"]; - - protected render(): TemplateResult { - return html` -

- ${this.onboardingLocalize( - "ui.panel.page-onboarding.core-config.intro", - { name: this.hass.user!.name } - )} -

- - - -

- ${this.onboardingLocalize( - "ui.panel.page-onboarding.core-config.intro_core" - )} -

- - - `; - } - - protected firstUpdated(changedProps) { - super.firstUpdated(changedProps); - setTimeout( - () => this.renderRoot.querySelector("ha-textfield")!.focus(), - 100 - ); - this.addEventListener("keyup", (ev) => { - if (ev.key === "Enter") { - this._save(ev); - } - }); - } - - private get _nameValue() { - return this._name !== undefined - ? this._name - : this.onboardingLocalize( - "ui.panel.page-onboarding.core-config.location_name_default" - ); - } - - private _nameChanged(ev) { - this._name = ev.target.value; - } - - private async _save(ev) { - ev.preventDefault(); - fireEvent(this, "value-changed", { - value: this._nameValue, - }); - } - - static get styles(): CSSResultGroup { - return css` - ha-textfield { - display: block; - } - p { - font-size: 14px; - line-height: 20px; - } - .footer { - margin-top: 16px; - text-align: right; - } - a { - color: var(--primary-color); - } - `; - } -} - -declare global { - interface HTMLElementTagNameMap { - "onboarding-name": OnboardingName; - } -} diff --git a/src/translations/en.json b/src/translations/en.json index 06edd1b452..40bf499eac 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -5702,9 +5702,7 @@ } }, "core-config": { - "intro": "Hello {name}, welcome to Home Assistant. How would you like to name your home?", - "intro_core": "We will set up the basics together. You can always change this later in the settings.", - "intro_location": "Let's set up the location of your home so that you can display information such as the local weather and use sun-based or presence-based automations. This data is never shared outside of your network.", + "intro_location": "Let's set up the location of your home so that you can display information such as the local weather and use sun-based or presence-based automations.", "location_address": "Powered by {openstreetmap} ({osm_privacy_policy}).", "osm_privacy_policy": "Privacy policy", "title_location_detect": "Do you want us to detect your location?",