Skip to content

Commit

Permalink
NAS-131994 / 25.04 / Storage: Number of available disks doesn't updat…
Browse files Browse the repository at this point in the history
…e after a disconnect/destroy data until screen refresh (#11209)

* NAS-131994: Storage: Number of available disks does not update after a disconnect/destroy data until screen refresh

* NAS-131994: PR update
  • Loading branch information
AlexKarpov98 authored Dec 20, 2024
1 parent 3773016 commit 8d90712
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,18 @@ describe('UnusedResourcesComponent', () => {

it('hides an \'Unassigned Disks\' card when does not exist unused disks', () => {
spectator.inject(MockApiService).mockCall('disk.details', { used: [], unused: [] });
spectator.component.ngOnInit();
spectator.setInput('pools', []);
spectator.detectChanges();

expect(spectator.queryAll('ix-unused-disk-card')).toHaveLength(0);

spectator.inject(MockApiService).mockCall('disk.details', {
used: [],
unused: [
{ devname: 'sdc', identifier: '{uuid}7ad07324-f0e9-49a4-a7a4-92edd82a4929' },
] as DetailsDisk[],
});
spectator.component.ngOnInit();
spectator.setInput('pools', []);
spectator.detectChanges();

expect(spectator.queryAll('ix-unused-disk-card')).toHaveLength(1);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
ChangeDetectionStrategy, ChangeDetectorRef, Component, input, OnInit,
ChangeDetectionStrategy, ChangeDetectorRef, Component, effect, input, OnInit,
} from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
Expand Down Expand Up @@ -35,10 +35,15 @@ export class UnusedResourcesComponent implements OnInit {
private errorHandler: ErrorHandlerService,
private cdr: ChangeDetectorRef,
private matDialog: MatDialog,
) { }
) {
effect(() => {
if (this.pools()) {
this.updateUnusedDisks();
}
});
}

ngOnInit(): void {
this.updateUnusedDisks();
this.subscribeToDiskQuery();
}

Expand Down

0 comments on commit 8d90712

Please sign in to comment.