mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-15 05:16:34 +00:00
Show the integration brand icon when there is no entity in logbook (#12713)
This commit is contained in:
parent
af6b0d3266
commit
f4f51e1de5
@ -46,6 +46,20 @@ export const domainIcon = (
|
||||
stateObj?: HassEntity,
|
||||
state?: string
|
||||
): string => {
|
||||
const icon = domainIconWithoutDefault(domain, stateObj, state);
|
||||
if (icon) {
|
||||
return icon;
|
||||
}
|
||||
// eslint-disable-next-line
|
||||
console.warn(`Unable to find icon for domain ${domain}`);
|
||||
return DEFAULT_DOMAIN_ICON;
|
||||
};
|
||||
|
||||
export const domainIconWithoutDefault = (
|
||||
domain: string,
|
||||
stateObj?: HassEntity,
|
||||
state?: string
|
||||
): string | undefined => {
|
||||
const compareState = state !== undefined ? state : stateObj?.state;
|
||||
|
||||
switch (domain) {
|
||||
@ -150,7 +164,5 @@ export const domainIcon = (
|
||||
return FIXED_DOMAIN_ICONS[domain];
|
||||
}
|
||||
|
||||
// eslint-disable-next-line
|
||||
console.warn(`Unable to find icon for domain ${domain}`);
|
||||
return DEFAULT_DOMAIN_ICON;
|
||||
return undefined;
|
||||
};
|
||||
|
@ -15,7 +15,8 @@ import { formatTimeWithSeconds } from "../../common/datetime/format_time";
|
||||
import { restoreScroll } from "../../common/decorators/restore-scroll";
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import { computeDomain } from "../../common/entity/compute_domain";
|
||||
import { domainIcon } from "../../common/entity/domain_icon";
|
||||
import { domainIconWithoutDefault } from "../../common/entity/domain_icon";
|
||||
import { isComponentLoaded } from "../../common/config/is_component_loaded";
|
||||
import { computeRTL, emitRTLDirection } from "../../common/util/compute_rtl";
|
||||
import "../../components/entity/state-badge";
|
||||
import "../../components/ha-circular-progress";
|
||||
@ -28,6 +29,7 @@ import {
|
||||
buttonLinkStyle,
|
||||
} from "../../resources/styles";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import { brandsUrl } from "../../util/brands-url";
|
||||
|
||||
const EVENT_LOCALIZE_MAP = {
|
||||
script_started: "from_script",
|
||||
@ -138,6 +140,26 @@ class HaLogbookRenderer extends LitElement {
|
||||
? computeDomain(item.entity_id)
|
||||
: // Domain is there if there is no entity ID.
|
||||
item.domain!;
|
||||
const overrideIcon =
|
||||
item.icon ||
|
||||
(item.domain && !stateObj
|
||||
? domainIconWithoutDefault(item.domain!)
|
||||
: undefined);
|
||||
const overrideImage = !DOMAINS_WITH_DYNAMIC_PICTURE.has(domain)
|
||||
? stateObj?.attributes.entity_picture_local ||
|
||||
stateObj?.attributes.entity_picture ||
|
||||
(!stateObj &&
|
||||
!overrideIcon &&
|
||||
item.domain &&
|
||||
isComponentLoaded(this.hass, item.domain)
|
||||
? brandsUrl({
|
||||
domain: item.domain!,
|
||||
type: "icon",
|
||||
useFallback: true,
|
||||
darkOptimized: this.hass.themes?.darkMode,
|
||||
})
|
||||
: undefined)
|
||||
: undefined;
|
||||
|
||||
return html`
|
||||
<div class="entry-container">
|
||||
@ -161,14 +183,8 @@ class HaLogbookRenderer extends LitElement {
|
||||
html`
|
||||
<state-badge
|
||||
.hass=${this.hass}
|
||||
.overrideIcon=${item.icon ||
|
||||
(item.domain && !stateObj
|
||||
? domainIcon(item.domain!)
|
||||
: undefined)}
|
||||
.overrideImage=${DOMAINS_WITH_DYNAMIC_PICTURE.has(domain)
|
||||
? ""
|
||||
: stateObj?.attributes.entity_picture_local ||
|
||||
stateObj?.attributes.entity_picture}
|
||||
.overrideIcon=${overrideIcon}
|
||||
.overrideImage=${overrideImage}
|
||||
.stateObj=${stateObj}
|
||||
.stateColor=${false}
|
||||
></state-badge>
|
||||
|
Loading…
x
Reference in New Issue
Block a user