From f9ba9098fd1946e0bfa8dc699af736c43f044537 Mon Sep 17 00:00:00 2001 From: dshvaika Date: Fri, 15 May 2026 14:01:49 +0300 Subject: [PATCH] fix(iot-hub): alarm rule prompt + open-detail route on install success MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * `selectEntityConfig` did not have an `ALARM_RULE` entry. The install dialog routes both `CALCULATED_FIELD` and `ALARM_RULE` to the `select-entity` step, but the per-`ItemType` config map (introduced by the CE 4.2 rule chain work) only had `CALCULATED_FIELD` and `RULE_CHAIN` entries. The alarm rule prompt paragraph silently dropped and the picker bindings had no config to read from. Add an `ALARM_RULE` entry with the same allow-list as CF and the new i18n key `iot-hub.select-entity-for-alarm-rule`. * `resolveEntityDetailsUrl` returned `/calculatedFields/{id}` for ALARM_RULE installs because the `ITEM_TYPE_TO_ENTITY_TYPE` map sent `ALARM_RULE` through `EntityType.CALCULATED_FIELD`. Alarm rules share the CalculatedField data structure on the backend but live at `/alarms/alarm-rules/{id}` in the UI. Resolve the URL directly for ALARM_RULE before falling through to the entity-type map, and drop the misleading `'ALARM_RULE' → CALCULATED_FIELD` entry / switch case. --- .../home/components/iot-hub/iot-hub-components.models.ts | 8 ++++++-- .../iot-hub/iot-hub-install-dialog.component.ts | 6 ++++++ ui-ngx/src/assets/locale/locale.constant-en_US.json | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-components.models.ts b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-components.models.ts index 1233dfa89c..f5e23cc6a0 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-components.models.ts +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-components.models.ts @@ -22,7 +22,6 @@ export const ITEM_TYPE_TO_ENTITY_TYPE: Record = { 'WIDGET': EntityType.WIDGET_TYPE, 'DASHBOARD': EntityType.DASHBOARD, 'CALCULATED_FIELD': EntityType.CALCULATED_FIELD, - 'ALARM_RULE': EntityType.CALCULATED_FIELD, 'RULE_CHAIN': EntityType.RULE_CHAIN, 'DEVICE': EntityType.DEVICE_PROFILE }; @@ -31,6 +30,12 @@ export function resolveEntityDetailsUrl(descriptor: IotHubInstalledItemDescripto if (!descriptor) { return null; } + // Alarm rules share the CalculatedField data structure but live at a different + // route, so resolve their URL directly instead of going through the entity-type map. + if (itemType === 'ALARM_RULE' && descriptor.type === 'ALARM_RULE') { + const id = descriptor.calculatedFieldId?.id; + return id ? `/alarms/alarm-rules/${id}` : null; + } const entityType = ITEM_TYPE_TO_ENTITY_TYPE[itemType]; if (!entityType) { return null; @@ -40,7 +45,6 @@ export function resolveEntityDetailsUrl(descriptor: IotHubInstalledItemDescripto case 'WIDGET': entityId = descriptor.widgetTypeId?.id; break; case 'DASHBOARD': entityId = descriptor.dashboardId?.id; break; case 'CALCULATED_FIELD': entityId = descriptor.calculatedFieldId?.id; break; - case 'ALARM_RULE': entityId = descriptor.calculatedFieldId?.id; break; case 'RULE_CHAIN': entityId = descriptor.ruleChainId?.id; break; } if (!entityId) { diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-install-dialog.component.ts b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-install-dialog.component.ts index 138c337e62..ee4565c0a8 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-install-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-install-dialog.component.ts @@ -87,6 +87,12 @@ export class TbIotHubInstallDialogComponent extends DialogComponent