diff --git a/src/auth/ha-authorize.ts b/src/auth/ha-authorize.ts index 67313d4ffa..9778edfc0a 100644 --- a/src/auth/ha-authorize.ts +++ b/src/auth/ha-authorize.ts @@ -35,6 +35,8 @@ export class HaAuthorize extends litLocalizeLiteMixin(LitElement) { @property() public oauth2State?: string; + @property() public translationFragment = "page-authorize"; + @state() private _authProvider?: AuthProvider; @state() private _authProviders?: AuthProvider[]; @@ -45,7 +47,6 @@ export class HaAuthorize extends litLocalizeLiteMixin(LitElement) { constructor() { super(); - this.translationFragment = "page-authorize"; const query = extractSearchParamsObject() as AuthUrlSearchParams; if (query.client_id) { this.clientId = query.client_id; @@ -102,7 +103,6 @@ export class HaAuthorize extends litLocalizeLiteMixin(LitElement) { : nothing} >( // Initialized to empty will prevent undefined errors if called before connected to DOM. @property() public localize: LocalizeFunc = empty; - @property() public resources?: Resources; - // Use browser language setup before login. @property() public language?: string = getLocalLanguage(); @property() public translationFragment?: string; + @state() private _resources?: Resources; + public connectedCallback(): void { super.connectedCallback(); this._initializeLocalizeLite(); @@ -35,22 +35,27 @@ export const litLocalizeLiteMixin = >( ); } - protected updated(changedProperties: PropertyValues) { - super.updated(changedProperties); + protected willUpdate(changedProperties: PropertyValues) { + super.willUpdate(changedProperties); + if (changedProperties.get("language")) { + this._resources = undefined; + this._initializeLocalizeLite(); + } + if (changedProperties.get("translationFragment")) { this._initializeLocalizeLite(); } if ( this.language && - this.resources && + this._resources && (changedProperties.has("language") || - changedProperties.has("resources")) + changedProperties.has("_resources")) ) { computeLocalize( this.constructor.prototype, this.language, - this.resources + this._resources ).then((localize) => { this.localize = localize; }); @@ -58,7 +63,7 @@ export const litLocalizeLiteMixin = >( } protected async _initializeLocalizeLite() { - if (this.resources) { + if (this._resources) { return; } @@ -68,7 +73,7 @@ export const litLocalizeLiteMixin = >( if (__DEV__) { setTimeout( () => - !this.resources && + !this._resources && // eslint-disable-next-line console.error( "Forgot to pass in resources or set translationFragment for", @@ -84,7 +89,7 @@ export const litLocalizeLiteMixin = >( this.translationFragment!, this.language! ); - this.resources = { + this._resources = { [this.language!]: data, }; } diff --git a/src/onboarding/ha-onboarding.ts b/src/onboarding/ha-onboarding.ts index f08917aaa4..5a2872f9fb 100644 --- a/src/onboarding/ha-onboarding.ts +++ b/src/onboarding/ha-onboarding.ts @@ -5,7 +5,7 @@ import { getAuth, subscribeConfig, } from "home-assistant-js-websocket"; -import { html, PropertyValues, nothing } from "lit"; +import { html, PropertyValues, nothing, css } from "lit"; import { customElement, property, state } from "lit/decorators"; import { applyThemesOnElement } from "../common/dom/apply_themes_on_element"; import { HASSDomEvent } from "../common/dom/fire_event"; @@ -27,6 +27,9 @@ import { registerServiceWorker } from "../util/register-service-worker"; import "./onboarding-analytics"; import "./onboarding-create-user"; import "./onboarding-loading"; +import "../components/ha-language-picker"; +import "../components/ha-card"; +import { storeState } from "../util/ha-pref-storage"; import { enableWrite, loadTokens, @@ -74,6 +77,21 @@ class HaOnboarding extends litLocalizeLiteMixin(HassElement) { @state() private _steps?: OnboardingStep[]; protected render() { + return html` +
${this._renderStep()}
+
+ ${this.hass + ? html`` + : nothing} `; + } + + private _renderStep() { const step = this._curStep()!; if (this._loading || !step) { @@ -114,7 +132,6 @@ class HaOnboarding extends litLocalizeLiteMixin(HassElement) { > `; } - if (step.step === "integration") { return html`