Skip to content

Commit

Permalink
NAS-132672: Containers | Delete instance which has autostart: true
Browse files Browse the repository at this point in the history
…-> shows error modal (#11085)
  • Loading branch information
AlexKarpov98 authored Nov 22, 2024
1 parent b041a5f commit a5e0a02
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class VirtualizationDevicesStore extends ComponentStore<VirtualizationIns
return;
}
const oldSelectedInstance = this.selectedInstance();
if (!selectedInstance || selectedInstance === oldSelectedInstance) {
if (!selectedInstance || selectedInstance?.id === oldSelectedInstance?.id) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ export class VirtualizationInstancesStore extends ComponentStore<VirtualizationI
return [...instances, event.fields];
case IncomingApiMessageType.Changed:
// TODO: Keep it until API improvements
if (Object.keys(event.fields).length === 1 && 'status' in event.fields) {
if (event.fields && Object.keys(event.fields).length === 1 && 'status' in event.fields) {
return instances.map((instance) => {
if (instance.name === event.id) {
return { ...instance, status: event.fields.status };
}
return instance;
});
}
return instances.map((item) => (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:
Expand Down

0 comments on commit a5e0a02

Please sign in to comment.