From 89d9dd28932a7f7108a48db2980b200e43b10b0f Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Mon, 30 Jun 2025 17:44:50 +0200 Subject: [PATCH] Improve device row in integration page (#26005) Improve device row in config entry page --- .../ha-config-entry-device-row.ts | 197 +++++++++--------- src/translations/en.json | 1 + 2 files changed, 104 insertions(+), 94 deletions(-) diff --git a/src/panels/config/integrations/ha-config-entry-device-row.ts b/src/panels/config/integrations/ha-config-entry-device-row.ts index f2654f61e3..6783240f46 100644 --- a/src/panels/config/integrations/ha-config-entry-device-row.ts +++ b/src/panels/config/integrations/ha-config-entry-device-row.ts @@ -1,9 +1,9 @@ import { - mdiCogOutline, mdiDelete, mdiDevices, mdiDotsVertical, mdiPencil, + mdiShapeOutline, mdiStopCircleOutline, mdiTransitConnectionVariant, } from "@mdi/js"; @@ -58,111 +58,118 @@ class HaConfigEntryDeviceRow extends LitElement { area ? area.name : undefined, ].filter(Boolean); - return html` - -
${computeDeviceNameDisplay(device, this.hass)} + return html` + +
${computeDeviceNameDisplay(device, this.hass)}
${supportingText.join(" • ")} ${supportingText.length && entities.length ? " • " : nothing} - ${ - entities.length - ? this.narrow - ? this.hass.localize( - "ui.panel.config.integrations.config_entry.entities", - { count: entities.length } - ) - : html`${this.hass.localize( - "ui.panel.config.integrations.config_entry.entities", - { count: entities.length } - )}` - : nothing - } - ${ - !this.narrow - ? html` - ` - : nothing - } - + ${!this.narrow + ? html` ` + : nothing}
- ${ - !this.narrow - ? html`` - : nothing - } - - + ${!this.narrow + ? html`` + : nothing} + + - ${ - this.narrow - ? html` - - ${this.hass.localize( - "ui.panel.config.integrations.config_entry.device.configure" - )} - ` - : nothing - } - - - - ${ - device.disabled_by && device.disabled_by !== "user" - ? this.hass.localize( - "ui.dialogs.device-registry-detail.enabled_cause", - { - type: this.hass.localize( - `ui.dialogs.device-registry-detail.type.${ - device.entry_type || "device" - }` - ), - cause: this.hass.localize( - `config_entry.disabled_by.${device.disabled_by}` - ), - } - ) - : device.disabled_by - ? this.hass.localize( - "ui.panel.config.integrations.config_entry.device.enable" - ) - : this.hass.localize( - "ui.panel.config.integrations.config_entry.device.disable" - ) - } - - - - ${ - this.entry.supports_remove_device - ? html` + + ${this.hass.localize( + "ui.panel.config.integrations.config_entry.device.edit" + )} + ` + : nothing} + ${entities.length + ? html` + - + ${this.hass.localize( - "ui.panel.config.integrations.config_entry.device.delete" + `ui.panel.config.integrations.config_entry.entities`, + { count: entities.length } )} - ` - : nothing - } + + + ` + : nothing} + + + + ${device.disabled_by && device.disabled_by !== "user" + ? this.hass.localize( + "ui.dialogs.device-registry-detail.enabled_cause", + { + type: this.hass.localize( + `ui.dialogs.device-registry-detail.type.${ + device.entry_type || "device" + }` + ), + cause: this.hass.localize( + `config_entry.disabled_by.${device.disabled_by}` + ), + } + ) + : device.disabled_by + ? this.hass.localize( + "ui.panel.config.integrations.config_entry.device.enable" + ) + : this.hass.localize( + "ui.panel.config.integrations.config_entry.device.disable" + )} + + ${this.entry.supports_remove_device + ? html` + + ${this.hass.localize( + "ui.panel.config.integrations.config_entry.device.delete" + )} + ` + : nothing}
`; } @@ -170,7 +177,7 @@ class HaConfigEntryDeviceRow extends LitElement { private _getEntities = (): EntityRegistryEntry[] => this.entities?.filter((entity) => entity.device_id === this.device.id); - private _handleConfigureDevice(ev: MouseEvent) { + private _handleEditDevice(ev: MouseEvent) { ev.stopPropagation(); // Prevent triggering the click handler on the list item showDeviceRegistryDetailDialog(this, { device: this.device, @@ -295,6 +302,8 @@ class HaConfigEntryDeviceRow extends LitElement { } ha-md-list-item { --md-list-item-leading-space: 56px; + --md-ripple-hover-color: transparent; + --md-ripple-pressed-color: transparent; } .disabled { opacity: 0.5; diff --git a/src/translations/en.json b/src/translations/en.json index 44a10730c9..6b144bf04e 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -5383,6 +5383,7 @@ "confirm_disable_title": "Disable device?", "confirm_disable_message": "Are you sure you want to disable {name} and all of its entities?", "configure": "Configure device", + "edit": "Edit device", "delete": "Remove device" }, "devices": "{count} {count, plural,\n one {device}\n other {devices}\n}",