Clean up imports and unopened tag on device config page (#21274)

This commit is contained in:
Steve Repsher 2024-07-04 04:01:01 -04:00 committed by GitHub
parent c07e1122e1
commit 8b9fa9bc39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,5 @@
import { consume } from "@lit-labs/context"; import { consume } from "@lit-labs/context";
import "@lrnwebcomponents/simple-tooltip/simple-tooltip"; import "@lrnwebcomponents/simple-tooltip/simple-tooltip";
import "@material/mwc-list/mwc-list-item";
import { import {
mdiCog, mdiCog,
mdiDelete, mdiDelete,
@ -10,8 +9,6 @@ import {
mdiPencil, mdiPencil,
mdiPlusCircle, mdiPlusCircle,
} from "@mdi/js"; } from "@mdi/js";
import "@polymer/paper-item/paper-item";
import "@polymer/paper-item/paper-item-body";
import { import {
CSSResultGroup, CSSResultGroup,
LitElement, LitElement,
@ -24,7 +21,7 @@ import { customElement, property, state } from "lit/decorators";
import { ifDefined } from "lit/directives/if-defined"; import { ifDefined } from "lit/directives/if-defined";
import memoizeOne from "memoize-one"; import memoizeOne from "memoize-one";
import { isComponentLoaded } from "../../../common/config/is_component_loaded"; import { isComponentLoaded } from "../../../common/config/is_component_loaded";
import { SENSOR_ENTITIES, ASSIST_ENTITIES } from "../../../common/const"; import { ASSIST_ENTITIES, SENSOR_ENTITIES } from "../../../common/const";
import { computeDomain } from "../../../common/entity/compute_domain"; import { computeDomain } from "../../../common/entity/compute_domain";
import { computeStateDomain } from "../../../common/entity/compute_state_domain"; import { computeStateDomain } from "../../../common/entity/compute_state_domain";
import { computeStateName } from "../../../common/entity/compute_state_name"; import { computeStateName } from "../../../common/entity/compute_state_name";
@ -77,7 +74,6 @@ import type { HomeAssistant } from "../../../types";
import { brandsUrl } from "../../../util/brands-url"; import { brandsUrl } from "../../../util/brands-url";
import { fileDownload } from "../../../util/file_download"; import { fileDownload } from "../../../util/file_download";
import "../../logbook/ha-logbook"; import "../../logbook/ha-logbook";
import "../ha-config-section";
import "./device-detail/ha-device-entities-card"; import "./device-detail/ha-device-entities-card";
import "./device-detail/ha-device-info-card"; import "./device-detail/ha-device-info-card";
import "./device-detail/ha-device-via-devices-card"; import "./device-detail/ha-device-via-devices-card";
@ -665,25 +661,20 @@ export class HaConfigDevicePage extends LitElement {
` `
: ""; : "";
return html` return html` <hass-subpage
<hass-subpage
.hass=${this.hass} .hass=${this.hass}
.narrow=${this.narrow} .narrow=${this.narrow}
.header=${deviceName} .header=${deviceName}
> >
<ha-icon-button <ha-icon-button
slot="toolbar-icon" slot="toolbar-icon"
.path=${mdiPencil} .path=${mdiPencil}
@click=${this._showSettings} @click=${this._showSettings}
.label=${this.hass.localize( .label=${this.hass.localize("ui.panel.config.devices.edit_settings")}
"ui.panel.config.devices.edit_settings"
)}
></ha-icon-button> ></ha-icon-button>
<div class="container"> <div class="container">
<div class="header fullwidth"> <div class="header fullwidth">
${ ${area
area
? html`<div class="header-name"> ? html`<div class="header-name">
<a href="/config/areas/area/${area.area_id}" <a href="/config/areas/area/${area.area_id}"
>${this.hass.localize( >${this.hass.localize(
@ -692,13 +683,10 @@ export class HaConfigDevicePage extends LitElement {
)}</a )}</a
> >
</div>` </div>`
: "" : ""}
}
<div class="header-right"> <div class="header-right">
${ ${battery &&
battery && (batteryDomain === "binary_sensor" || !isNaN(battery.state as any))
(batteryDomain === "binary_sensor" ||
!isNaN(battery.state as any))
? html` ? html`
<div class="battery"> <div class="battery">
${batteryDomain === "sensor" ${batteryDomain === "sensor"
@ -711,10 +699,8 @@ export class HaConfigDevicePage extends LitElement {
></ha-battery-icon> ></ha-battery-icon>
</div> </div>
` `
: "" : ""}
} ${integrations.length
${
integrations.length
? html` ? html`
<img <img
alt=${domainToName( alt=${domainToName(
@ -732,14 +718,11 @@ export class HaConfigDevicePage extends LitElement {
@error=${this._onImageError} @error=${this._onImageError}
/> />
` `
: "" : ""}
}
</div> </div>
</div> </div>
<div class="column"> <div class="column">
${ ${this._deviceAlerts?.length
this._deviceAlerts?.length
? html` ? html`
<div> <div>
${this._deviceAlerts.map( ${this._deviceAlerts.map(
@ -751,24 +734,17 @@ export class HaConfigDevicePage extends LitElement {
)} )}
</div> </div>
` `
: "" : ""}
} <ha-device-info-card .hass=${this.hass} .device=${device}>
<ha-device-info-card
.hass=${this.hass}
.device=${device}
>
${deviceInfo} ${deviceInfo}
${ ${firstDeviceAction || actions.length
firstDeviceAction || actions.length
? html` ? html`
<div class="card-actions" slot="actions"> <div class="card-actions" slot="actions">
<div> <div>
<a <a
href=${ifDefined(firstDeviceAction!.href)} href=${ifDefined(firstDeviceAction!.href)}
rel=${ifDefined( rel=${ifDefined(
firstDeviceAction!.target firstDeviceAction!.target ? "noreferrer" : undefined
? "noreferrer"
: undefined
)} )}
target=${ifDefined(firstDeviceAction!.target)} target=${ifDefined(firstDeviceAction!.target)}
> >
@ -782,9 +758,7 @@ export class HaConfigDevicePage extends LitElement {
${firstDeviceAction!.icon ${firstDeviceAction!.icon
? html` ? html`
<ha-svg-icon <ha-svg-icon
class=${ifDefined( class=${ifDefined(firstDeviceAction!.classes)}
firstDeviceAction!.classes
)}
.path=${firstDeviceAction!.icon} .path=${firstDeviceAction!.icon}
slot="graphic" slot="graphic"
></ha-svg-icon> ></ha-svg-icon>
@ -807,9 +781,7 @@ export class HaConfigDevicePage extends LitElement {
<ha-button-menu> <ha-button-menu>
<ha-icon-button <ha-icon-button
slot="trigger" slot="trigger"
.label=${this.hass.localize( .label=${this.hass.localize("ui.common.menu")}
"ui.common.menu"
)}
.path=${mdiDotsVertical} .path=${mdiDotsVertical}
></ha-icon-button> ></ha-icon-button>
${actions.map((deviceAction) => { ${actions.map((deviceAction) => {
@ -818,17 +790,13 @@ export class HaConfigDevicePage extends LitElement {
.action=${deviceAction.action} .action=${deviceAction.action}
@click=${this._deviceActionClicked} @click=${this._deviceActionClicked}
graphic="icon" graphic="icon"
.hasMeta=${Boolean( .hasMeta=${Boolean(deviceAction.trailingIcon)}
deviceAction.trailingIcon
)}
> >
${deviceAction.label} ${deviceAction.label}
${deviceAction.icon ${deviceAction.icon
? html` ? html`
<ha-svg-icon <ha-svg-icon
class=${ifDefined( class=${ifDefined(deviceAction.classes)}
deviceAction.classes
)}
.path=${deviceAction.icon} .path=${deviceAction.icon}
slot="graphic" slot="graphic"
></ha-svg-icon> ></ha-svg-icon>
@ -846,9 +814,7 @@ export class HaConfigDevicePage extends LitElement {
return deviceAction.href return deviceAction.href
? html`<a ? html`<a
href=${deviceAction.href} href=${deviceAction.href}
target=${ifDefined( target=${ifDefined(deviceAction.target)}
deviceAction.target
)}
rel=${ifDefined( rel=${ifDefined(
deviceAction.target deviceAction.target
? "noreferrer" ? "noreferrer"
@ -863,8 +829,7 @@ export class HaConfigDevicePage extends LitElement {
: ""} : ""}
</div> </div>
` `
: "" : ""}
}
</ha-device-info-card> </ha-device-info-card>
${!this.narrow ? [automationCard, sceneCard, scriptCard] : ""} ${!this.narrow ? [automationCard, sceneCard, scriptCard] : ""}
</div> </div>
@ -904,8 +869,7 @@ export class HaConfigDevicePage extends LitElement {
</div> </div>
<div class="column"> <div class="column">
${this.narrow ? [automationCard, sceneCard, scriptCard] : ""} ${this.narrow ? [automationCard, sceneCard, scriptCard] : ""}
${ ${isComponentLoaded(this.hass, "logbook")
isComponentLoaded(this.hass, "logbook")
? html` ? html`
<ha-card outlined> <ha-card outlined>
<h1 class="card-header"> <h1 class="card-header">
@ -922,12 +886,10 @@ export class HaConfigDevicePage extends LitElement {
></ha-logbook> ></ha-logbook>
</ha-card> </ha-card>
` `
: "" : ""}
}
</div> </div>
</div> </div>
</ha-config-section> </hass-subpage>`;
</hass-subpage> `;
} }
private async _getDiagnosticButtons(requestId: number): Promise<void> { private async _getDiagnosticButtons(requestId: number): Promise<void> {