1
0
mirror of https://github.com/home-assistant/frontend.git synced 2026-04-17 15:45:43 +01:00

Sort disabled and ignored integrations by name, translate disabled domains (#30230)

* Sort Disabled and Ignored integrations by name

* Localise disabled integration domains
This commit is contained in:
Aidan Timson
2026-03-19 15:03:30 +00:00
committed by GitHub
parent cf50db350f
commit 1bbfb79ddb
2 changed files with 51 additions and 5 deletions

View File

@@ -88,6 +88,36 @@ const groupByIntegration = (
});
return result;
};
const getLocalizedDomainName = (
entry: ConfigEntryExtended,
manifests: Record<string, IntegrationManifest>,
localize: HomeAssistant["localize"]
): string =>
entry.localized_domain_name && entry.localized_domain_name !== entry.domain
? entry.localized_domain_name
: domainToName(localize, entry.domain, manifests[entry.domain]);
const sortConfigEntriesByName = (
entries: ConfigEntryExtended[],
manifests: Record<string, IntegrationManifest>,
localize: HomeAssistant["localize"],
language: string
): ConfigEntryExtended[] =>
entries.sort(
(entryA, entryB) =>
caseInsensitiveStringCompare(
getLocalizedDomainName(entryA, manifests, localize),
getLocalizedDomainName(entryB, manifests, localize),
language
) ||
caseInsensitiveStringCompare(
entryA.title || entryA.domain,
entryB.title || entryB.domain,
language
)
);
@customElement("ha-config-integrations-dashboard")
class HaConfigIntegrationsDashboard extends KeyboardShortcutMixin(
SubscribeMixin(LitElement)
@@ -202,7 +232,11 @@ class HaConfigIntegrationsDashboard extends KeyboardShortcutMixin(
const nonConfigEntry: ConfigEntryExtended[] = [...domains].map(
(domain) => ({
domain,
localized_domain_name: domainToName(localize, domain),
localized_domain_name: domainToName(
localize,
domain,
manifests[domain]
),
title: domain,
source: "yaml",
state: "loaded",
@@ -269,8 +303,18 @@ class HaConfigIntegrationsDashboard extends KeyboardShortcutMixin(
this.hass.locale.language
)
),
ignored,
disabled,
sortConfigEntriesByName(
ignored,
this._manifests,
this.hass.localize,
this.hass.locale.language
),
sortConfigEntriesByName(
disabled,
this._manifests,
this.hass.localize,
this.hass.locale.language
),
];
}
);

View File

@@ -46,8 +46,10 @@ export class HaIntegrationActionCard extends LitElement {
/>
<h2>${this.label}</h2>
<h3>
${this.localizedDomainName ||
domainToName(this.hass.localize, this.domain, this.manifest)}
${this.localizedDomainName &&
this.localizedDomainName !== this.domain
? this.localizedDomainName
: domainToName(this.hass.localize, this.domain, this.manifest)}
</h3>
</div>
<div class="filler"></div>