Merge pull request #11462 from home-assistant/dev

This commit is contained in:
Paulus Schoutsen 2022-01-27 10:42:12 -08:00 committed by GitHub
commit 9fee7a2829
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 119 additions and 72 deletions

View File

@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup( setup(
name="home-assistant-frontend", name="home-assistant-frontend",
version="20220126.0", version="20220127.0",
description="The Home Assistant frontend", description="The Home Assistant frontend",
url="https://github.com/home-assistant/frontend", url="https://github.com/home-assistant/frontend",
author="The Home Assistant Authors", author="The Home Assistant Authors",

View File

@ -17,6 +17,7 @@ import {
import { Selector } from "../data/selector"; import { Selector } from "../data/selector";
import { PolymerChangedEvent } from "../polymer-types"; import { PolymerChangedEvent } from "../polymer-types";
import { HomeAssistant } from "../types"; import { HomeAssistant } from "../types";
import { documentationUrl } from "../util/documentation-url";
import "./ha-checkbox"; import "./ha-checkbox";
import "./ha-icon-button"; import "./ha-icon-button";
import "./ha-selector/ha-selector"; import "./ha-selector/ha-selector";
@ -230,7 +231,12 @@ export class HaServiceControl extends LitElement {
<p>${serviceData?.description}</p> <p>${serviceData?.description}</p>
${this._manifest ${this._manifest
? html` <a ? html` <a
href=${this._manifest.documentation} href=${this._manifest.is_built_in
? documentationUrl(
this.hass,
`/integrations/${this._manifest.domain}`
)
: this._manifest.documentation}
title=${this.hass.localize( title=${this.hass.localize(
"ui.components.service-control.integration_doc" "ui.components.service-control.integration_doc"
)} )}

View File

@ -255,8 +255,10 @@ export class HaMediaPlayerBrowse extends LitElement {
${child.thumbnail ${child.thumbnail
? html` ? html`
<div <div
class="${child.media_class === class="${[
"directory" "app",
"directory",
].includes(child.media_class)
? "centered-image" ? "centered-image"
: ""} image lazythumbnail" : ""} image lazythumbnail"
data-src=${child.thumbnail} data-src=${child.thumbnail}

View File

@ -104,18 +104,19 @@ export const localizeConfigFlowTitle = (
localize: LocalizeFunc, localize: LocalizeFunc,
flow: DataEntryFlowProgress flow: DataEntryFlowProgress
) => { ) => {
const placeholders = flow.context.title_placeholders || {}; if (
const placeholderKeys = Object.keys(placeholders); !flow.context.title_placeholders ||
if (placeholderKeys.length === 0) { Object.keys(flow.context.title_placeholders).length === 0
) {
return domainToName(localize, flow.handler); return domainToName(localize, flow.handler);
} }
const args: string[] = []; return (
placeholderKeys.forEach((key) => { localize(
args.push(key); `component.${flow.handler}.config.flow_title`,
args.push(placeholders[key]); flow.context.title_placeholders
}); ) ||
return localize(`component.${flow.handler}.config.flow_title`, ...args) || ("name" in flow.context.title_placeholders
"name" in placeholders ? flow.context.title_placeholders.name
? placeholders.name : domainToName(localize, flow.handler))
: domainToName(localize, flow.handler); );
}; };

View File

@ -108,7 +108,9 @@ export class QuickBar extends LitElement {
public async showDialog(params: QuickBarParams) { public async showDialog(params: QuickBarParams) {
this._commandMode = params.commandMode || this._toggleIfAlreadyOpened(); this._commandMode = params.commandMode || this._toggleIfAlreadyOpened();
this._hint = params.hint; this._hint = params.hint;
this._narrow = matchMedia("(max-width: 600px)").matches; this._narrow = matchMedia(
"all and (max-width: 450px), all and (max-height: 500px)"
).matches;
this._initializeItemsIfNeeded(); this._initializeItemsIfNeeded();
this._opened = true; this._opened = true;
} }
@ -154,7 +156,7 @@ export class QuickBar extends LitElement {
)} )}
.value=${this._commandMode ? `>${this._search}` : this._search} .value=${this._commandMode ? `>${this._search}` : this._search}
.icon=${true} .icon=${true}
.iconTrailing=${this._search !== undefined} .iconTrailing=${this._search !== undefined || this._narrow}
@input=${this._handleSearchChange} @input=${this._handleSearchChange}
@keydown=${this._handleInputKeyDown} @keydown=${this._handleInputKeyDown}
@focus=${this._setFocusFirstListItem} @focus=${this._setFocusFirstListItem}
@ -174,24 +176,26 @@ export class QuickBar extends LitElement {
.path=${mdiMagnify} .path=${mdiMagnify}
></ha-svg-icon> ></ha-svg-icon>
`} `}
${this._search && ${this._search || this._narrow
html` ? html`
<ha-icon-button <div slot="trailingIcon">
slot="trailingIcon" ${this._search &&
@click=${this._clearSearch} html`<ha-icon-button
.label=${this.hass!.localize("ui.common.clear")} @click=${this._clearSearch}
.path=${mdiClose} .label=${this.hass!.localize("ui.common.clear")}
></ha-icon-button> .path=${mdiClose}
`} ></ha-icon-button>`}
${this._narrow &&
html`
<mwc-button
.label=${this.hass!.localize("ui.common.close")}
@click=${this.closeDialog}
></mwc-button>
`}
</div>
`
: ""}
</ha-textfield> </ha-textfield>
${this._narrow
? html`
<mwc-button
.label=${this.hass!.localize("ui.common.close")}
@click=${this.closeDialog}
></mwc-button>
`
: ""}
</div> </div>
${!items ${!items
? html`<ha-circular-progress ? html`<ha-circular-progress
@ -210,10 +214,12 @@ export class QuickBar extends LitElement {
@keydown=${this._handleListItemKeyDown} @keydown=${this._handleListItemKeyDown}
@selected=${this._handleSelected} @selected=${this._handleSelected}
style=${styleMap({ style=${styleMap({
height: `${Math.min( height: this._narrow
items.length * (this._commandMode ? 56 : 72) + 26, ? "calc(100vh - 56px)"
this._done ? 500 : 0 : `${Math.min(
)}px`, items.length * (this._commandMode ? 56 : 72) + 26,
this._done ? 500 : 0
)}px`,
})} })}
> >
${scroll({ ${scroll({
@ -705,6 +711,12 @@ export class QuickBar extends LitElement {
} }
} }
@media all and (max-width: 450px), all and (max-height: 500px) {
ha-textfield {
--mdc-shape-small: 0;
}
}
ha-icon.entity, ha-icon.entity,
ha-svg-icon.entity { ha-svg-icon.entity {
margin-left: 20px; margin-left: 20px;
@ -758,6 +770,11 @@ export class QuickBar extends LitElement {
padding: 16px 0px; padding: 16px 0px;
text-align: center; text-align: center;
} }
div[slot="trailingIcon"] {
display: flex;
align-items: center;
}
`, `,
]; ];
} }

View File

@ -5,5 +5,3 @@ import "../resources/roboto";
import "../util/legacy-support"; import "../util/legacy-support";
setPassiveTouchGestures(true); setPassiveTouchGestures(true);
(window as any).frontendVersion = __VERSION__;

View File

@ -29,6 +29,7 @@ import { HomeAssistant } from "../types";
import { MAIN_WINDOW_NAME } from "../data/main_window"; import { MAIN_WINDOW_NAME } from "../data/main_window";
window.name = MAIN_WINDOW_NAME; window.name = MAIN_WINDOW_NAME;
(window as any).frontendVersion = __VERSION__;
declare global { declare global {
interface Window { interface Window {

View File

@ -12,6 +12,7 @@ import {
} from "../../../data/integration"; } from "../../../data/integration";
import { HomeAssistant } from "../../../types"; import { HomeAssistant } from "../../../types";
import { brandsUrl } from "../../../util/brands-url"; import { brandsUrl } from "../../../util/brands-url";
import { documentationUrl } from "../../../util/documentation-url";
@customElement("integrations-card") @customElement("integrations-card")
class IntegrationsCard extends LitElement { class IntegrationsCard extends LitElement {
@ -66,7 +67,12 @@ class IntegrationsCard extends LitElement {
const manifest = this._manifests && this._manifests[domain]; const manifest = this._manifests && this._manifests[domain];
const docLink = manifest const docLink = manifest
? html`<a ? html`<a
href=${manifest.documentation} href=${manifest.is_built_in
? documentationUrl(
this.hass,
`/integrations/${manifest.domain}`
)
: manifest.documentation}
target="_blank" target="_blank"
rel="noreferrer" rel="noreferrer"
>${this.hass.localize( >${this.hass.localize(

View File

@ -15,6 +15,7 @@ import { showConfirmationDialog } from "../../../dialogs/generic/show-dialog-box
import type { HomeAssistant } from "../../../types"; import type { HomeAssistant } from "../../../types";
import type { DataEntryFlowProgressExtended } from "./ha-config-integrations"; import type { DataEntryFlowProgressExtended } from "./ha-config-integrations";
import "./ha-integration-action-card"; import "./ha-integration-action-card";
import { documentationUrl } from "../../../util/documentation-url";
@customElement("ha-config-flow-card") @customElement("ha-config-flow-card")
export class HaConfigFlowCard extends LitElement { export class HaConfigFlowCard extends LitElement {
@ -82,7 +83,12 @@ export class HaConfigFlowCard extends LitElement {
: ""} : ""}
${this.manifest ${this.manifest
? html`<a ? html`<a
href=${this.manifest.documentation} href=${this.manifest.is_built_in
? documentationUrl(
this.hass,
`/integrations/${this.manifest.domain}`
)
: this.manifest.documentation}
rel="noreferrer" rel="noreferrer"
target="_blank" target="_blank"
> >

View File

@ -46,6 +46,7 @@ import {
} from "../../../dialogs/generic/show-dialog-box"; } from "../../../dialogs/generic/show-dialog-box";
import { haStyle, haStyleScrollbar } from "../../../resources/styles"; import { haStyle, haStyleScrollbar } from "../../../resources/styles";
import type { HomeAssistant } from "../../../types"; import type { HomeAssistant } from "../../../types";
import { documentationUrl } from "../../../util/documentation-url";
import { fileDownload } from "../../../util/file_download"; import { fileDownload } from "../../../util/file_download";
import type { ConfigEntryExtended } from "./ha-config-integrations"; import type { ConfigEntryExtended } from "./ha-config-integrations";
import "./ha-integration-header"; import "./ha-integration-header";
@ -331,7 +332,12 @@ export class HaIntegrationCard extends LitElement {
</mwc-list-item> </mwc-list-item>
${this.manifest ${this.manifest
? html` <a ? html` <a
href=${this.manifest.documentation} href=${this.manifest.is_built_in
? documentationUrl(
this.hass,
`/integrations/${this.manifest.domain}`
)
: this.manifest.documentation}
rel="noreferrer" rel="noreferrer"
target="_blank" target="_blank"
> >

View File

@ -21,6 +21,7 @@ import {
} from "../../../data/system_log"; } from "../../../data/system_log";
import { haStyleDialog } from "../../../resources/styles"; import { haStyleDialog } from "../../../resources/styles";
import type { HomeAssistant } from "../../../types"; import type { HomeAssistant } from "../../../types";
import { documentationUrl } from "../../../util/documentation-url";
import { showToast } from "../../../util/toast"; import { showToast } from "../../../util/toast";
import type { SystemLogDetailDialogParams } from "./show-dialog-system-log-detail"; import type { SystemLogDetailDialogParams } from "./show-dialog-system-log-detail";
import { formatSystemLogTime } from "./util"; import { formatSystemLogTime } from "./util";
@ -117,7 +118,12 @@ class DialogSystemLogDetail extends LitElement {
? "" ? ""
: html` : html`
(<a (<a
href=${this._manifest.documentation} href=${this._manifest.is_built_in
? documentationUrl(
this.hass,
`/integrations/${this._manifest.domain}`
)
: this._manifest.documentation}
target="_blank" target="_blank"
rel="noreferrer" rel="noreferrer"
>documentation</a >documentation</a

View File

@ -8,6 +8,7 @@ import "@polymer/paper-tooltip/paper-tooltip";
import { html, LitElement, PropertyValues, TemplateResult } from "lit"; import { html, LitElement, PropertyValues, TemplateResult } from "lit";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state } from "lit/decorators";
import memoize from "memoize-one"; import memoize from "memoize-one";
import { isComponentLoaded } from "../../../../common/config/is_component_loaded";
import { navigate } from "../../../../common/navigate"; import { navigate } from "../../../../common/navigate";
import { stringCompare } from "../../../../common/string/compare"; import { stringCompare } from "../../../../common/string/compare";
import { import {
@ -183,29 +184,34 @@ export class HaConfigLovelaceDashboards extends LitElement {
).mode; ).mode;
const defaultUrlPath = this.hass.defaultPanel; const defaultUrlPath = this.hass.defaultPanel;
const isDefault = defaultUrlPath === "lovelace"; const isDefault = defaultUrlPath === "lovelace";
return [ const result: Record<string, any>[] = [
{ {
icon: "hass:view-dashboard", icon: "hass:view-dashboard",
title: this.hass.localize("panel.states"), title: this.hass.localize("panel.states"),
default: isDefault, default: isDefault,
sidebar: isDefault, show_in_sidebar: isDefault,
require_admin: false, require_admin: false,
url_path: "lovelace", url_path: "lovelace",
mode: defaultMode, mode: defaultMode,
filename: defaultMode === "yaml" ? "ui-lovelace.yaml" : "", filename: defaultMode === "yaml" ? "ui-lovelace.yaml" : "",
}, },
{
icon: "hass:lightning-bolt",
title: this.hass.localize(`ui.panel.config.dashboard.energy.title`),
url_path: "energy",
filename: "",
},
...dashboards.map((dashboard) => ({ ...dashboards.map((dashboard) => ({
filename: "", filename: "",
...dashboard, ...dashboard,
default: defaultUrlPath === dashboard.url_path, default: defaultUrlPath === dashboard.url_path,
})), })),
]; ];
if (isComponentLoaded(this.hass, "energy")) {
result.push({
icon: "hass:lightning-bolt",
title: this.hass.localize(`ui.panel.config.dashboard.energy.title`),
show_in_sidebar: true,
mode: "storage",
url_path: "energy",
filename: "",
});
}
return result;
}); });
protected render(): TemplateResult { protected render(): TemplateResult {

View File

@ -130,6 +130,7 @@ class HUIRoot extends LitElement {
></ha-icon-button> ></ha-icon-button>
</div> </div>
<mwc-button <mwc-button
outlined
class="exit-edit-mode" class="exit-edit-mode"
.label=${this.hass!.localize( .label=${this.hass!.localize(
"ui.panel.lovelace.menu.exit_edit_mode" "ui.panel.lovelace.menu.exit_edit_mode"
@ -938,7 +939,8 @@ class HUIRoot extends LitElement {
); );
} }
.exit-edit-mode { .exit-edit-mode {
--mdc-theme-primary: var(--primary-text-color); --mdc-theme-primary: var(--app-header-edit-text-color, #fff);
--mdc-button-outline-color: var(--app-header-edit-text-color, #fff);
--mdc-typography-button-font-size: 14px; --mdc-typography-button-font-size: 14px;
} }
`, `,

View File

@ -3,7 +3,7 @@ import { isComponentLoaded } from "../../../common/config/is_component_loaded";
import { subscribeOne } from "../../../common/util/subscribe-one"; import { subscribeOne } from "../../../common/util/subscribe-one";
import { subscribeAreaRegistry } from "../../../data/area_registry"; import { subscribeAreaRegistry } from "../../../data/area_registry";
import { subscribeDeviceRegistry } from "../../../data/device_registry"; import { subscribeDeviceRegistry } from "../../../data/device_registry";
import { EnergyPreferences, getEnergyPreferences } from "../../../data/energy"; import { getEnergyPreferences } from "../../../data/energy";
import { subscribeEntityRegistry } from "../../../data/entity_registry"; import { subscribeEntityRegistry } from "../../../data/entity_registry";
import { generateDefaultViewConfig } from "../common/generate-lovelace-config"; import { generateDefaultViewConfig } from "../common/generate-lovelace-config";
import { import {
@ -39,30 +39,18 @@ export class OriginalStatesStrategy {
subscribeEntityRegistry(hass.connection, () => undefined); subscribeEntityRegistry(hass.connection, () => undefined);
} }
let energyPromise: Promise<EnergyPreferences> | undefined; const [areaEntries, deviceEntries, entityEntries, localize, energyPrefs] =
if (isComponentLoaded(hass, "energy")) {
energyPromise = getEnergyPreferences(hass);
}
const [areaEntries, deviceEntries, entityEntries, localize] =
await Promise.all([ await Promise.all([
subscribeOne(hass.connection, subscribeAreaRegistry), subscribeOne(hass.connection, subscribeAreaRegistry),
subscribeOne(hass.connection, subscribeDeviceRegistry), subscribeOne(hass.connection, subscribeDeviceRegistry),
subscribeOne(hass.connection, subscribeEntityRegistry), subscribeOne(hass.connection, subscribeEntityRegistry),
hass.loadBackendTranslation("title"), hass.loadBackendTranslation("title"),
isComponentLoaded(hass, "energy")
? // It raises if not configured, just swallow that.
getEnergyPreferences(hass).catch(() => undefined)
: undefined,
]); ]);
let energyPrefs: EnergyPreferences | undefined;
if (energyPromise) {
try {
energyPrefs = await energyPromise;
} catch (_) {
// Nothing to do here
}
}
// User can override default view. If they didn't, we will add one // User can override default view. If they didn't, we will add one
// that contains all entities. // that contains all entities.
const view = generateDefaultViewConfig( const view = generateDefaultViewConfig(

View File

@ -448,6 +448,7 @@ class BarMediaPlayer extends LitElement {
.controls { .controls {
height: 48px; height: 48px;
padding-bottom: 4px;
} }
.controls-progress { .controls-progress {
@ -501,6 +502,7 @@ class BarMediaPlayer extends LitElement {
:host([narrow]) .controls { :host([narrow]) .controls {
display: flex; display: flex;
padding-bottom: 0;
} }
:host([narrow]) .choose-player { :host([narrow]) .choose-player {