Skip to content

Commit

Permalink
20231130.0 (#18843)
Browse files Browse the repository at this point in the history
  • Loading branch information
bramkragten authored Nov 30, 2023
2 parents ef735d6 + 72caf72 commit b854d23
Show file tree
Hide file tree
Showing 36 changed files with 346 additions and 293 deletions.
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
"dependencies": {
"@babel/runtime": "7.23.4",
"@braintree/sanitize-url": "6.0.4",
"@codemirror/autocomplete": "6.11.0",
"@codemirror/commands": "6.3.0",
"@codemirror/language": "6.9.2",
"@codemirror/autocomplete": "6.11.1",
"@codemirror/commands": "6.3.1",
"@codemirror/language": "6.9.3",
"@codemirror/legacy-modes": "6.3.3",
"@codemirror/search": "6.5.4",
"@codemirror/state": "6.3.1",
"@codemirror/view": "6.22.0",
"@codemirror/search": "6.5.5",
"@codemirror/state": "6.3.2",
"@codemirror/view": "6.22.1",
"@egjs/hammerjs": "2.0.17",
"@formatjs/intl-datetimeformat": "6.12.0",
"@formatjs/intl-displaynames": "6.6.4",
Expand Down Expand Up @@ -91,8 +91,8 @@
"@polymer/paper-toast": "3.0.1",
"@polymer/polymer": "3.5.1",
"@thomasloven/round-slider": "0.6.0",
"@vaadin/combo-box": "24.2.3",
"@vaadin/vaadin-themable-mixin": "24.2.3",
"@vaadin/combo-box": "24.2.4",
"@vaadin/vaadin-themable-mixin": "24.2.4",
"@vibrant/color": "3.2.1-alpha.1",
"@vibrant/core": "3.2.1-alpha.1",
"@vibrant/quantizer-mmcq": "3.2.1-alpha.1",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "home-assistant-frontend"
version = "20231129.1"
version = "20231130.0"
license = {text = "Apache-2.0"}
description = "The Home Assistant frontend"
readme = "README.md"
Expand Down
28 changes: 21 additions & 7 deletions src/auth/ha-auth-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
DataEntryFlowStepForm,
} from "../data/data_entry_flow";
import "./ha-auth-form";
import { fireEvent } from "../common/dom/fire_event";

type State = "loading" | "error" | "step";

Expand Down Expand Up @@ -85,10 +86,6 @@ export class HaAuthFlow extends LitElement {
protected render() {
return html`
<style>
ha-auth-flow .action {
margin: 24px 0 8px;
text-align: center;
}
ha-auth-flow .store-token {
margin-left: -16px;
}
Expand Down Expand Up @@ -158,14 +155,25 @@ export class HaAuthFlow extends LitElement {
}

private _renderForm() {
const showBack =
this.step?.type === "form" &&
this.authProvider?.users &&
!["select_mfa_module", "mfa"].includes(this.step.step_id);

switch (this._state) {
case "step":
if (this.step == null) {
return nothing;
}

return html`
${this._renderStep(this.step)}
<div class="action">
<div class="action ${showBack ? "space-between" : ""}">
${showBack
? html`<mwc-button @click=${this._localFlow}>
${this.localize("ui.panel.page-authorize.form.previous")}
</mwc-button>`
: nothing}
<mwc-button
raised
@click=${this._handleSubmit}
Expand Down Expand Up @@ -294,7 +302,8 @@ export class HaAuthFlow extends LitElement {
redirectWithAuthCode(
this.redirectUri!,
data.result,
this.oauth2State
this.oauth2State,
this.storeToken
);
return;
}
Expand Down Expand Up @@ -375,7 +384,8 @@ export class HaAuthFlow extends LitElement {
redirectWithAuthCode(
this.redirectUri!,
newStep.result,
this.oauth2State
this.oauth2State,
this.storeToken
);
return;
}
Expand All @@ -390,6 +400,10 @@ export class HaAuthFlow extends LitElement {
this._submitting = false;
}
}

private _localFlow() {
fireEvent(this, "default-login-flow", { value: false });
}
}

declare global {
Expand Down
20 changes: 16 additions & 4 deletions src/auth/ha-authorize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ export class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
position: relative;
padding: 16px;
}
.action {
margin: 16px 0 8px;
display: flex;
width: 100%;
max-width: 336px;
justify-content: center;
}
.space-between {
justify-content: space-between;
}
.footer {
padding-top: 8px;
display: flex;
Expand Down Expand Up @@ -164,7 +174,10 @@ export class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
</ha-alert>`
: nothing}
<div class="card-content">
<div
class="card-content"
@default-login-flow=${this._handleDefaultLoginFlow}
>
${!this._authProvider
? html`<p>
${this.localize("ui.panel.page-authorize.initializing")}
Expand All @@ -181,7 +194,6 @@ export class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
.authProviders=${this._authProviders}
.localize=${this.localize}
.ownInstance=${this._ownInstance}
@default-login-flow=${this._handleDefaultLoginFlow}
></ha-local-auth-flow>`
: html`<ha-auth-flow
.clientId=${this.clientId}
Expand Down Expand Up @@ -315,8 +327,8 @@ export class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
}
}

private _handleDefaultLoginFlow() {
this._forceDefaultLogin = true;
private _handleDefaultLoginFlow(ev) {
this._forceDefaultLogin = ev.detail.value;
}

private async _handleAuthProviderPick(ev) {
Expand Down
43 changes: 22 additions & 21 deletions src/auth/ha-local-auth-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
submitLoginFlow,
} from "../data/auth";
import { DataEntryFlowStep } from "../data/data_entry_flow";
import { listPersons } from "../data/person";
import { BasePerson, listUserPersons } from "../data/person";
import "./ha-auth-textfield";
import type { HaAuthTextField } from "./ha-auth-textfield";

Expand All @@ -43,7 +43,7 @@ export class HaLocalAuthFlow extends LitElement {

@state() private _submitting = false;

@state() private _persons?: Promise<Record<string, string>>;
@state() private _persons?: Record<string, BasePerson>;

@state() private _selectedUser?: string;

Expand All @@ -65,7 +65,9 @@ export class HaLocalAuthFlow extends LitElement {
if (!this.authProvider?.users || !this._persons) {
return nothing;
}
const userIds = Object.keys(this.authProvider.users);
const userIds = Object.keys(this.authProvider.users).filter(
(userId) => userId in this._persons!
);
return html`
<style>
.content {
Expand Down Expand Up @@ -146,16 +148,6 @@ export class HaLocalAuthFlow extends LitElement {
height: 120px;
--person-badge-font-size: 3em;
}
.action {
margin: 16px 0 8px;
display: flex;
width: 100%;
max-width: 336px;
justify-content: center;
}
.space-between {
justify-content: space-between;
}
ha-list-item {
margin-top: 16px;
}
Expand Down Expand Up @@ -198,9 +190,9 @@ export class HaLocalAuthFlow extends LitElement {
: this._selectedUser
? html`<div class="login-form"><div class="person">
<ha-person-badge
.person=${this._persons![this._selectedUser]}
.person=${this._persons[this._selectedUser]}
></ha-person-badge>
<p>${this._persons![this._selectedUser].name}</p>
<p>${this._persons[this._selectedUser].name}</p>
</div>
<form>
<input
Expand Down Expand Up @@ -273,6 +265,7 @@ export class HaLocalAuthFlow extends LitElement {
>
${userIds.map((userId) => {
const person = this._persons![userId];
return html`<div
class="person"
.userId=${userId}
Expand Down Expand Up @@ -316,7 +309,12 @@ export class HaLocalAuthFlow extends LitElement {
}

private async _load() {
this._persons = await (await listPersons()).json();
try {
this._persons = await listUserPersons();
} catch {
this._persons = {};
this._error = "Failed to fetch persons";
}
}

private _restart() {
Expand Down Expand Up @@ -353,7 +351,8 @@ export class HaLocalAuthFlow extends LitElement {
redirectWithAuthCode(
this.redirectUri!,
data.result,
this.oauth2State
this.oauth2State,
true
);
return;
}
Expand All @@ -374,7 +373,8 @@ export class HaLocalAuthFlow extends LitElement {
redirectWithAuthCode(
this.redirectUri!,
result.result,
this.oauth2State
this.oauth2State,
true
);
return;
}
Expand Down Expand Up @@ -433,7 +433,8 @@ export class HaLocalAuthFlow extends LitElement {
redirectWithAuthCode(
this.redirectUri!,
newStep.result,
this.oauth2State
this.oauth2State,
true
);
return;
}
Expand Down Expand Up @@ -462,7 +463,7 @@ export class HaLocalAuthFlow extends LitElement {
}

private _otherLogin() {
fireEvent(this, "default-login-flow");
fireEvent(this, "default-login-flow", { value: true });
}
}

Expand All @@ -471,6 +472,6 @@ declare global {
"ha-local-auth-flow": HaLocalAuthFlow;
}
interface HASSDomEvents {
"default-login-flow": undefined;
"default-login-flow": { value: boolean };
}
}
5 changes: 5 additions & 0 deletions src/components/chart/state-history-charts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ export class StateHistoryCharts extends LitElement {
padding-right: 1px;
}
.entry-container:not(:first-child) {
border-top: 2px solid var(--divider-color);
margin-top: 16px;
}
.container,
lit-virtualizer {
height: 100%;
Expand Down
5 changes: 4 additions & 1 deletion src/components/ha-faded.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class HaFaded extends LitElement {
@click=${this._showContent}
>
<slot
@iron-resize=${
@content-resize=${
// ha-markdown-element fire this when render is complete
this._setShowContent
}
Expand Down Expand Up @@ -79,4 +79,7 @@ declare global {
interface HTMLElementTagNameMap {
"ha-faded": HaFaded;
}
interface HASSDomEvents {
"content-resize": undefined;
}
}
2 changes: 1 addition & 1 deletion src/components/ha-markdown-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class HaMarkdownElement extends ReactiveElement {
}
}

private _resize = () => fireEvent(this, "iron-resize");
private _resize = () => fireEvent(this, "content-resize");
}

declare global {
Expand Down
7 changes: 4 additions & 3 deletions src/components/map/ha-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class HaMap extends ReactiveElement {
autoFitRequired = true;
}

if (this.autoFit && autoFitRequired) {
if (changedProps.has("_loaded") || (this.autoFit && autoFitRequired)) {
this.fitMap();
}

Expand All @@ -155,10 +155,11 @@ export class HaMap extends ReactiveElement {
}

private _updateMapStyle(): void {
const darkMode = this.darkMode ?? this.hass.themes.darkMode;
const darkMode = this.darkMode ?? this.hass.themes.darkMode ?? false;
const forcedDark = this.darkMode ?? false;
const map = this.shadowRoot!.getElementById("map");
map!.classList.toggle("dark", darkMode);
map!.classList.toggle("forced-dark", this.darkMode);
map!.classList.toggle("forced-dark", forcedDark);
}

private async _loadMap(): Promise<void> {
Expand Down
4 changes: 2 additions & 2 deletions src/components/user/ha-person-badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import { classMap } from "lit/directives/class-map";
import { styleMap } from "lit/directives/style-map";
import { Person } from "../../data/person";
import { BasePerson } from "../../data/person";
import { computeUserInitials } from "../../data/user";

@customElement("ha-person-badge")
class PersonBadge extends LitElement {
@property({ attribute: false }) public person?: Person;
@property({ attribute: false }) public person?: BasePerson;

protected render() {
if (!this.person) {
Expand Down
4 changes: 2 additions & 2 deletions src/data/area_registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ export const areaCompare =
const indexA = order ? order.indexOf(a) : -1;
const indexB = order ? order.indexOf(b) : 1;
if (indexA === -1 && indexB === -1) {
const nameA = entries?.[a].name ?? a;
const nameB = entries?.[b].name ?? b;
const nameA = entries?.[a]?.name ?? a;
const nameB = entries?.[b]?.name ?? b;
return stringCompare(nameA, nameB);
}
if (indexA === -1) {
Expand Down
7 changes: 5 additions & 2 deletions src/data/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ export const deleteLoginFlow = (flow_id) =>
export const redirectWithAuthCode = (
url: string,
authCode: string,
oauth2State: string | undefined
oauth2State: string | undefined,
storeToken: boolean
) => {
// OAuth 2: 3.1.2 we need to retain query component of a redirect URI
if (!url.includes("?")) {
Expand All @@ -94,7 +95,9 @@ export const redirectWithAuthCode = (
if (oauth2State) {
url += `&state=${encodeURIComponent(oauth2State)}`;
}
url += `&storeToken=true`;
if (storeToken) {
url += `&storeToken=true`;
}

document.location.assign(url);
};
Expand Down
Loading

0 comments on commit b854d23

Please sign in to comment.