Skip to content

Commit

Permalink
Merge branch 'home-assistant:dev' into lock-commands
Browse files Browse the repository at this point in the history
  • Loading branch information
marcgeurts authored Feb 27, 2024
2 parents 034a0f1 + 29954e5 commit 4ecdde4
Show file tree
Hide file tree
Showing 51 changed files with 354 additions and 127 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
"babel-plugin-template-html-minifier": "4.1.0",
"chai": "5.1.0",
"del": "7.1.0",
"eslint": "8.56.0",
"eslint": "8.57.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-airbnb-typescript": "17.1.0",
"eslint-config-prettier": "9.1.0",
Expand All @@ -207,7 +207,7 @@
"glob": "10.3.10",
"gulp": "4.0.2",
"gulp-flatmap": "1.0.2",
"gulp-json-transform": "0.4.8",
"gulp-json-transform": "0.5.0",
"gulp-merge-json": "2.1.2",
"gulp-rename": "2.0.0",
"gulp-zopfli-green": "6.0.1",
Expand Down
11 changes: 10 additions & 1 deletion src/common/config/can_show_page.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { PageNavigation } from "../../layouts/hass-tabs-subpage";
import { HomeAssistant } from "../../types";
import { ensureArray } from "../array/ensure-array";
import { isComponentLoaded } from "./is_component_loaded";

export const canShowPage = (hass: HomeAssistant, page: PageNavigation) =>
(isCore(page) || isLoadedIntegration(hass, page)) &&
!hideAdvancedPage(hass, page);
!hideAdvancedPage(hass, page) &&
isNotLoadedIntegration(hass, page);

const isLoadedIntegration = (hass: HomeAssistant, page: PageNavigation) =>
page.component
Expand All @@ -14,6 +16,13 @@ const isLoadedIntegration = (hass: HomeAssistant, page: PageNavigation) =>
isComponentLoaded(hass, integration)
)
: true;

const isNotLoadedIntegration = (hass: HomeAssistant, page: PageNavigation) =>
!page.not_component ||
!ensureArray(page.not_component).some((integration) =>
isComponentLoaded(hass, integration)
);

const isCore = (page: PageNavigation) => page.core;
const isAdvancedPage = (page: PageNavigation) => page.advancedOnly;
const userWantsAdvanced = (hass: HomeAssistant) => hass.userData?.showAdvanced;
Expand Down
17 changes: 11 additions & 6 deletions src/common/dom/get_main_window.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { MAIN_WINDOW_NAME } from "../../data/main_window";

export const mainWindow =
window.name === MAIN_WINDOW_NAME
? window
: parent.name === MAIN_WINDOW_NAME
? parent
: top!;
export const mainWindow = (() => {
try {
return window.name === MAIN_WINDOW_NAME
? window
: parent.name === MAIN_WINDOW_NAME
? parent
: top!;
} catch {
return window;
}
})();
6 changes: 4 additions & 2 deletions src/components/entity/state-badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ export class StateBadge extends LitElement {

@property() public overrideImage?: string;

@property({ type: Boolean }) public stateColor = false;
// Cannot be a boolean attribute because undefined is treated different than
// false. When it is undefined, state is still colored for light entities.
@property({ attribute: false }) public stateColor?: boolean;

@property() public color?: string;

Expand Down Expand Up @@ -70,7 +72,7 @@ export class StateBadge extends LitElement {
const domain = this.stateObj
? computeStateDomain(this.stateObj)
: undefined;
return this.stateColor || (domain === "light" && this.stateColor !== false);
return this.stateColor ?? domain === "light";
}

protected render() {
Expand Down
1 change: 1 addition & 0 deletions src/components/ha-climate-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ class HaClimateState extends LitElement {
.current {
color: var(--secondary-text-color);
direction: var(--direction);
}
.state-label {
Expand Down
8 changes: 7 additions & 1 deletion src/components/ha-metric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ class HaMetric extends LitElement {
<ha-settings-row>
<span slot="heading"> ${this.heading} </span>
<div slot="description" .title=${this.tooltip ?? ""}>
<span class="value"> ${roundedValue} % </span>
<span class="value">
<div>${roundedValue} %</div>
</span>
<ha-bar
class=${classMap({
"target-warning": roundedValue > 50,
Expand Down Expand Up @@ -70,6 +72,10 @@ class HaMetric extends LitElement {
padding-inline-start: initial;
flex-shrink: 0;
}
.value > div {
direction: ltr;
text-align: var(--float-start);
}
`;
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/ha-qr-scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ class HaQrScanner extends LitElement {
position: absolute;
bottom: 8px;
right: 8px;
inset-inline-end: 8px;
inset-inline-start: initial;
background: #727272b2;
color: white;
border-radius: 50%;
Expand Down
58 changes: 33 additions & 25 deletions src/components/ha-service-control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ export class HaServiceControl extends LitElement {

@property({ type: Boolean, reflect: true }) public hidePicker = false;

@property({ type: Boolean }) public hideDescription = false;

@state() private _value!: this["value"];

@state() private _checkedKeys = new Set();
Expand Down Expand Up @@ -373,37 +375,42 @@ export class HaServiceControl extends LitElement {
)) ||
serviceData?.description;

return html`${this.hidePicker
return html`
${this.hidePicker
? nothing
: html`<ha-service-picker
.hass=${this.hass}
.value=${this._value?.service}
.disabled=${this.disabled}
@value-changed=${this._serviceChanged}
></ha-service-picker>`}
<div class="description">
${description ? html`<p>${description}</p>` : ""}
${this._manifest
? html` <a
href=${this._manifest.is_built_in
? documentationUrl(
this.hass,
`/integrations/${this._manifest.domain}`
)
: this._manifest.documentation}
title=${this.hass.localize(
"ui.components.service-control.integration_doc"
)}
target="_blank"
rel="noreferrer"
>
<ha-icon-button
.path=${mdiHelpCircle}
class="help-icon"
></ha-icon-button>
</a>`
: ""}
</div>
${this.hideDescription
? nothing
: html`
<div class="description">
${description ? html`<p>${description}</p>` : ""}
${this._manifest
? html` <a
href=${this._manifest.is_built_in
? documentationUrl(
this.hass,
`/integrations/${this._manifest.domain}`
)
: this._manifest.documentation}
title=${this.hass.localize(
"ui.components.service-control.integration_doc"
)}
target="_blank"
rel="noreferrer"
>
<ha-icon-button
.path=${mdiHelpCircle}
class="help-icon"
></ha-icon-button>
</a>`
: nothing}
</div>
`}
${serviceData && "target" in serviceData
? html`<ha-settings-row .narrow=${this.narrow}>
${hasOptional
Expand Down Expand Up @@ -517,7 +524,8 @@ export class HaServiceControl extends LitElement {
></ha-selector>
</ha-settings-row>`
: "";
})}`;
})}
`;
}

private _localizeValueCallback = (key: string) => {
Expand Down
3 changes: 1 addition & 2 deletions src/components/ha-textfield.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class HaTextField extends TextFieldBase {
padding-right: var(--text-field-suffix-padding-right, 0px);
padding-inline-start: var(--text-field-suffix-padding-left, 12px);
padding-inline-end: var(--text-field-suffix-padding-right, 0px);
direction: var(--direction);
direction: ltr;
}
.mdc-text-field--with-leading-icon {
padding-inline-start: var(--text-field-suffix-padding-left, 0px);
Expand Down Expand Up @@ -199,7 +199,6 @@ export class HaTextField extends TextFieldBase {
// safari workaround - must be explicit
mainWindow.document.dir === "rtl"
? css`
.mdc-text-field__affix--suffix,
.mdc-text-field--with-leading-icon,
.mdc-text-field__icon--leading,
.mdc-floating-label,
Expand Down
1 change: 0 additions & 1 deletion src/components/media-player/dialog-media-player-browse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ class DialogMediaPlayerBrowse extends LitElement {
ha-media-player-browse {
--media-browser-max-height: calc(100vh - 65px);
direction: ltr;
}
:host(.opened) ha-media-player-browse {
Expand Down
1 change: 1 addition & 0 deletions src/components/media-player/ha-media-player-browse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,7 @@ export class HaMediaPlayerBrowse extends LitElement {
display: flex;
flex-direction: column;
position: relative;
direction: ltr;
}
ha-circular-progress {
Expand Down
10 changes: 8 additions & 2 deletions src/dialogs/generic/dialog-box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,21 @@ class DialogBox extends LitElement {
</div>
${confirmPrompt &&
html`
<mwc-button @click=${this._dismiss} slot="secondaryAction">
<mwc-button
@click=${this._dismiss}
slot="secondaryAction"
?dialogInitialFocus=${!this._params.prompt &&
this._params.destructive}
>
${this._params.dismissText
? this._params.dismissText
: this.hass.localize("ui.dialogs.generic.cancel")}
</mwc-button>
`}
<mwc-button
@click=${this._confirm}
?dialogInitialFocus=${!this._params.prompt}
?dialogInitialFocus=${!this._params.prompt &&
!this._params.destructive}
slot="primaryAction"
class=${classMap({
destructive: this._params.destructive || false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ export class HaMoreInfoLightFavoriteColors extends LitElement {
position: absolute;
top: -6px;
right: -6px;
inset-inline-end: -6px;
inset-inline-start: initial;
width: 20px;
height: 20px;
outline: none;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,8 @@ class LightRgbColorPicker extends LitElement {
position: absolute;
top: 0;
right: 0;
inset-inline-end: 0;
inset-inline-start: initial;
z-index: 1;
}
Expand Down
2 changes: 1 addition & 1 deletion src/dialogs/more-info/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { computeGroupDomain, GroupEntity } from "../../data/group";
import { CONTINUOUS_DOMAINS } from "../../data/logbook";
import { HomeAssistant } from "../../types";

export const DOMAINS_NO_INFO = ["camera", "configurator"];
export const DOMAINS_NO_INFO = ["camera", "configurator", "script"];
/**
* Entity domains that should be editable *if* they have an id present;
* {@see shouldShowEditIcon}.
Expand Down
Loading

0 comments on commit 4ecdde4

Please sign in to comment.