From 5194067c6b46eaa184667a693e124a027862360e Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Tue, 9 Jun 2026 15:57:54 +0300 Subject: [PATCH] refactor(iot-hub): broaden count-based deep-link resolution Treat DEVICE, CALCULATED_FIELD, ALARM_RULE, and RULE_CHAIN as count-based item types in maybeOpenDeepLinkedItem: all four resolve via getInstalledItemCounts(this.config.type) and pass only { count } to openItemDetail. Singular-entity types (widgets, dashboards, solution templates) still go through resolveInstalledItem and pass { installed }. --- .../iot-hub/iot-hub-items-page.component.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.ts b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.ts index 5f68c586f3..90519f4e7f 100644 --- a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.ts +++ b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.ts @@ -136,13 +136,22 @@ export class TbIotHubItemsPageComponent implements OnInit { } history.replaceState({ ...history.state, openItem: undefined }, ''); - const isDevice = this.config.type === ItemType.DEVICE; - const resolution$: Observable<{ installed?: IotHubInstalledItem; count?: number }> = isDevice + // Types where multiple entities can be installed from the same + // IoT Hub item — we only care about the count per itemId + // (no singular installed entity to surface in the detail dialog). + const countBasedTypes: ReadonlySet = new Set([ + ItemType.DEVICE, + ItemType.CALCULATED_FIELD, + ItemType.ALARM_RULE, + ItemType.RULE_CHAIN + ]); + const isCountBased = countBasedTypes.has(this.config.type); + const resolution$: Observable<{ installed?: IotHubInstalledItem; count?: number }> = isCountBased ? this.iotHubApiService - .getInstalledItemCounts(ItemType.DEVICE, { ignoreLoading: true }) - .pipe(map(counts => ({ count: counts[openItem.version.itemId] || 0 }))) + .getInstalledItemCounts(this.config.type, { ignoreLoading: true }) + .pipe(map(counts => ({ count: counts[openItem.version.itemId] || 0 }))) : this.resolveInstalledItem(openItem.version) - .pipe(map(installed => ({ installed: installed ?? undefined }))); + .pipe(map(installed => ({ installed: installed ?? undefined }))); resolution$.subscribe(({ installed, count }) => { this.iotHubActions.openItemDetail(