mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 16:26:43 +00:00
Fix more info for disabled entities (#24789)
This commit is contained in:
parent
97966805fa
commit
a9823f30e3
@ -1,7 +1,11 @@
|
|||||||
import type { HassEntity } from "home-assistant-js-websocket";
|
import type { HassEntity } from "home-assistant-js-websocket";
|
||||||
import type { AreaRegistryEntry } from "../../data/area_registry";
|
import type { AreaRegistryEntry } from "../../data/area_registry";
|
||||||
import type { DeviceRegistryEntry } from "../../data/device_registry";
|
import type { DeviceRegistryEntry } from "../../data/device_registry";
|
||||||
import type { EntityRegistryDisplayEntry } from "../../data/entity_registry";
|
import type {
|
||||||
|
EntityRegistryDisplayEntry,
|
||||||
|
EntityRegistryEntry,
|
||||||
|
ExtEntityRegistryEntry,
|
||||||
|
} from "../../data/entity_registry";
|
||||||
import type { FloorRegistryEntry } from "../../data/floor_registry";
|
import type { FloorRegistryEntry } from "../../data/floor_registry";
|
||||||
import type { HomeAssistant } from "../../types";
|
import type { HomeAssistant } from "../../types";
|
||||||
|
|
||||||
@ -19,6 +23,23 @@ export const getEntityContext = (
|
|||||||
| EntityRegistryDisplayEntry
|
| EntityRegistryDisplayEntry
|
||||||
| undefined;
|
| undefined;
|
||||||
|
|
||||||
|
if (!entry) {
|
||||||
|
return {
|
||||||
|
device: null,
|
||||||
|
area: null,
|
||||||
|
floor: null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return getEntityEntryContext(entry, hass);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getEntityEntryContext = (
|
||||||
|
entry:
|
||||||
|
| EntityRegistryDisplayEntry
|
||||||
|
| EntityRegistryEntry
|
||||||
|
| ExtEntityRegistryEntry,
|
||||||
|
hass: HomeAssistant
|
||||||
|
): EntityContext => {
|
||||||
const deviceId = entry?.device_id;
|
const deviceId = entry?.device_id;
|
||||||
const device = deviceId ? hass.devices[deviceId] : null;
|
const device = deviceId ? hass.devices[deviceId] : null;
|
||||||
const areaId = entry?.area_id || device?.area_id;
|
const areaId = entry?.area_id || device?.area_id;
|
||||||
|
@ -21,8 +21,10 @@ import { stopPropagation } from "../../common/dom/stop_propagation";
|
|||||||
import { computeAreaName } from "../../common/entity/compute_area_name";
|
import { computeAreaName } from "../../common/entity/compute_area_name";
|
||||||
import { computeDeviceName } from "../../common/entity/compute_device_name";
|
import { computeDeviceName } from "../../common/entity/compute_device_name";
|
||||||
import { computeDomain } from "../../common/entity/compute_domain";
|
import { computeDomain } from "../../common/entity/compute_domain";
|
||||||
import { computeEntityName } from "../../common/entity/compute_entity_name";
|
import {
|
||||||
import { getEntityContext } from "../../common/entity/get_entity_context";
|
computeEntityEntryName,
|
||||||
|
computeEntityName,
|
||||||
|
} from "../../common/entity/compute_entity_name";
|
||||||
import { shouldHandleRequestSelectedEvent } from "../../common/mwc/handle-request-selected-event";
|
import { shouldHandleRequestSelectedEvent } from "../../common/mwc/handle-request-selected-event";
|
||||||
import { navigate } from "../../common/navigate";
|
import { navigate } from "../../common/navigate";
|
||||||
import "../../components/ha-button-menu";
|
import "../../components/ha-button-menu";
|
||||||
@ -56,6 +58,10 @@ import "./ha-more-info-history-and-logbook";
|
|||||||
import "./ha-more-info-info";
|
import "./ha-more-info-info";
|
||||||
import "./ha-more-info-settings";
|
import "./ha-more-info-settings";
|
||||||
import "./more-info-content";
|
import "./more-info-content";
|
||||||
|
import {
|
||||||
|
getEntityContext,
|
||||||
|
getEntityEntryContext,
|
||||||
|
} from "../../common/entity/get_entity_context";
|
||||||
|
|
||||||
export interface MoreInfoDialogParams {
|
export interface MoreInfoDialogParams {
|
||||||
entityId: string | null;
|
entityId: string | null;
|
||||||
@ -293,11 +299,18 @@ export class MoreInfoDialog extends LitElement {
|
|||||||
this._initialView !== DEFAULT_VIEW && !this._childView;
|
this._initialView !== DEFAULT_VIEW && !this._childView;
|
||||||
const showCloseIcon = isDefaultView || isSpecificInitialView;
|
const showCloseIcon = isDefaultView || isSpecificInitialView;
|
||||||
|
|
||||||
const context = stateObj ? getEntityContext(stateObj, this.hass) : null;
|
const context = stateObj
|
||||||
|
? getEntityContext(stateObj, this.hass)
|
||||||
|
: this._entry
|
||||||
|
? getEntityEntryContext(this._entry, this.hass)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
const entityName = stateObj
|
const entityName = stateObj
|
||||||
? computeEntityName(stateObj, this.hass)
|
? computeEntityName(stateObj, this.hass)
|
||||||
: undefined;
|
: this._entry
|
||||||
|
? computeEntityEntryName(this._entry, this.hass)
|
||||||
|
: entityId;
|
||||||
|
|
||||||
const deviceName = context?.device
|
const deviceName = context?.device
|
||||||
? computeDeviceName(context.device)
|
? computeDeviceName(context.device)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user