Show integration bylines as hostnames

The Manage screen reduces instance URLs to the hostname, and Home Assistant uses the integration name as its title with the instance name as byline.
This commit is contained in:
raucao committed 2026-10-27 20:56:39 +04:00
1 parent ce5102cf39
commit 3909bd402a
3 files changed
+23 -10

No files matched your search

+7 -5
View File
@@ -1,6 +1,6 @@
import Service, { service } from '@ember/service';
import { INTEGRATIONS, integrationFor } from '../config/integrations';
import { displayUrl } from '../utils/display-url';
import { displayHost } from '../utils/display-host';
// Bridges the static integration registry with the live instance state owned by
// the `sites` (auth-based) and `bitcoin` services, so the Add/Manage screens can
@@ -236,10 +236,12 @@ export default class IntegrationsService extends Service {
this.instancesFor(integration.id).map((instance) => ({
...instance,
type: integration.id,
// Prefer a per-instance custom name (e.g. Home Assistant) over the
// shared registry label.
label: instance.name ?? integration.label,
byline: displayUrl(instance.url) || integration.description,
// Every row uses the shared registry label as its title. A per-instance
// custom name (Home Assistant) becomes the byline instead, so the title
// stays the integration name.
label: integration.label,
byline:
instance.name || displayHost(instance.url) || integration.description,
colorClass: integration.colorClass,
iconPath: integration.iconPath,
iconFill: integration.iconFill,
+16
View File
@@ -0,0 +1,16 @@
// Instance URLs are shown as bylines, where only the host identifies the
// instance. Keep the stored URL intact for network calls and reduce it to the
// hostname only for display.
export function displayHost(url) {
if (typeof url !== 'string' || !url) {
return '';
}
const value = /^[a-z][a-z0-9+.-]*:\/\//i.test(url) ? url : `https://${url}`;
try {
return new URL(value).hostname;
} catch {
return '';
}
}
-5
View File
@@ -1,5 +0,0 @@
// Instance URLs are shown as bylines, where the scheme is visual noise. Keep
// the stored URL intact for network calls and strip it only for display.
export function displayUrl(url) {
return typeof url === 'string' ? url.replace(/^https?:\/\//, '') : '';
}