Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NAS-132671 / 25.04 / Initial Containers Loading - Hide empty component until data is received #11100

Merged
merged 4 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading