Merge pull request #6426 from yosilevy/Logbook-link-fix

Logbook link fix
This commit is contained in:
Yosi Levy 2020-07-20 14:31:21 +03:00 committed by GitHub
commit 11827aa4c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 7 deletions

View File

@ -9,5 +9,9 @@ export function computeRTL(hass: HomeAssistant) {
} }
export function computeRTLDirection(hass: HomeAssistant) { export function computeRTLDirection(hass: HomeAssistant) {
return computeRTL(hass) ? "rtl" : "ltr"; return emitRTLDirection(computeRTL(hass));
}
export function emitRTLDirection(rtl: boolean) {
return rtl ? "rtl" : "ltr";
} }

View File

@ -14,7 +14,7 @@ import { formatTimeWithSeconds } from "../../common/datetime/format_time";
import { fireEvent } from "../../common/dom/fire_event"; import { fireEvent } from "../../common/dom/fire_event";
import { domainIcon } from "../../common/entity/domain_icon"; import { domainIcon } from "../../common/entity/domain_icon";
import { stateIcon } from "../../common/entity/state_icon"; import { stateIcon } from "../../common/entity/state_icon";
import { computeRTL } from "../../common/util/compute_rtl"; import { computeRTL, emitRTLDirection } from "../../common/util/compute_rtl";
import "../../components/ha-icon"; import "../../components/ha-icon";
import { LogbookEntry } from "../../data/logbook"; import { LogbookEntry } from "../../data/logbook";
import { HomeAssistant } from "../../types"; import { HomeAssistant } from "../../types";
@ -28,7 +28,6 @@ class HaLogbook extends LitElement {
@property() public entries: LogbookEntry[] = []; @property() public entries: LogbookEntry[] = [];
@property({ attribute: "rtl", type: Boolean, reflect: true }) @property({ attribute: "rtl", type: Boolean, reflect: true })
// @ts-ignore
private _rtl = false; private _rtl = false;
// @ts-ignore // @ts-ignore
@ -38,17 +37,22 @@ class HaLogbook extends LitElement {
const oldHass = changedProps.get("hass") as HomeAssistant | undefined; const oldHass = changedProps.get("hass") as HomeAssistant | undefined;
const languageChanged = const languageChanged =
oldHass === undefined || oldHass.language !== this.hass.language; oldHass === undefined || oldHass.language !== this.hass.language;
return changedProps.has("entries") || languageChanged; return changedProps.has("entries") || languageChanged;
} }
protected updated(_changedProps: PropertyValues) { protected updated(_changedProps: PropertyValues) {
this._rtl = computeRTL(this.hass); const oldHass = _changedProps.get("hass") as HomeAssistant | undefined;
if (oldHass === undefined || oldHass.language !== this.hass.language) {
this._rtl = computeRTL(this.hass);
}
} }
protected render(): TemplateResult { protected render(): TemplateResult {
if (!this.entries?.length) { if (!this.entries?.length) {
return html` return html`
<div class="container"> <div class="container" .dir=${emitRTLDirection(this._rtl)}>
${this.hass.localize("ui.panel.logbook.entries_not_found")} ${this.hass.localize("ui.panel.logbook.entries_not_found")}
</div> </div>
`; `;
@ -106,9 +110,8 @@ class HaLogbook extends LitElement {
@click=${this._entityClicked} @click=${this._entityClicked}
.entityId=${item.entity_id} .entityId=${item.entity_id}
class="name" class="name"
>${item.name}</a
> >
${item.name}
</a>
`} `}
<span <span
>${item.message}${item_username >${item.message}${item_username