Sort devices and services alphabetically in integration pages (#26231)

Co-authored-by: balloob <1444314+balloob@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This commit is contained in:
Copilot 2025-07-23 14:41:34 +02:00 committed by GitHub
parent 98ed3bdd4d
commit 20dab92ad8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -22,6 +22,8 @@ import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state } from "lit/decorators";
import { classMap } from "lit/directives/class-map"; import { classMap } from "lit/directives/class-map";
import memoizeOne from "memoize-one"; import memoizeOne from "memoize-one";
import { caseInsensitiveStringCompare } from "../../../common/string/compare";
import { computeDeviceNameDisplay } from "../../../common/entity/compute_device_name";
import { isDevVersion } from "../../../common/config/version"; import { isDevVersion } from "../../../common/config/version";
import { import {
deleteApplicationCredential, deleteApplicationCredential,
@ -491,18 +493,34 @@ class HaConfigEntryRow extends LitElement {
); );
private _getDevices = (): DeviceRegistryEntry[] => private _getDevices = (): DeviceRegistryEntry[] =>
Object.values(this.hass.devices).filter( Object.values(this.hass.devices)
(device) => .filter(
device.config_entries.includes(this.entry.entry_id) && (device) =>
device.entry_type !== "service" device.config_entries.includes(this.entry.entry_id) &&
); device.entry_type !== "service"
)
.sort((a, b) =>
caseInsensitiveStringCompare(
computeDeviceNameDisplay(a, this.hass),
computeDeviceNameDisplay(b, this.hass),
this.hass.locale.language
)
);
private _getServices = (): DeviceRegistryEntry[] => private _getServices = (): DeviceRegistryEntry[] =>
Object.values(this.hass.devices).filter( Object.values(this.hass.devices)
(device) => .filter(
device.config_entries.includes(this.entry.entry_id) && (device) =>
device.entry_type === "service" device.config_entries.includes(this.entry.entry_id) &&
); device.entry_type === "service"
)
.sort((a, b) =>
caseInsensitiveStringCompare(
computeDeviceNameDisplay(a, this.hass),
computeDeviceNameDisplay(b, this.hass),
this.hass.locale.language
)
);
private _toggleExpand() { private _toggleExpand() {
this._expanded = !this._expanded; this._expanded = !this._expanded;