From c1d8d73f2a6713d0ebaf07ac8d8837017b284a05 Mon Sep 17 00:00:00 2001 From: dpinkevych Date: Mon, 16 Nov 2026 11:59:57 +0200 Subject: [PATCH 1/8] IoT Hub device package delete: a device profile devices use stays, with what it refers to, and the dialog says so (PROD-9340) --- .../service/iot_hub/DefaultIotHubService.java | 85 ++++++++++++++++++- .../iot_hub/InstalledItemKeptEntities.java | 10 ++- ...DefaultDevicePackageUpdateServiceTest.java | 2 +- .../iot_hub/DefaultIotHubServiceTest.java | 83 ++++++++++++++++++ .../iot-hub-delete-dialog.component.ts | 24 ++++-- .../iot-hub/iot-hub-installed-item.models.ts | 7 +- .../assets/locale/locale.constant-en_US.json | 1 + 7 files changed, 199 insertions(+), 13 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/service/iot_hub/DefaultIotHubService.java b/application/src/main/java/org/thingsboard/server/service/iot_hub/DefaultIotHubService.java index ddbe8ec5d7..ff13b6378a 100644 --- a/application/src/main/java/org/thingsboard/server/service/iot_hub/DefaultIotHubService.java +++ b/application/src/main/java/org/thingsboard/server/service/iot_hub/DefaultIotHubService.java @@ -12,6 +12,7 @@ import org.springframework.stereotype.Service; import org.thingsboard.common.util.ExceptionUtil; import org.thingsboard.common.util.JacksonUtil; import org.thingsboard.server.common.data.Customer; +import org.thingsboard.server.common.data.Device; import org.thingsboard.server.common.data.DeviceProfile; import org.thingsboard.server.common.data.EntityType; import org.thingsboard.server.common.data.asset.AssetProfile; @@ -91,8 +92,10 @@ import java.util.HexFormat; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.UUID; +import java.util.stream.Stream; @Service @TbCoreComponent @@ -720,7 +723,9 @@ public class DefaultIotHubService implements IotHubService { /** * Deletes what a device package created, except the entities another installed device package * also uses (e.g. an integration it took over with Overwrite): deleting those would break that package, - * and the ones the user had before and the package took as they were (use existing). + * and the ones the user had before and the package took as they were (use existing). A device profile that devices + * still use stays too, e.g. with the devices a LoRaWAN integration created, and so does what it refers to that the + * package created: TB deletes neither. * A kept integration loses the metadata entries the package added. */ private void deleteDevicePackageEntities(TenantId tenantId, IotHubInstalledItemId installedItemId, @@ -737,6 +742,8 @@ public class DefaultIotHubService implements IotHubService { List ordered = new ArrayList<>(createdEntityIds); Collections.reverse(ordered); ordered.sort(Comparator.comparingInt(id -> DELETE_ORDER.getOrDefault(id.getEntityType(), DELETE_ORDER.size()))); + // What a kept profile refers to: its default rule chain and dashboard, which come after it in the order + Set referencedByKeptProfiles = new HashSet<>(); for (EntityId entityId : ordered) { if (usedExisting.contains(entityId.getId())) { log.info("[{}] Kept {} {}: the package took it as it was", tenantId, entityId.getEntityType(), entityId.getId()); @@ -749,6 +756,17 @@ public class DefaultIotHubService implements IotHubService { removeIntegrationMetadata(tenantId, entityId, descriptor, otherPackages); continue; } + if (referencedByKeptProfiles.contains(entityId.getId())) { + log.info("[{}] Kept {} {}: a kept device profile refers to it", tenantId, entityId.getEntityType(), entityId.getId()); + continue; + } + // The package's own devices are deleted by now; the ones left came from elsewhere, e.g. a LoRaWAN integration + long devices = countProfileDevices(tenantId, entityId, Set.of()); + if (devices > 0) { + log.info("[{}] Kept device profile {}: devices use it ({})", tenantId, entityId.getId(), devices); + profileReferences(tenantId, entityId).forEach(reference -> referencedByKeptProfiles.add(reference.getId())); + continue; + } try { deleteDevicePackageEntity(tenantId, entityId, user); } catch (Exception e) { @@ -811,16 +829,27 @@ public class DefaultIotHubService implements IotHubService { throw new IllegalArgumentException("Installed item not found"); } List kept = new ArrayList<>(); + List keptForDevices = new ArrayList<>(); Set usedByItems = new HashSet<>(); int usedExistingCount = 0; + long devicesCount = 0; if (installedItem.getDescriptor() instanceof DeviceInstalledItemDescriptor dd && dd.getCreatedEntityIds() != null) { Set usedExisting = usedExistingIds(dd); Map> usedByOtherPackages = findEntitiesOfOtherDevicePackages(tenantId, installedItemId, new ArrayList<>()); + // The delete removes these before the profiles, so they don't keep a profile; a kept device does + Set deletedDevices = new HashSet<>(); + dd.getCreatedEntityIds().stream() + .filter(id -> id.getEntityType() == EntityType.DEVICE && !usedExisting.contains(id.getId()) && !usedByOtherPackages.containsKey(id.getId())) + .forEach(id -> deletedDevices.add(id.getId())); + Set created = new HashSet<>(); + dd.getCreatedEntityIds().forEach(id -> created.add(id.getId())); + Set keptIds = new HashSet<>(); for (EntityId entityId : dd.getCreatedEntityIds()) { Set usedBy = usedByOtherPackages.get(entityId.getId()); boolean taken = usedExisting.contains(entityId.getId()); if (usedBy != null || taken) { - kept.add(new InstalledItemKeptEntities.KeptEntity(entityId, entityService.fetchEntityName(tenantId, entityId).orElse(null))); + kept.add(keptEntity(tenantId, entityId)); + keptIds.add(entityId.getId()); } if (usedBy != null) { usedByItems.addAll(usedBy); @@ -829,8 +858,58 @@ public class DefaultIotHubService implements IotHubService { usedExistingCount++; } } + for (EntityId entityId : dd.getCreatedEntityIds()) { + long devices = keptIds.contains(entityId.getId()) ? 0 : countProfileDevices(tenantId, entityId, deletedDevices); + if (devices == 0) { + continue; + } + keptForDevices.add(keptEntity(tenantId, entityId)); + keptIds.add(entityId.getId()); + devicesCount += devices; + // What the profile refers to stays with it + for (EntityId reference : profileReferences(tenantId, entityId)) { + if (created.contains(reference.getId()) && keptIds.add(reference.getId())) { + keptForDevices.add(keptEntity(tenantId, reference)); + } + } + } + } + return new InstalledItemKeptEntities(kept, usedByItems.size(), usedExistingCount, keptForDevices, devicesCount); + } + + private InstalledItemKeptEntities.KeptEntity keptEntity(TenantId tenantId, EntityId entityId) { + return new InstalledItemKeptEntities.KeptEntity(entityId, entityService.fetchEntityName(tenantId, entityId).orElse(null)); + } + + /** The default rule chains and dashboard of the device profile {@code profileId}: TB doesn't delete them while it refers to them. */ + private List profileReferences(TenantId tenantId, EntityId profileId) { + DeviceProfile profile = deviceProfileService.findDeviceProfileById(tenantId, new DeviceProfileId(profileId.getId())); + List references = new ArrayList<>(); + if (profile != null) { + Stream.of(profile.getDefaultRuleChainId(), profile.getDefaultEdgeRuleChainId(), profile.getDefaultDashboardId()) + .filter(Objects::nonNull) + .forEach(references::add); + } + return references; + } + + /** + * How many devices use the device profile {@code entityId}, apart from {@code excludedDevices}; 0 for another entity. + * TB doesn't delete a profile that devices use. + */ + private long countProfileDevices(TenantId tenantId, EntityId entityId, Set excludedDevices) { + if (entityId.getEntityType() != EntityType.DEVICE_PROFILE) { + return 0; + } + DeviceProfileId profileId = new DeviceProfileId(entityId.getId()); + long count = deviceService.findDeviceIdsByTenantIdAndDeviceProfileId(tenantId, profileId, new PageLink(1)).getTotalElements(); + for (UUID deviceId : excludedDevices) { + Device device = deviceService.findDeviceById(tenantId, new DeviceId(deviceId)); + if (device != null && profileId.equals(device.getDeviceProfileId())) { + count--; + } } - return new InstalledItemKeptEntities(kept, usedByItems.size(), usedExistingCount); + return Math.max(count, 0); } /** The entities the package took as they were at install (use existing); none for installs before 4.4.1 kept them. */ diff --git a/application/src/main/java/org/thingsboard/server/service/iot_hub/InstalledItemKeptEntities.java b/application/src/main/java/org/thingsboard/server/service/iot_hub/InstalledItemKeptEntities.java index ad517c5327..4d21db6b10 100644 --- a/application/src/main/java/org/thingsboard/server/service/iot_hub/InstalledItemKeptEntities.java +++ b/application/src/main/java/org/thingsboard/server/service/iot_hub/InstalledItemKeptEntities.java @@ -9,7 +9,10 @@ import org.thingsboard.server.common.data.id.EntityId; import java.util.List; -/** What deleting an installed item keeps: what other installed items use too, and what the user had before it. */ +/** + * What deleting an installed item keeps: what other installed items use too, what the user had before it, and the device + * profiles devices still use (a LoRaWAN integration creates its devices on the first uplink, not the package). + */ @Data @NoArgsConstructor @AllArgsConstructor @@ -20,6 +23,11 @@ public class InstalledItemKeptEntities { private int usedByItemsCount; // How many of the kept entities the user had before and the package took as they were (use existing) private int usedExistingCount; + // The package's device profiles that devices use and what they refer to (default rule chain, dashboard): TB deletes + // neither. Apart from entities, which an update reads as shared with other packages + private List keptForDevices; + // How many devices use those profiles + private long devicesCount; @Data @NoArgsConstructor diff --git a/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultDevicePackageUpdateServiceTest.java b/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultDevicePackageUpdateServiceTest.java index 38595a0c71..82f5f6c1c9 100644 --- a/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultDevicePackageUpdateServiceTest.java +++ b/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultDevicePackageUpdateServiceTest.java @@ -308,7 +308,7 @@ class DefaultDevicePackageUpdateServiceTest { Dashboard shared = dashboard(9L); DevicePackageEntities.Snapshot snapshot = new DevicePackageEntities.Snapshot(shared, null); when(packageEntities.load(tenantId, dashboardId)).thenReturn(snapshot); - when(iotHubService.findKeptEntities(tenantId, installedItem.getId())).thenReturn(new InstalledItemKeptEntities(List.of(), 0, 0)); + when(iotHubService.findKeptEntities(tenantId, installedItem.getId())).thenReturn(new InstalledItemKeptEntities(List.of(), 0, 0, List.of(), 0)); // This package recorded the dashboard as it left it; the other one overwrote it since and recorded the new one ObjectNode own = stateOf(dashboardId, "created").put("checksum", "as-this-package-left-it"); ((DeviceInstalledItemDescriptor) installedItem.getDescriptor()).setInstallState(Map.of("Dashboard", own)); diff --git a/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultIotHubServiceTest.java b/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultIotHubServiceTest.java index a81368450c..2ef9437115 100644 --- a/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultIotHubServiceTest.java +++ b/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultIotHubServiceTest.java @@ -22,6 +22,7 @@ import org.thingsboard.server.common.data.id.DeviceProfileId; import org.thingsboard.server.common.data.id.EntityId; import org.thingsboard.server.common.data.id.IntegrationId; import org.thingsboard.server.common.data.id.IotHubInstalledItemId; +import org.thingsboard.server.common.data.id.RuleChainId; import org.thingsboard.server.common.data.id.TenantId; import org.thingsboard.server.common.data.integration.Integration; import org.thingsboard.server.common.data.iot_hub.DeviceInstalledItemDescriptor; @@ -39,10 +40,12 @@ import org.thingsboard.server.dao.device.DeviceService; import org.thingsboard.server.dao.entity.EntityService; import org.thingsboard.server.dao.integration.IntegrationService; import org.thingsboard.server.dao.iot_hub.IotHubInstalledItemService; +import org.thingsboard.server.dao.rule.RuleChainService; import org.thingsboard.server.service.entitiy.dashboard.TbDashboardService; import org.thingsboard.server.service.entitiy.converter.TbConverterService; import org.thingsboard.server.service.entitiy.device.TbDeviceService; import org.thingsboard.server.service.entitiy.device.profile.TbDeviceProfileService; +import org.thingsboard.server.service.rule.TbRuleChainService; import org.thingsboard.server.service.security.model.SecurityUser; import java.util.List; @@ -95,6 +98,10 @@ class DefaultIotHubServiceTest { private ConverterService converterService; @Mock private TbConverterService tbConverterService; + @Mock + private RuleChainService ruleChainService; + @Mock + private TbRuleChainService tbRuleChainService; @Spy @InjectMocks @@ -474,6 +481,7 @@ class DefaultIotHubServiceTest { when(iotHubInstalledItemService.findByTenantId(eq(tenantId), eq(List.of("DEVICE")), isNull(), any())) .thenReturn(new PageData<>(List.of(deleted), 1, 1, false)); when(deviceProfileService.findDeviceProfileById(tenantId, profile.getId())).thenReturn(profile); + noDevices(profile.getId()); when(dashboardService.findDashboardById(tenantId, dashboard.getId())).thenReturn(dashboard); when(integrationService.findIntegrationById(tenantId, integration.getId())).thenReturn(integration); when(converterService.findConverterById(tenantId, converter.getId())).thenReturn(converter); @@ -736,6 +744,81 @@ class DefaultIotHubServiceTest { return integration; } + @Test + void findKeptEntities_devicePackage_namesTheProfileDevicesUseAndItsRuleChain_apartFromTheShared() { + DeviceProfile profile = new DeviceProfile(new DeviceProfileId(UUID.randomUUID())); + RuleChainId ruleChainId = new RuleChainId(UUID.randomUUID()); + profile.setDefaultRuleChainId(ruleChainId); + Device packageDevice = new Device(new DeviceId(UUID.randomUUID())); + packageDevice.setDeviceProfileId(profile.getId()); + IotHubInstalledItem checked = devicePackage(ruleChainId, profile.getId(), packageDevice.getId()); + when(iotHubInstalledItemService.findById(tenantId, checked.getId())).thenReturn(checked); + when(iotHubInstalledItemService.findByTenantId(eq(tenantId), eq(List.of("DEVICE")), isNull(), any())) + .thenReturn(new PageData<>(List.of(checked), 1, 1, false)); + // 3 devices on the profile: the package's own, which the delete removes first, and 2 the integration created + when(deviceService.findDeviceIdsByTenantIdAndDeviceProfileId(eq(tenantId), eq(profile.getId()), any())) + .thenReturn(new PageData<>(List.of(), 3, 3, true)); + when(deviceService.findDeviceById(tenantId, packageDevice.getId())).thenReturn(packageDevice); + when(deviceProfileService.findDeviceProfileById(tenantId, profile.getId())).thenReturn(profile); + when(entityService.fetchEntityName(tenantId, profile.getId())).thenReturn(Optional.of("smartico-l2-lr")); + when(entityService.fetchEntityName(tenantId, ruleChainId)).thenReturn(Optional.of("Smartico L2-LR")); + + InstalledItemKeptEntities kept = service.findKeptEntities(tenantId, checked.getId()); + + // An update reads entities as shared with other packages: the profile is not among them + assertThat(kept.getEntities()).isEmpty(); + assertThat(kept.getKeptForDevices()).containsExactly( + new InstalledItemKeptEntities.KeptEntity(profile.getId(), "smartico-l2-lr"), + new InstalledItemKeptEntities.KeptEntity(ruleChainId, "Smartico L2-LR")); + assertThat(kept.getDevicesCount()).isEqualTo(2); + } + + @Test + void findKeptEntities_devicePackage_aKeptDeviceKeepsItsProfile() { + DeviceProfileId profileId = new DeviceProfileId(UUID.randomUUID()); + DeviceId sharedDeviceId = new DeviceId(UUID.randomUUID()); + IotHubInstalledItem checked = devicePackage(profileId, sharedDeviceId); + IotHubInstalledItem other = devicePackage(sharedDeviceId); + when(iotHubInstalledItemService.findById(tenantId, checked.getId())).thenReturn(checked); + when(iotHubInstalledItemService.findByTenantId(eq(tenantId), eq(List.of("DEVICE")), isNull(), any())) + .thenReturn(new PageData<>(List.of(checked, other), 1, 2, false)); + // The only device on the profile is the one another package uses: the delete keeps it, so it keeps the profile + when(deviceService.findDeviceIdsByTenantIdAndDeviceProfileId(eq(tenantId), eq(profileId), any())) + .thenReturn(new PageData<>(List.of(sharedDeviceId), 1, 1, false)); + + InstalledItemKeptEntities kept = service.findKeptEntities(tenantId, checked.getId()); + + assertThat(kept.getKeptForDevices()).extracting(InstalledItemKeptEntities.KeptEntity::getEntityId).containsExactly(profileId); + assertThat(kept.getDevicesCount()).isEqualTo(1); + } + + @Test + void deleteInstalledItem_devicePackage_keepsTheProfileDevicesUseAndItsRuleChain() throws Exception { + mockTenant(); + DeviceProfile profile = new DeviceProfile(new DeviceProfileId(UUID.randomUUID())); + RuleChainId ruleChainId = new RuleChainId(UUID.randomUUID()); + profile.setDefaultRuleChainId(ruleChainId); + IotHubInstalledItem deleted = devicePackage(ruleChainId, profile.getId()); + when(iotHubInstalledItemService.findById(tenantId, deleted.getId())).thenReturn(deleted); + when(iotHubInstalledItemService.findByTenantId(eq(tenantId), eq(List.of("DEVICE")), isNull(), any())) + .thenReturn(new PageData<>(List.of(deleted), 1, 1, false)); + when(deviceService.findDeviceIdsByTenantIdAndDeviceProfileId(eq(tenantId), eq(profile.getId()), any())) + .thenReturn(new PageData<>(List.of(new DeviceId(UUID.randomUUID())), 1, 1, false)); + when(deviceProfileService.findDeviceProfileById(tenantId, profile.getId())).thenReturn(profile); + + service.deleteInstalledItem(user, deleted.getId()); + + verify(tbDeviceProfileService, never()).delete(any(), any()); + verify(ruleChainService, never()).findRuleChainById(any(), any()); + verify(tbRuleChainService, never()).delete(any(), any()); + verify(iotHubInstalledItemService).deleteById(tenantId, deleted.getId()); + } + + private void noDevices(DeviceProfileId profileId) { + when(deviceService.findDeviceIdsByTenantIdAndDeviceProfileId(eq(tenantId), eq(profileId), any())) + .thenReturn(new PageData<>(List.of(), 0, 0, false)); + } + private IotHubInstalledItem devicePackage(EntityId... createdEntityIds) { DeviceInstalledItemDescriptor descriptor = new DeviceInstalledItemDescriptor(); descriptor.setCreatedEntityIds(List.of(createdEntityIds)); diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.ts b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.ts index 88bdf96fff..5366e63dfc 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.ts @@ -46,13 +46,23 @@ export class TbIotHubDeleteDialogComponent extends DialogComponent ({ id: entity.entityId as EntityId, name: entity.name })); - // Kept because other packages use them, because the user had them before the package, or both - const reasonKey = !kept.usedExistingCount ? 'iot-hub.remove-kept-used' : - !kept.usedByItemsCount ? 'iot-hub.remove-kept-own' : 'iot-hub.remove-kept-own-or-used'; - this.keptTitle = this.translate.instant('iot-hub.remove-kept-title', { kept: kept.entities.length }); - this.keptReason = this.translate.instant(reasonKey, { kept: kept.entities.length }); + const shared = kept?.entities ?? []; + const withDevices = kept?.keptForDevices ?? []; + if (shared.length || withDevices.length) { + this.keptReferences = [...shared, ...withDevices].map(entity => ({ id: entity.entityId as EntityId, name: entity.name })); + const reasons: string[] = []; + if (shared.length) { + // Kept because other packages use them, because the user had them before the package, or both + const reasonKey = !kept.usedExistingCount ? 'iot-hub.remove-kept-used' : + !kept.usedByItemsCount ? 'iot-hub.remove-kept-own' : 'iot-hub.remove-kept-own-or-used'; + reasons.push(this.translate.instant(reasonKey, { kept: shared.length })); + } + if (withDevices.length) { + const profiles = withDevices.filter(entity => entity.entityId.entityType === 'DEVICE_PROFILE').length; + reasons.push(this.translate.instant('iot-hub.remove-kept-devices', { profiles, devices: kept.devicesCount ?? 0 })); + } + this.keptTitle = this.translate.instant('iot-hub.remove-kept-title', { kept: shared.length + withDevices.length }); + this.keptReason = reasons.join(' '); } } diff --git a/ui-ngx/src/app/shared/models/iot-hub/iot-hub-installed-item.models.ts b/ui-ngx/src/app/shared/models/iot-hub/iot-hub-installed-item.models.ts index 07fac4bf63..5b7aad53b4 100644 --- a/ui-ngx/src/app/shared/models/iot-hub/iot-hub-installed-item.models.ts +++ b/ui-ngx/src/app/shared/models/iot-hub/iot-hub-installed-item.models.ts @@ -159,7 +159,7 @@ export interface ItemPublishedVersionInfo { publishedVersion: string; } -/** An entity that deleting an installed item keeps, because other installed items use it too. */ +/** An entity that deleting an installed item keeps. */ export interface IotHubKeptEntity { entityId: { id: string; entityType: string }; name: string; @@ -170,6 +170,11 @@ export interface IotHubInstalledItemKeptEntities { usedByItemsCount: number; // Of the kept entities, the ones the user had before and the package took as they were usedExistingCount: number; + // The package's device profiles that devices use (e.g. the ones a LoRaWAN integration created) and what they refer to: + // TB deletes neither. Absent from an older backend + keptForDevices?: IotHubKeptEntity[]; + // How many devices use those profiles + devicesCount?: number; } export interface IotHubInstalledItem extends BaseData<{id: string}> { diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 15ca6ed759..9d6c9e6726 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -6449,6 +6449,7 @@ "remove-kept-title": "{ kept, plural, =1 {This entity will not be removed} other {These entities will not be removed} }", "remove-kept-used": "Other installed packages use { kept, plural, =1 {it} other {them} }.", "remove-kept-own": "You had { kept, plural, =1 {it} other {them} } before the package was installed.", + "remove-kept-devices": "{ devices, plural, =1 {1 device still uses} other {# devices still use} } { profiles, plural, =1 {the device profile} other {the device profiles} }, and ThingsBoard doesn't remove a profile in use. Delete the devices first to remove it.", "remove-kept-own-or-used": "You had { kept, plural, =1 {it} other {them} } before the package was installed, or other installed packages use { kept, plural, =1 {it} other {them} }.", "remove-desc-solution-template": "Removing this solution template will also remove all created entities including dashboards, rule chains, devices, and other associated resources within your tenant", "remove-anyway": "Remove anyway", From f6067b469e7eb26df15b057093addcdd4dd979d7 Mon Sep 17 00:00:00 2001 From: dpinkevych Date: Mon, 16 Nov 2026 12:30:36 +0200 Subject: [PATCH 2/8] IoT Hub device package delete: the dialog says why a profile devices use stays, with no advice to delete the devices (PROD-9340 review) --- .../components/iot-hub/iot-hub-delete-dialog.component.ts | 4 +++- ui-ngx/src/assets/locale/locale.constant-en_US.json | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.ts b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.ts index 5366e63dfc..f1910d662d 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.ts @@ -58,8 +58,10 @@ export class TbIotHubDeleteDialogComponent extends DialogComponent entity.entityId.entityType === 'DEVICE_PROFILE').length; - reasons.push(this.translate.instant('iot-hub.remove-kept-devices', { profiles, devices: kept.devicesCount ?? 0 })); + const key = withDevices.length > profiles ? 'iot-hub.remove-kept-devices-with-references' : 'iot-hub.remove-kept-devices'; + reasons.push(this.translate.instant(key, { profiles, devices: kept.devicesCount ?? 0 })); } this.keptTitle = this.translate.instant('iot-hub.remove-kept-title', { kept: shared.length + withDevices.length }); this.keptReason = reasons.join(' '); diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 9d6c9e6726..07d90f4b3a 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -6449,7 +6449,8 @@ "remove-kept-title": "{ kept, plural, =1 {This entity will not be removed} other {These entities will not be removed} }", "remove-kept-used": "Other installed packages use { kept, plural, =1 {it} other {them} }.", "remove-kept-own": "You had { kept, plural, =1 {it} other {them} } before the package was installed.", - "remove-kept-devices": "{ devices, plural, =1 {1 device still uses} other {# devices still use} } { profiles, plural, =1 {the device profile} other {the device profiles} }, and ThingsBoard doesn't remove a profile in use. Delete the devices first to remove it.", + "remove-kept-devices": "{ devices, plural, =1 {1 device still uses} other {# devices still use} } { profiles, plural, =1 {the device profile, so it stays} other {the device profiles, so they stay} }.", + "remove-kept-devices-with-references": "{ devices, plural, =1 {1 device still uses} other {# devices still use} } { profiles, plural, =1 {the device profile, so it stays with the entities it uses} other {the device profiles, so they stay with the entities they use} }.", "remove-kept-own-or-used": "You had { kept, plural, =1 {it} other {them} } before the package was installed, or other installed packages use { kept, plural, =1 {it} other {them} }.", "remove-desc-solution-template": "Removing this solution template will also remove all created entities including dashboards, rule chains, devices, and other associated resources within your tenant", "remove-anyway": "Remove anyway", From f8b8fa18e5c826fcd82f8f9bdea14ed1bf70ca40 Mon Sep 17 00:00:00 2001 From: dpinkevych Date: Mon, 16 Nov 2026 13:18:52 +0200 Subject: [PATCH 3/8] IoT Hub device package delete: kept entities in one list, a group per reason (PROD-9340 review) --- .../iot-hub-delete-dialog.component.html | 14 +++++-- .../iot-hub-delete-dialog.component.scss | 36 ++++++++++++++++++ .../iot-hub-delete-dialog.component.ts | 37 +++++++++---------- .../assets/locale/locale.constant-en_US.json | 3 +- 4 files changed, 65 insertions(+), 25 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.html b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.html index f7bcce1201..4b0d6fc93c 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.html @@ -8,13 +8,21 @@

{{ 'iot-hub.remove-confirm-title' | translate:{ name: data.itemName } }}

{{ description }}

- @if (keptReferences) { + @if (keptGroups.length) {
info_outline
{{ keptTitle }}
-
{{ keptReason }}
- + +
+ @for (group of keptGroups; track group.reason; let first = $first) { + @if (!first) { +
+ } +
{{ group.reason }}
+ + } +
} diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.scss b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.scss index 63fa684164..15bbef3f08 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.scss +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.scss @@ -23,3 +23,39 @@ color: rgba(0, 0, 0, 0.54); margin: 0; } + +// The kept entities: one white list as tb-image-references draws it, a group per reason +.tb-iot-hub-kept-groups { + display: flex; + flex-direction: column; + gap: 4px; + padding: 8px 0; + border-radius: 4px; + background: #fff; + border: 1px solid color-mix(in srgb, var(--tb-primary-500) 40%, transparent); + + // The groups share the outer border: no border of its own around each group's list + ::ng-deep tb-image-references table.tb-entities-list-table { + padding: 0 10px 0 4px !important; + background: transparent !important; + + &:before { + display: none !important; + } + } +} + +.tb-iot-hub-kept-reason { + padding: 4px 12px 2px; + font-size: 12px; + font-weight: 500; + line-height: 16px; + letter-spacing: 0.4px; + color: rgba(0, 0, 0, 0.6); +} + +.tb-iot-hub-kept-divider { + height: 1px; + margin: 6px 12px 4px; + background: rgba(0, 0, 0, 0.08); +} diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.ts b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.ts index f1910d662d..2fe865940e 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.ts @@ -7,7 +7,7 @@ import { Router } from '@angular/router'; import { Store } from '@ngrx/store'; import { AppState } from '@core/core.state'; import { DialogComponent } from '@shared/components/dialog.component'; -import { IotHubInstalledItemKeptEntities } from 'src/app/shared/models/iot-hub/iot-hub-installed-item.models'; +import { IotHubInstalledItemKeptEntities, IotHubKeptEntity } from 'src/app/shared/models/iot-hub/iot-hub-installed-item.models'; import { IotHubApiService } from '@core/http/iot-hub-api.service'; import { TranslateService } from '@ngx-translate/core'; import { ResourceReferences } from '@shared/models/resource.models'; @@ -30,10 +30,10 @@ export class TbIotHubDeleteDialogComponent extends DialogComponent, @@ -48,23 +48,20 @@ export class TbIotHubDeleteDialogComponent extends DialogComponent ({ id: entity.entityId as EntityId, name: entity.name })); - const reasons: string[] = []; - if (shared.length) { - // Kept because other packages use them, because the user had them before the package, or both - const reasonKey = !kept.usedExistingCount ? 'iot-hub.remove-kept-used' : - !kept.usedByItemsCount ? 'iot-hub.remove-kept-own' : 'iot-hub.remove-kept-own-or-used'; - reasons.push(this.translate.instant(reasonKey, { kept: shared.length })); - } - if (withDevices.length) { - // The profiles devices use, and what they use (default rule chains, dashboard), which stays with them - const profiles = withDevices.filter(entity => entity.entityId.entityType === 'DEVICE_PROFILE').length; - const key = withDevices.length > profiles ? 'iot-hub.remove-kept-devices-with-references' : 'iot-hub.remove-kept-devices'; - reasons.push(this.translate.instant(key, { profiles, devices: kept.devicesCount ?? 0 })); - } + const references = (entities: IotHubKeptEntity[]): ResourceReferences => + entities.map(entity => ({ id: entity.entityId as EntityId, name: entity.name })); + if (shared.length) { + // Kept because other packages use them, because the user had them before the package, or both + const reasonKey = !kept.usedExistingCount ? 'iot-hub.remove-kept-used' : + !kept.usedByItemsCount ? 'iot-hub.remove-kept-own' : 'iot-hub.remove-kept-own-or-used'; + this.keptGroups.push({ reason: this.translate.instant(reasonKey, { kept: shared.length }), references: references(shared) }); + } + if (withDevices.length) { + // The profiles devices use, and what those profiles use (default rule chains, dashboard) + this.keptGroups.push({ reason: this.translate.instant('iot-hub.remove-kept-referenced'), references: references(withDevices) }); + } + if (this.keptGroups.length) { this.keptTitle = this.translate.instant('iot-hub.remove-kept-title', { kept: shared.length + withDevices.length }); - this.keptReason = reasons.join(' '); } } diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 07d90f4b3a..944ab99022 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -6449,8 +6449,7 @@ "remove-kept-title": "{ kept, plural, =1 {This entity will not be removed} other {These entities will not be removed} }", "remove-kept-used": "Other installed packages use { kept, plural, =1 {it} other {them} }.", "remove-kept-own": "You had { kept, plural, =1 {it} other {them} } before the package was installed.", - "remove-kept-devices": "{ devices, plural, =1 {1 device still uses} other {# devices still use} } { profiles, plural, =1 {the device profile, so it stays} other {the device profiles, so they stay} }.", - "remove-kept-devices-with-references": "{ devices, plural, =1 {1 device still uses} other {# devices still use} } { profiles, plural, =1 {the device profile, so it stays with the entities it uses} other {the device profiles, so they stay with the entities they use} }.", + "remove-kept-referenced": "Referenced by other tenant entities.", "remove-kept-own-or-used": "You had { kept, plural, =1 {it} other {them} } before the package was installed, or other installed packages use { kept, plural, =1 {it} other {them} }.", "remove-desc-solution-template": "Removing this solution template will also remove all created entities including dashboards, rule chains, devices, and other associated resources within your tenant", "remove-anyway": "Remove anyway", From 4c960743c3819c1079a3aaa825ca98668ea93f7f Mon Sep 17 00:00:00 2001 From: dpinkevych Date: Mon, 16 Nov 2026 17:42:10 +0200 Subject: [PATCH 4/8] IoT Hub device package delete: any kept profile keeps what it refers to, devicesCount dropped (PROD-9340 review) --- .../service/iot_hub/DefaultIotHubService.java | 43 ++++++---- .../iot_hub/InstalledItemKeptEntities.java | 12 ++- ...DefaultDevicePackageUpdateServiceTest.java | 2 +- .../iot_hub/DefaultIotHubServiceTest.java | 83 ++++++++++++++++--- .../iot-hub-delete-dialog.component.html | 15 ++-- .../iot-hub-delete-dialog.component.scss | 30 ++----- .../iot-hub-delete-dialog.component.ts | 12 ++- .../iot-hub/iot-hub-installed-item.models.ts | 7 +- 8 files changed, 127 insertions(+), 77 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/service/iot_hub/DefaultIotHubService.java b/application/src/main/java/org/thingsboard/server/service/iot_hub/DefaultIotHubService.java index ff13b6378a..b62cde9868 100644 --- a/application/src/main/java/org/thingsboard/server/service/iot_hub/DefaultIotHubService.java +++ b/application/src/main/java/org/thingsboard/server/service/iot_hub/DefaultIotHubService.java @@ -8,6 +8,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import jakarta.servlet.http.HttpServletRequest; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.exception.ExceptionUtils; import org.springframework.stereotype.Service; import org.thingsboard.common.util.ExceptionUtil; import org.thingsboard.common.util.JacksonUtil; @@ -44,6 +45,7 @@ import org.thingsboard.server.common.data.iot_hub.RuleChainInstalledItemDescript import org.thingsboard.server.common.data.iot_hub.SolutionTemplateInstalledItemDescriptor; import org.thingsboard.server.common.data.iot_hub.WidgetInstalledItemDescriptor; import org.thingsboard.server.common.data.subscription.SubscriptionException; +import org.thingsboard.server.exception.DataValidationException; import org.thingsboard.server.exception.EntitiesLimitExceededException; import org.thingsboard.server.common.data.page.PageData; import org.thingsboard.server.common.data.page.PageLink; @@ -724,8 +726,8 @@ public class DefaultIotHubService implements IotHubService { * Deletes what a device package created, except the entities another installed device package * also uses (e.g. an integration it took over with Overwrite): deleting those would break that package, * and the ones the user had before and the package took as they were (use existing). A device profile that devices - * still use stays too, e.g. with the devices a LoRaWAN integration created, and so does what it refers to that the - * package created: TB deletes neither. + * still use stays too, e.g. with the devices a LoRaWAN integration created, and any kept profile keeps what it refers + * to: TB deletes neither. * A kept integration loses the metadata entries the package added. */ private void deleteDevicePackageEntities(TenantId tenantId, IotHubInstalledItemId installedItemId, @@ -748,12 +750,14 @@ public class DefaultIotHubService implements IotHubService { if (usedExisting.contains(entityId.getId())) { log.info("[{}] Kept {} {}: the package took it as it was", tenantId, entityId.getEntityType(), entityId.getId()); removeIntegrationMetadata(tenantId, entityId, descriptor, otherPackages); + profileReferences(tenantId, entityId).forEach(reference -> referencedByKeptProfiles.add(reference.getId())); continue; } Set usedBy = usedByOtherPackages.get(entityId.getId()); if (usedBy != null) { log.info("[{}] Kept {} {}: installed device packages {} use it", tenantId, entityId.getEntityType(), entityId.getId(), usedBy); removeIntegrationMetadata(tenantId, entityId, descriptor, otherPackages); + profileReferences(tenantId, entityId).forEach(reference -> referencedByKeptProfiles.add(reference.getId())); continue; } if (referencedByKeptProfiles.contains(entityId.getId())) { @@ -770,7 +774,12 @@ public class DefaultIotHubService implements IotHubService { try { deleteDevicePackageEntity(tenantId, entityId, user); } catch (Exception e) { - log.error("[{}] Failed to delete device package entity: {}", tenantId, entityId, e); + // A reference the package doesn't know of, e.g. a profile the user made later with the package's rule chain + if (ExceptionUtils.indexOfType(e, DataValidationException.class) >= 0) { + log.info("[{}] Kept {} {}: {}", tenantId, entityId.getEntityType(), entityId.getId(), ExceptionUtils.getRootCauseMessage(e)); + } else { + log.error("[{}] Failed to delete device package entity: {}", tenantId, entityId, e); + } } } } @@ -829,10 +838,9 @@ public class DefaultIotHubService implements IotHubService { throw new IllegalArgumentException("Installed item not found"); } List kept = new ArrayList<>(); - List keptForDevices = new ArrayList<>(); + List referenced = new ArrayList<>(); Set usedByItems = new HashSet<>(); int usedExistingCount = 0; - long devicesCount = 0; if (installedItem.getDescriptor() instanceof DeviceInstalledItemDescriptor dd && dd.getCreatedEntityIds() != null) { Set usedExisting = usedExistingIds(dd); Map> usedByOtherPackages = findEntitiesOfOtherDevicePackages(tenantId, installedItemId, new ArrayList<>()); @@ -859,32 +867,37 @@ public class DefaultIotHubService implements IotHubService { } } for (EntityId entityId : dd.getCreatedEntityIds()) { - long devices = keptIds.contains(entityId.getId()) ? 0 : countProfileDevices(tenantId, entityId, deletedDevices); - if (devices == 0) { + if (!keptIds.contains(entityId.getId()) && countProfileDevices(tenantId, entityId, deletedDevices) > 0) { + referenced.add(keptEntity(tenantId, entityId)); + keptIds.add(entityId.getId()); + } + } + // A kept profile, for whatever reason, keeps what it refers to + for (EntityId entityId : dd.getCreatedEntityIds()) { + if (!keptIds.contains(entityId.getId())) { continue; } - keptForDevices.add(keptEntity(tenantId, entityId)); - keptIds.add(entityId.getId()); - devicesCount += devices; - // What the profile refers to stays with it for (EntityId reference : profileReferences(tenantId, entityId)) { if (created.contains(reference.getId()) && keptIds.add(reference.getId())) { - keptForDevices.add(keptEntity(tenantId, reference)); + referenced.add(keptEntity(tenantId, reference)); } } } } - return new InstalledItemKeptEntities(kept, usedByItems.size(), usedExistingCount, keptForDevices, devicesCount); + return new InstalledItemKeptEntities(kept, usedByItems.size(), usedExistingCount, referenced); } private InstalledItemKeptEntities.KeptEntity keptEntity(TenantId tenantId, EntityId entityId) { return new InstalledItemKeptEntities.KeptEntity(entityId, entityService.fetchEntityName(tenantId, entityId).orElse(null)); } - /** The default rule chains and dashboard of the device profile {@code profileId}: TB doesn't delete them while it refers to them. */ + /** The default rule chains and dashboard of a device profile, which TB doesn't delete while it refers to them; none for another entity. */ private List profileReferences(TenantId tenantId, EntityId profileId) { - DeviceProfile profile = deviceProfileService.findDeviceProfileById(tenantId, new DeviceProfileId(profileId.getId())); List references = new ArrayList<>(); + if (profileId.getEntityType() != EntityType.DEVICE_PROFILE) { + return references; + } + DeviceProfile profile = deviceProfileService.findDeviceProfileById(tenantId, new DeviceProfileId(profileId.getId())); if (profile != null) { Stream.of(profile.getDefaultRuleChainId(), profile.getDefaultEdgeRuleChainId(), profile.getDefaultDashboardId()) .filter(Objects::nonNull) diff --git a/application/src/main/java/org/thingsboard/server/service/iot_hub/InstalledItemKeptEntities.java b/application/src/main/java/org/thingsboard/server/service/iot_hub/InstalledItemKeptEntities.java index 4d21db6b10..7c3cfdbeb7 100644 --- a/application/src/main/java/org/thingsboard/server/service/iot_hub/InstalledItemKeptEntities.java +++ b/application/src/main/java/org/thingsboard/server/service/iot_hub/InstalledItemKeptEntities.java @@ -10,8 +10,8 @@ import org.thingsboard.server.common.data.id.EntityId; import java.util.List; /** - * What deleting an installed item keeps: what other installed items use too, what the user had before it, and the device - * profiles devices still use (a LoRaWAN integration creates its devices on the first uplink, not the package). + * What deleting an installed item keeps: what other installed items use too, what the user had before it, and what other + * tenant entities refer to (a LoRaWAN integration creates its devices on the first uplink, not the package). */ @Data @NoArgsConstructor @@ -23,11 +23,9 @@ public class InstalledItemKeptEntities { private int usedByItemsCount; // How many of the kept entities the user had before and the package took as they were (use existing) private int usedExistingCount; - // The package's device profiles that devices use and what they refer to (default rule chain, dashboard): TB deletes - // neither. Apart from entities, which an update reads as shared with other packages - private List keptForDevices; - // How many devices use those profiles - private long devicesCount; + // What other tenant entities refer to: the package's device profiles that devices use, and the default rule chains and + // dashboard of a kept profile. Apart from entities, which an update reads as shared with other packages + private List referencedEntities; @Data @NoArgsConstructor diff --git a/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultDevicePackageUpdateServiceTest.java b/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultDevicePackageUpdateServiceTest.java index 82f5f6c1c9..a90bef69df 100644 --- a/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultDevicePackageUpdateServiceTest.java +++ b/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultDevicePackageUpdateServiceTest.java @@ -308,7 +308,7 @@ class DefaultDevicePackageUpdateServiceTest { Dashboard shared = dashboard(9L); DevicePackageEntities.Snapshot snapshot = new DevicePackageEntities.Snapshot(shared, null); when(packageEntities.load(tenantId, dashboardId)).thenReturn(snapshot); - when(iotHubService.findKeptEntities(tenantId, installedItem.getId())).thenReturn(new InstalledItemKeptEntities(List.of(), 0, 0, List.of(), 0)); + when(iotHubService.findKeptEntities(tenantId, installedItem.getId())).thenReturn(new InstalledItemKeptEntities(List.of(), 0, 0, List.of())); // This package recorded the dashboard as it left it; the other one overwrote it since and recorded the new one ObjectNode own = stateOf(dashboardId, "created").put("checksum", "as-this-package-left-it"); ((DeviceInstalledItemDescriptor) installedItem.getDescriptor()).setInstallState(Map.of("Dashboard", own)); diff --git a/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultIotHubServiceTest.java b/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultIotHubServiceTest.java index 2ef9437115..f21dd20726 100644 --- a/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultIotHubServiceTest.java +++ b/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultIotHubServiceTest.java @@ -23,6 +23,8 @@ import org.thingsboard.server.common.data.id.EntityId; import org.thingsboard.server.common.data.id.IntegrationId; import org.thingsboard.server.common.data.id.IotHubInstalledItemId; import org.thingsboard.server.common.data.id.RuleChainId; +import org.thingsboard.server.common.data.rule.RuleChain; +import org.thingsboard.server.exception.DataValidationException; import org.thingsboard.server.common.data.id.TenantId; import org.thingsboard.server.common.data.integration.Integration; import org.thingsboard.server.common.data.iot_hub.DeviceInstalledItemDescriptor; @@ -745,13 +747,17 @@ class DefaultIotHubServiceTest { } @Test - void findKeptEntities_devicePackage_namesTheProfileDevicesUseAndItsRuleChain_apartFromTheShared() { + void findKeptEntities_devicePackage_namesTheProfileDevicesUseAndWhatItRefersTo_apartFromTheShared() { DeviceProfile profile = new DeviceProfile(new DeviceProfileId(UUID.randomUUID())); RuleChainId ruleChainId = new RuleChainId(UUID.randomUUID()); + DashboardId dashboardId = new DashboardId(UUID.randomUUID()); profile.setDefaultRuleChainId(ruleChainId); + profile.setDefaultDashboardId(dashboardId); + // The user's, not the package's: not listed + profile.setDefaultEdgeRuleChainId(new RuleChainId(UUID.randomUUID())); Device packageDevice = new Device(new DeviceId(UUID.randomUUID())); packageDevice.setDeviceProfileId(profile.getId()); - IotHubInstalledItem checked = devicePackage(ruleChainId, profile.getId(), packageDevice.getId()); + IotHubInstalledItem checked = devicePackage(ruleChainId, dashboardId, profile.getId(), packageDevice.getId()); when(iotHubInstalledItemService.findById(tenantId, checked.getId())).thenReturn(checked); when(iotHubInstalledItemService.findByTenantId(eq(tenantId), eq(List.of("DEVICE")), isNull(), any())) .thenReturn(new PageData<>(List.of(checked), 1, 1, false)); @@ -762,15 +768,16 @@ class DefaultIotHubServiceTest { when(deviceProfileService.findDeviceProfileById(tenantId, profile.getId())).thenReturn(profile); when(entityService.fetchEntityName(tenantId, profile.getId())).thenReturn(Optional.of("smartico-l2-lr")); when(entityService.fetchEntityName(tenantId, ruleChainId)).thenReturn(Optional.of("Smartico L2-LR")); + when(entityService.fetchEntityName(tenantId, dashboardId)).thenReturn(Optional.of("Smartico L2-LR Fleet")); InstalledItemKeptEntities kept = service.findKeptEntities(tenantId, checked.getId()); // An update reads entities as shared with other packages: the profile is not among them assertThat(kept.getEntities()).isEmpty(); - assertThat(kept.getKeptForDevices()).containsExactly( + assertThat(kept.getReferencedEntities()).containsExactly( new InstalledItemKeptEntities.KeptEntity(profile.getId(), "smartico-l2-lr"), - new InstalledItemKeptEntities.KeptEntity(ruleChainId, "Smartico L2-LR")); - assertThat(kept.getDevicesCount()).isEqualTo(2); + new InstalledItemKeptEntities.KeptEntity(ruleChainId, "Smartico L2-LR"), + new InstalledItemKeptEntities.KeptEntity(dashboardId, "Smartico L2-LR Fleet")); } @Test @@ -788,17 +795,36 @@ class DefaultIotHubServiceTest { InstalledItemKeptEntities kept = service.findKeptEntities(tenantId, checked.getId()); - assertThat(kept.getKeptForDevices()).extracting(InstalledItemKeptEntities.KeptEntity::getEntityId).containsExactly(profileId); - assertThat(kept.getDevicesCount()).isEqualTo(1); + assertThat(kept.getReferencedEntities()).extracting(InstalledItemKeptEntities.KeptEntity::getEntityId).containsExactly(profileId); } @Test - void deleteInstalledItem_devicePackage_keepsTheProfileDevicesUseAndItsRuleChain() throws Exception { + void findKeptEntities_devicePackage_aSharedProfileKeepsWhatItRefersTo() { + DeviceProfile profile = new DeviceProfile(new DeviceProfileId(UUID.randomUUID())); + RuleChainId ruleChainId = new RuleChainId(UUID.randomUUID()); + profile.setDefaultRuleChainId(ruleChainId); + IotHubInstalledItem checked = devicePackage(ruleChainId, profile.getId()); + IotHubInstalledItem other = devicePackage(profile.getId()); + when(iotHubInstalledItemService.findById(tenantId, checked.getId())).thenReturn(checked); + when(iotHubInstalledItemService.findByTenantId(eq(tenantId), eq(List.of("DEVICE")), isNull(), any())) + .thenReturn(new PageData<>(List.of(checked, other), 1, 2, false)); + when(deviceProfileService.findDeviceProfileById(tenantId, profile.getId())).thenReturn(profile); + + InstalledItemKeptEntities kept = service.findKeptEntities(tenantId, checked.getId()); + + assertThat(kept.getEntities()).extracting(InstalledItemKeptEntities.KeptEntity::getEntityId).containsExactly(profile.getId()); + assertThat(kept.getReferencedEntities()).extracting(InstalledItemKeptEntities.KeptEntity::getEntityId).containsExactly(ruleChainId); + } + + @Test + void deleteInstalledItem_devicePackage_keepsTheProfileDevicesUseAndWhatItRefersTo() throws Exception { mockTenant(); DeviceProfile profile = new DeviceProfile(new DeviceProfileId(UUID.randomUUID())); RuleChainId ruleChainId = new RuleChainId(UUID.randomUUID()); + DashboardId dashboardId = new DashboardId(UUID.randomUUID()); profile.setDefaultRuleChainId(ruleChainId); - IotHubInstalledItem deleted = devicePackage(ruleChainId, profile.getId()); + profile.setDefaultDashboardId(dashboardId); + IotHubInstalledItem deleted = devicePackage(ruleChainId, dashboardId, profile.getId()); when(iotHubInstalledItemService.findById(tenantId, deleted.getId())).thenReturn(deleted); when(iotHubInstalledItemService.findByTenantId(eq(tenantId), eq(List.of("DEVICE")), isNull(), any())) .thenReturn(new PageData<>(List.of(deleted), 1, 1, false)); @@ -809,8 +835,45 @@ class DefaultIotHubServiceTest { service.deleteInstalledItem(user, deleted.getId()); verify(tbDeviceProfileService, never()).delete(any(), any()); - verify(ruleChainService, never()).findRuleChainById(any(), any()); verify(tbRuleChainService, never()).delete(any(), any()); + verify(tbDashboardService, never()).delete(any(), any()); + verify(iotHubInstalledItemService).deleteById(tenantId, deleted.getId()); + } + + @Test + void deleteInstalledItem_devicePackage_aSharedProfileKeepsItsRuleChain() throws Exception { + mockTenant(); + DeviceProfile profile = new DeviceProfile(new DeviceProfileId(UUID.randomUUID())); + RuleChainId ruleChainId = new RuleChainId(UUID.randomUUID()); + profile.setDefaultRuleChainId(ruleChainId); + IotHubInstalledItem deleted = devicePackage(ruleChainId, profile.getId()); + IotHubInstalledItem other = devicePackage(profile.getId()); + when(iotHubInstalledItemService.findById(tenantId, deleted.getId())).thenReturn(deleted); + when(iotHubInstalledItemService.findByTenantId(eq(tenantId), eq(List.of("DEVICE")), isNull(), any())) + .thenReturn(new PageData<>(List.of(deleted, other), 1, 2, false)); + when(deviceProfileService.findDeviceProfileById(tenantId, profile.getId())).thenReturn(profile); + + service.deleteInstalledItem(user, deleted.getId()); + + verify(tbDeviceProfileService, never()).delete(any(), any()); + verify(tbRuleChainService, never()).delete(any(), any()); + } + + @Test + void deleteInstalledItem_devicePackage_anEntitySomethingElseRefersToStays() throws Exception { + mockTenant(); + RuleChain ruleChain = new RuleChain(new RuleChainId(UUID.randomUUID())); + IotHubInstalledItem deleted = devicePackage(ruleChain.getId()); + when(iotHubInstalledItemService.findById(tenantId, deleted.getId())).thenReturn(deleted); + when(iotHubInstalledItemService.findByTenantId(eq(tenantId), eq(List.of("DEVICE")), isNull(), any())) + .thenReturn(new PageData<>(List.of(deleted), 1, 1, false)); + when(ruleChainService.findRuleChainById(tenantId, ruleChain.getId())).thenReturn(ruleChain); + // A profile the user made after the install uses the package's rule chain + doThrow(new DataValidationException("The rule chain referenced by the device profiles cannot be deleted!")) + .when(tbRuleChainService).delete(ruleChain, user); + + service.deleteInstalledItem(user, deleted.getId()); + verify(iotHubInstalledItemService).deleteById(tenantId, deleted.getId()); } diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.html b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.html index 4b0d6fc93c..9ee22d6bc7 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.html @@ -13,14 +13,13 @@ info_outline
{{ keptTitle }}
- -
- @for (group of keptGroups; track group.reason; let first = $first) { - @if (!first) { -
- } -
{{ group.reason }}
- +
+ @for (group of keptGroups; track group.reason; let i = $index; let first = $first) { +
+
{{ group.reason }}
+ +
}
diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.scss b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.scss index 15bbef3f08..95dcd79e2d 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.scss +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.scss @@ -24,38 +24,20 @@ margin: 0; } -// The kept entities: one white list as tb-image-references draws it, a group per reason .tb-iot-hub-kept-groups { - display: flex; - flex-direction: column; - gap: 4px; - padding: 8px 0; - border-radius: 4px; - background: #fff; border: 1px solid color-mix(in srgb, var(--tb-primary-500) 40%, transparent); - // The groups share the outer border: no border of its own around each group's list + // Groups share the outer border; hide tb-image-references' own ::ng-deep tb-image-references table.tb-entities-list-table { - padding: 0 10px 0 4px !important; - background: transparent !important; + padding: 0 10px 0 4px; + background: transparent; &:before { - display: none !important; + display: none; } } } -.tb-iot-hub-kept-reason { - padding: 4px 12px 2px; - font-size: 12px; - font-weight: 500; - line-height: 16px; - letter-spacing: 0.4px; - color: rgba(0, 0, 0, 0.6); -} - -.tb-iot-hub-kept-divider { - height: 1px; - margin: 6px 12px 4px; - background: rgba(0, 0, 0, 0.08); +.tb-iot-hub-kept-group-next { + border-top: 1px solid rgba(0, 0, 0, 0.08); } diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.ts b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.ts index 2fe865940e..ee010f52d5 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.ts @@ -30,8 +30,7 @@ export class TbIotHubDeleteDialogComponent extends DialogComponent entities.map(entity => ({ id: entity.entityId as EntityId, name: entity.name })); if (shared.length) { @@ -56,12 +55,11 @@ export class TbIotHubDeleteDialogComponent extends DialogComponent { From 9cee5b499a72136faa2e55f26418e7c1f3cf5e9c Mon Sep 17 00:00:00 2001 From: dpinkevych Date: Mon, 16 Nov 2026 18:23:06 +0200 Subject: [PATCH 5/8] IoT Hub device package delete: the dialog scrolls and keeps long names in the box, log level checked in tests (PROD-9340 review) --- .../iot_hub/DefaultIotHubServiceTest.java | 58 ++++++++++++++++--- .../iot-hub-delete-dialog.component.html | 7 ++- .../iot-hub-delete-dialog.component.scss | 6 ++ 3 files changed, 59 insertions(+), 12 deletions(-) diff --git a/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultIotHubServiceTest.java b/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultIotHubServiceTest.java index f21dd20726..fe42513490 100644 --- a/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultIotHubServiceTest.java +++ b/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultIotHubServiceTest.java @@ -3,6 +3,10 @@ // SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1 package org.thingsboard.server.service.iot_hub; +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.Logger; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.read.ListAppender; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; import jakarta.servlet.http.HttpServletRequest; @@ -14,6 +18,7 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Spy; import org.mockito.junit.jupiter.MockitoExtension; +import org.slf4j.LoggerFactory; import org.thingsboard.common.util.JacksonUtil; import org.thingsboard.server.common.data.Device; import org.thingsboard.server.common.data.id.DashboardId; @@ -802,8 +807,10 @@ class DefaultIotHubServiceTest { void findKeptEntities_devicePackage_aSharedProfileKeepsWhatItRefersTo() { DeviceProfile profile = new DeviceProfile(new DeviceProfileId(UUID.randomUUID())); RuleChainId ruleChainId = new RuleChainId(UUID.randomUUID()); + RuleChainId edgeRuleChainId = new RuleChainId(UUID.randomUUID()); profile.setDefaultRuleChainId(ruleChainId); - IotHubInstalledItem checked = devicePackage(ruleChainId, profile.getId()); + profile.setDefaultEdgeRuleChainId(edgeRuleChainId); + IotHubInstalledItem checked = devicePackage(ruleChainId, edgeRuleChainId, profile.getId()); IotHubInstalledItem other = devicePackage(profile.getId()); when(iotHubInstalledItemService.findById(tenantId, checked.getId())).thenReturn(checked); when(iotHubInstalledItemService.findByTenantId(eq(tenantId), eq(List.of("DEVICE")), isNull(), any())) @@ -813,7 +820,8 @@ class DefaultIotHubServiceTest { InstalledItemKeptEntities kept = service.findKeptEntities(tenantId, checked.getId()); assertThat(kept.getEntities()).extracting(InstalledItemKeptEntities.KeptEntity::getEntityId).containsExactly(profile.getId()); - assertThat(kept.getReferencedEntities()).extracting(InstalledItemKeptEntities.KeptEntity::getEntityId).containsExactly(ruleChainId); + assertThat(kept.getReferencedEntities()).extracting(InstalledItemKeptEntities.KeptEntity::getEntityId) + .containsExactly(ruleChainId, edgeRuleChainId); } @Test @@ -860,7 +868,30 @@ class DefaultIotHubServiceTest { } @Test - void deleteInstalledItem_devicePackage_anEntitySomethingElseRefersToStays() throws Exception { + void deleteInstalledItem_devicePackage_anEntitySomethingElseRefersToStays_loggedAsKept() throws Exception { + // A profile the user made after the install uses the package's rule chain + List logs = deleteRuleChainFailingWith( + new DataValidationException("The rule chain referenced by the device profiles cannot be deleted!")); + + assertThat(logs).anySatisfy(event -> { + assertThat(event.getLevel()).isEqualTo(Level.INFO); + assertThat(event.getFormattedMessage()).contains("Kept RULE_CHAIN").contains("referenced by the device profiles"); + }); + assertThat(logs).noneMatch(event -> event.getLevel() == Level.ERROR); + } + + @Test + void deleteInstalledItem_devicePackage_aFailedDelete_staysAnError() throws Exception { + List logs = deleteRuleChainFailingWith(new RuntimeException("Database is down")); + + assertThat(logs).anySatisfy(event -> { + assertThat(event.getLevel()).isEqualTo(Level.ERROR); + assertThat(event.getFormattedMessage()).contains("Failed to delete device package entity"); + }); + } + + /** Deletes a package whose only entity is a rule chain that fails to delete with {@code failure}; the service's logs. */ + private List deleteRuleChainFailingWith(Exception failure) throws Exception { mockTenant(); RuleChain ruleChain = new RuleChain(new RuleChainId(UUID.randomUUID())); IotHubInstalledItem deleted = devicePackage(ruleChain.getId()); @@ -868,13 +899,22 @@ class DefaultIotHubServiceTest { when(iotHubInstalledItemService.findByTenantId(eq(tenantId), eq(List.of("DEVICE")), isNull(), any())) .thenReturn(new PageData<>(List.of(deleted), 1, 1, false)); when(ruleChainService.findRuleChainById(tenantId, ruleChain.getId())).thenReturn(ruleChain); - // A profile the user made after the install uses the package's rule chain - doThrow(new DataValidationException("The rule chain referenced by the device profiles cannot be deleted!")) - .when(tbRuleChainService).delete(ruleChain, user); - - service.deleteInstalledItem(user, deleted.getId()); - + doThrow(failure).when(tbRuleChainService).delete(ruleChain, user); + Logger logger = (Logger) LoggerFactory.getLogger(DefaultIotHubService.class); + ListAppender appender = new ListAppender<>(); + appender.start(); + logger.addAppender(appender); + Level level = logger.getLevel(); + logger.setLevel(Level.INFO); + try { + service.deleteInstalledItem(user, deleted.getId()); + } finally { + logger.setLevel(level); + logger.detachAppender(appender); + } + // The delete goes on either way verify(iotHubInstalledItemService).deleteById(tenantId, deleted.getId()); + return appender.list; } private void noDevices(DeviceProfileId profileId) { diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.html b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.html index 9ee22d6bc7..be62922e11 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.html @@ -5,15 +5,16 @@ SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1 --> -
+ +

{{ 'iot-hub.remove-confirm-title' | translate:{ name: data.itemName } }}

{{ description }}

@if (keptGroups.length) {
info_outline -
+
{{ keptTitle }}
-
+
@for (group of keptGroups; track group.reason; let i = $index; let first = $first) {
diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.scss b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.scss index 95dcd79e2d..ab3f9b9ebc 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.scss +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.scss @@ -35,9 +35,15 @@ &:before { display: none; } + + // A long name breaks inside the box instead of running past its border + td.tb-entity-name { + overflow-wrap: anywhere; + } } } +// Not divide-y: with preflight off, divide-solid draws the side borders of the groups too .tb-iot-hub-kept-group-next { border-top: 1px solid rgba(0, 0, 0, 0.08); } From 14415d27b68c22da7b374526dc4d2923bd7ed68b Mon Sep 17 00:00:00 2001 From: dpinkevych Date: Tue, 17 Nov 2026 11:27:59 +0200 Subject: [PATCH 6/8] IoT Hub device package delete: the hint doesn't shrink so the dialog scrolls, the type column wraps in a narrow dialog, cleanup (PROD-9340 review) --- .../iot-hub/iot-hub-delete-dialog.component.html | 11 ++++++----- .../iot-hub/iot-hub-delete-dialog.component.scss | 6 +++++- .../iot-hub/iot-hub-delete-dialog.component.ts | 1 - .../models/iot-hub/iot-hub-installed-item.models.ts | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.html b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.html index be62922e11..29af8760a4 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.html @@ -10,15 +10,16 @@

{{ 'iot-hub.remove-confirm-title' | translate:{ name: data.itemName } }}

{{ description }}

@if (keptGroups.length) { -
+ +
info_outline
{{ keptTitle }}
-
- @for (group of keptGroups; track group.reason; let i = $index; let first = $first) { +
+ @for (group of keptGroups; track group.reason; let first = $first) {
-
{{ group.reason }}
+ [attr.aria-labelledby]="'tb-iot-hub-kept-reason-' + $index"> +
{{ group.reason }}
} diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.scss b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.scss index ab3f9b9ebc..692c86d143 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.scss +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.scss @@ -36,7 +36,11 @@ display: none; } - // A long name breaks inside the box instead of running past its border + // In a narrow dialog the type wraps, so the name keeps room; a long name breaks inside the box + td.tb-entity-type { + white-space: normal; + } + td.tb-entity-name { overflow-wrap: anywhere; } diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.ts b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.ts index ee010f52d5..32cd6324c6 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.ts @@ -30,7 +30,6 @@ export class TbIotHubDeleteDialogComponent extends DialogComponent Date: Tue, 17 Nov 2026 12:36:05 +0200 Subject: [PATCH 7/8] IoT Hub device package delete: the type column wraps in a narrow dialog, standard dialog layout On phones the entity type now wraps so the name gets more room; the override did not apply before. The dialog uses mat-dialog-content and mat-dialog-actions, so Material handles scrolling. The group divider uses Tailwind. --- .../iot-hub/iot-hub-actions.service.ts | 2 +- .../iot-hub-delete-dialog.component.html | 46 +++++++++---------- .../iot-hub-delete-dialog.component.scss | 13 +++--- 3 files changed, 30 insertions(+), 31 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-actions.service.ts b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-actions.service.ts index 9c5d995c10..f17c4cb7d4 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-actions.service.ts +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-actions.service.ts @@ -212,7 +212,7 @@ export class IotHubActionsService { if (!installedItem) { return of(false); } - // A device package keeps what other installed packages use: the dialog opens with that already known + // A device package keeps some entities: the dialog opens with them already known const keptEntities$: Observable = installedItem.itemType === 'DEVICE' ? this.iotHubApiService.getInstalledItemKeptEntities(installedItem.id.id, {ignoreErrors: true}).pipe(catchError(() => of(null))) : of(null); diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.html b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.html index 29af8760a4..d8adb56606 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.html @@ -5,30 +5,30 @@ SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1 --> - -
-

{{ 'iot-hub.remove-confirm-title' | translate:{ name: data.itemName } }}

-

{{ description }}

- @if (keptGroups.length) { - -
- info_outline -
-
{{ keptTitle }}
-
- @for (group of keptGroups; track group.reason; let first = $first) { -
-
{{ group.reason }}
- -
- } + +
+

{{ 'iot-hub.remove-confirm-title' | translate:{ name: data.itemName } }}

+

{{ description }}

+ @if (keptGroups.length) { +
+ info_outline +
+
{{ keptTitle }}
+
+ @for (group of keptGroups; track group.reason) { +
+
{{ group.reason }}
+ +
+ } +
-
- } -
-
+ } +
+ + -
+ diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.scss b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.scss index 692c86d143..0168b2bb51 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.scss +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.scss @@ -1,6 +1,8 @@ // SPDX-FileCopyrightText: Copyright The ThingsBoard Authors // SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc. // SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1 +@import "../../../../../scss/constants"; + :host { display: block; max-width: 600px; @@ -36,9 +38,11 @@ display: none; } - // In a narrow dialog the type wraps, so the name keeps room; a long name breaks inside the box + // Narrow dialog: let type and name wrap td.tb-entity-type { - white-space: normal; + @media #{$mat-xs} { + white-space: normal !important; + } } td.tb-entity-name { @@ -46,8 +50,3 @@ } } } - -// Not divide-y: with preflight off, divide-solid draws the side borders of the groups too -.tb-iot-hub-kept-group-next { - border-top: 1px solid rgba(0, 0, 0, 0.08); -} From 265a4a8ebd775b79eceaef02a3e9f812075e6625 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Tue, 17 Nov 2026 12:48:11 +0200 Subject: [PATCH 8/8] IoT Hub device package delete: the title uses mat-dialog-title --- .../components/iot-hub/iot-hub-delete-dialog.component.html | 4 ++-- .../components/iot-hub/iot-hub-delete-dialog.component.scss | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.html b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.html index d8adb56606..30626b90f6 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.html @@ -5,9 +5,9 @@ SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1 --> - +

{{ 'iot-hub.remove-confirm-title' | translate:{ name: data.itemName } }}

+
-

{{ 'iot-hub.remove-confirm-title' | translate:{ name: data.itemName } }}

{{ description }}

@if (keptGroups.length) {
diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.scss b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.scss index 0168b2bb51..41e586417b 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.scss +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-delete-dialog.component.scss @@ -15,6 +15,12 @@ letter-spacing: 0.1px; color: rgba(0, 0, 0, 0.87); margin: 0; + padding: 24px 24px 20px; + + // No baseline strut: the title keeps its own line height + &::before { + display: none; + } } .tb-iot-hub-delete-desc {