Skip to content

Commit

Permalink
NAS-132671 / 25.04 / Initial Containers Loading - Hide empty componen…
Browse files Browse the repository at this point in the history
…t until data is received (#11100)

* NAS-132671: Hide empty component until data is received

* NAS-132671: Revert "NAS-422: Hide empty component until data is received"

* NAS-132671: Hide empty component until data is received

---------

Co-authored-by: Boris Vasilenko <[email protected]>
  • Loading branch information
bvasilenko and Boris Vasilenko authored Dec 4, 2024
1 parent a4a28de commit f93e825
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h2>{{ 'Instances' | translate }}</h2>

<ix-search-input1
[maxLength]="100"
[disabled]="!instances().length"
[disabled]="!instances()?.length"
[value]="searchQuery()"
(search)="onSearch($event)"
></ix-search-input1>
Expand All @@ -28,7 +28,7 @@ <h2>{{ 'Instances' | translate }}</h2>
<div class="instances">
<div class="instances-header-row">
<div class="cell checkbox">
@if (instances().length) {
@if (instances()?.length) {
<mat-checkbox
color="primary"
ixTest="select-all-app"
Expand All @@ -45,7 +45,7 @@ <h2>{{ 'Instances' | translate }}</h2>
<div class="cell actions">{{ 'Controls' | translate }}</div>
</div>

@if (!filteredInstances()?.length) {
@if (instances() !== undefined && !filteredInstances().length) {
<ix-empty [conf]="emptyConfig()"></ix-empty>
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class InstanceListComponent {
}

protected readonly filteredInstances = computed(() => {
return this.instances().filter((instance) => {
return (this.instances() || []).filter((instance) => {
return instance?.name?.toLocaleLowerCase().includes(this.searchQuery().toLocaleLowerCase());
});
});
Expand Down Expand Up @@ -96,7 +96,7 @@ export class InstanceListComponent {
private deviceStore: VirtualizationDevicesStore,
) {
toObservable(this.instances).pipe(
filter((instances) => !!instances.length),
filter((instances) => !!instances?.length),
switchMap(() => this.activatedRoute.params),
untilDestroyed(this),
).subscribe((params) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('VirtualizationInstancesStore', () => {
it('should have initial state', () => {
expect(spectator.service.stateAsSignal()).toEqual({
isLoading: true,
instances: [],
instances: undefined,
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ import { ApiService } from 'app/services/websocket/api.service';

export interface VirtualizationInstancesState {
isLoading: boolean;
instances: VirtualizationInstance[];
instances: VirtualizationInstance[] | undefined;
}

const initialState: VirtualizationInstancesState = {
isLoading: true,
instances: [],
instances: undefined,
};

@UntilDestroy()
@Injectable()
export class VirtualizationInstancesStore extends ComponentStore<VirtualizationInstancesState> {
readonly stateAsSignal = toSignal(this.state$, { initialValue: initialState });
readonly isLoading = computed(() => this.stateAsSignal().isLoading);
readonly instances = computed(() => this.stateAsSignal().instances.filter(Boolean));
readonly instances = computed(() => this.stateAsSignal().instances?.filter(Boolean));

constructor(
private api: ApiService,
Expand Down

0 comments on commit f93e825

Please sign in to comment.