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

AAE-13282: Fixing save preferences on service tasks #8476

Merged
merged 2 commits into from
Apr 14, 2023
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 @@ -157,6 +157,9 @@ export abstract class BaseTaskListCloudComponent<T = unknown> extends DataTableS
if (changes['sorting']) {
this.formatSorting(changes['sorting'].currentValue);
}
if (changes['appName']) {
this.retrieveTasksPreferences();
}
this.reload();
}

Expand All @@ -165,7 +168,8 @@ export abstract class BaseTaskListCloudComponent<T = unknown> extends DataTableS
this.onDestroy$.complete();
}

ngAfterContentInit() {
private retrieveTasksPreferences(): void {
this.isLoading = true;
this.cloudPreferenceService.getPreferences(this.appName).pipe(
take(1),
map((preferences => {
Expand Down Expand Up @@ -194,8 +198,16 @@ export abstract class BaseTaskListCloudComponent<T = unknown> extends DataTableS
}

this.createDatatableSchema();
}
);
this.createColumns();
this.isLoading = false;
}, (error) => {
this.error.emit(error);
this.isLoading = false;
});
}

ngAfterContentInit(): void {
this.retrieveTasksPreferences();
}

isListEmpty(): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,9 @@ describe('ServiceTaskListCloudComponent', () => {
spyOn(serviceTaskListCloudService, 'getServiceTaskByRequest').and.returnValue(of(emptyList));

fixture.detectChanges();
expect(component.isLoading).toBe(true);
let loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
expect(loadingContent.nativeElement).toBeDefined();

const appName = new SimpleChange(null, 'FAKE-APP-NAME', true);
component.ngOnChanges({ appName });
fixture.detectChanges();
expect(component.isLoading).toBe(false);

loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
const loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
expect(loadingContent).toBeFalsy();

const emptyContent = fixture.debugElement.query(By.css('.adf-empty-content'));
Expand All @@ -150,15 +144,13 @@ describe('ServiceTaskListCloudComponent', () => {
const appName = new SimpleChange(null, 'FAKE-APP-NAME', true);

fixture.detectChanges();
expect(component.isLoading).toBe(true);
let loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
expect(loadingContent.nativeElement).toBeDefined();
expect(component.isLoading).toBe(false);

component.ngOnChanges({ appName });
fixture.detectChanges();

expect(component.isLoading).toBe(false);
loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
const loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
expect(loadingContent).toBeFalsy();

const emptyContent = fixture.debugElement.query(By.css('.adf-empty-content'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export class ServiceTaskListCloudComponent extends BaseTaskListCloudComponent {
this.requestNode = this.createRequestNode();

if (this.requestNode.appName || this.requestNode.appName === '') {
this.isLoading = true;

combineLatest([
this.serviceTaskListCloudService.getServiceTaskByRequest(this.requestNode),
Expand All @@ -63,7 +62,6 @@ export class ServiceTaskListCloudComponent extends BaseTaskListCloudComponent {
([tasks]) => {
this.rows = tasks.list.entries;
this.success.emit(tasks);
this.isLoading = false;
this.pagination.next(tasks.list.pagination);
}, (error) => {
this.error.emit(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,13 @@ describe('TaskListCloudComponent', () => {
spyOn(taskListCloudService, 'getTaskByRequest').and.returnValue(of(emptyList));

fixture.detectChanges();
expect(component.isLoading).toBe(true);
let loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
expect(loadingContent.nativeElement).toBeDefined();
expect(component.isLoading).toBe(false);

const appName = new SimpleChange(null, 'FAKE-APP-NAME', true);
component.ngOnChanges({ appName });
fixture.detectChanges();

loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
const loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
expect(loadingContent).toBeFalsy();

const emptyContent = fixture.debugElement.query(By.css('.adf-empty-content'));
Expand All @@ -180,15 +178,13 @@ describe('TaskListCloudComponent', () => {
const appName = new SimpleChange(null, 'FAKE-APP-NAME', true);

fixture.detectChanges();
expect(component.isLoading).toBe(true);
let loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
expect(loadingContent.nativeElement).toBeDefined();
expect(component.isLoading).toBe(false);

component.ngOnChanges({ appName });
fixture.detectChanges();

expect(component.isLoading).toBe(false);
loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
const loadingContent = fixture.debugElement.query(By.css('mat-progress-spinner'));
expect(loadingContent).toBeFalsy();

const emptyContent = fixture.debugElement.query(By.css('.adf-empty-content'));
Expand Down