From a5e0a0274c7c8b296bbdf6d3e120abb46d77adde Mon Sep 17 00:00:00 2001 From: Alex Karpov Date: Fri, 22 Nov 2024 15:10:43 +0200 Subject: [PATCH] NAS-132672: Containers | Delete instance which has `autostart: true` -> shows error modal (#11085) --- .../instance-general-info/instance-general-info.component.ts | 3 ++- .../all-instances/instance-list/instance-list.component.ts | 2 +- .../virtualization/stores/virtualization-devices.store.ts | 2 +- .../virtualization/stores/virtualization-instances.store.ts | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/app/pages/virtualization/components/all-instances/instance-details/instance-general-info/instance-general-info.component.ts b/src/app/pages/virtualization/components/all-instances/instance-details/instance-general-info/instance-general-info.component.ts index 780d51d7bb4..b4415ff72f0 100644 --- a/src/app/pages/virtualization/components/all-instances/instance-details/instance-general-info/instance-general-info.component.ts +++ b/src/app/pages/virtualization/components/all-instances/instance-details/instance-general-info/instance-general-info.component.ts @@ -8,7 +8,7 @@ import { import { Router } from '@angular/router'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { TranslateModule, TranslateService } from '@ngx-translate/core'; -import { switchMap } from 'rxjs'; +import { filter, switchMap } from 'rxjs'; import { RequiresRolesDirective } from 'app/directives/requires-roles/requires-roles.directive'; import { Role } from 'app/enums/role.enum'; import { virtualizationStatusLabels } from 'app/enums/virtualization.enum'; @@ -70,6 +70,7 @@ export class InstanceGeneralInfoComponent { title: this.translate.instant('Delete'), message: this.translate.instant('Delete {name}?', { name: this.instance().name }), }).pipe( + filter(Boolean), switchMap(() => { return this.dialogService.jobDialog( this.api.job('virt.instance.delete', [this.instance().id]), diff --git a/src/app/pages/virtualization/components/all-instances/instance-list/instance-list.component.ts b/src/app/pages/virtualization/components/all-instances/instance-list/instance-list.component.ts index 3040da1e35e..b6914aff729 100644 --- a/src/app/pages/virtualization/components/all-instances/instance-list/instance-list.component.ts +++ b/src/app/pages/virtualization/components/all-instances/instance-list/instance-list.component.ts @@ -89,7 +89,7 @@ export class InstanceListComponent { } const instanceId = this.activatedRoute.snapshot.paramMap.get('id'); - if (instanceId) { + if (instanceId && this.instances().some((instance) => instance.id === instanceId)) { this.deviceStore.selectInstance(instanceId); } else { const [firstInstance] = this.instances(); diff --git a/src/app/pages/virtualization/stores/virtualization-devices.store.ts b/src/app/pages/virtualization/stores/virtualization-devices.store.ts index 1edec925885..a30e44d27dd 100644 --- a/src/app/pages/virtualization/stores/virtualization-devices.store.ts +++ b/src/app/pages/virtualization/stores/virtualization-devices.store.ts @@ -66,7 +66,7 @@ export class VirtualizationDevicesStore extends ComponentStore { if (instance.name === event.id) { return { ...instance, status: event.fields.status }; @@ -54,7 +54,7 @@ export class VirtualizationInstancesStore extends ComponentStore (item.id === event.id ? event.fields : item)); + return instances.map((item) => (item.id === event.id ? { ...item, ...event?.fields } : item)); case IncomingApiMessageType.Removed: return instances.filter((item) => item.id !== event.id); default: