Fixes for problems caused by not rebuilding (#5850)

This commit is contained in:
Bram Kragten 2020-05-13 18:51:26 +02:00 committed by GitHub
parent 4c0810f530
commit b2af91c83e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 5 deletions

View File

@ -15,9 +15,14 @@ import { hasConfigOrEntityChanged } from "../common/has-changed";
import "../components/hui-generic-entity-row"; import "../components/hui-generic-entity-row";
import "../components/hui-timestamp-display"; import "../components/hui-timestamp-display";
import "../components/hui-warning"; import "../components/hui-warning";
import { EntityConfig, LovelaceRow } from "./types"; import { LovelaceRow } from "./types";
import { EntitiesCardEntityConfig } from "../cards/types";
import { actionHandler } from "../common/directives/action-handler-directive";
import { hasAction } from "../common/has-action";
import { ActionHandlerEvent } from "../../../data/lovelace";
import { handleAction } from "../common/handle-action";
interface SensorEntityConfig extends EntityConfig { interface SensorEntityConfig extends EntitiesCardEntityConfig {
format?: "relative" | "date" | "time" | "datetime"; format?: "relative" | "date" | "time" | "datetime";
} }
@ -59,7 +64,14 @@ class HuiSensorEntityRow extends LitElement implements LovelaceRow {
return html` return html`
<hui-generic-entity-row .hass=${this.hass} .config=${this._config}> <hui-generic-entity-row .hass=${this.hass} .config=${this._config}>
<div class="text-content"> <div
class="text-content"
@action=${this._handleAction}
.actionHandler=${actionHandler({
hasHold: hasAction(this._config.hold_action),
hasDoubleClick: hasAction(this._config.double_tap_action),
})}
>
${stateObj.attributes.device_class === ${stateObj.attributes.device_class ===
SENSOR_DEVICE_CLASS_TIMESTAMP && SENSOR_DEVICE_CLASS_TIMESTAMP &&
stateObj.state !== "unavailable" && stateObj.state !== "unavailable" &&
@ -81,6 +93,10 @@ class HuiSensorEntityRow extends LitElement implements LovelaceRow {
`; `;
} }
private _handleAction(ev: ActionHandlerEvent) {
handleAction(this, this.hass!, this._config!, ev.detail.action);
}
static get styles(): CSSResult { static get styles(): CSSResult {
return css` return css`
div { div {

View File

@ -424,18 +424,24 @@ class HUIRoot extends LitElement {
} }
if (!oldLovelace || oldLovelace.editMode !== this.lovelace!.editMode) { if (!oldLovelace || oldLovelace.editMode !== this.lovelace!.editMode) {
const views = this.config && this.config.views;
// Adjust for higher header
if (!views || views.length < 2) {
fireEvent(this, "iron-resize");
}
// Leave unused entities when leaving edit mode // Leave unused entities when leaving edit mode
if ( if (
this.lovelace!.mode === "storage" && this.lovelace!.mode === "storage" &&
viewPath === "hass-unused-entities" viewPath === "hass-unused-entities"
) { ) {
const views = this.config && this.config.views;
navigate(this, `${this.route?.prefix}/${views[0]?.path || 0}`); navigate(this, `${this.route?.prefix}/${views[0]?.path || 0}`);
newSelectView = 0; newSelectView = 0;
} }
} }
if (!force) { if (!force && huiView) {
huiView.lovelace = this.lovelace; huiView.lovelace = this.lovelace;
} }
} }