From 62f1d522ea698dcba6410ce1ce1d8f8c50444936 Mon Sep 17 00:00:00 2001 From: Panos Hatzinikolaou Date: Tue, 7 Jan 2025 16:00:36 -0800 Subject: [PATCH 1/2] replace union type with alias --- .../classes/success-dialog-component.class.ts | 8 +++++++ .../success-dialog.component.ts | 24 +++++++++---------- 2 files changed, 20 insertions(+), 12 deletions(-) create mode 100644 workspace/apps/pidp/src/app/shared/components/success-dialog/classes/success-dialog-component.class.ts diff --git a/workspace/apps/pidp/src/app/shared/components/success-dialog/classes/success-dialog-component.class.ts b/workspace/apps/pidp/src/app/shared/components/success-dialog/classes/success-dialog-component.class.ts new file mode 100644 index 000000000..7a21fb39b --- /dev/null +++ b/workspace/apps/pidp/src/app/shared/components/success-dialog/classes/success-dialog-component.class.ts @@ -0,0 +1,8 @@ +import { DialogBcproviderCreateComponent } from '../components/dialog-bcprovider-create.component'; +import { DialogBcproviderEditComponent } from '../components/dialog-bcprovider-edit.component'; +import { FeedbackSendComponent } from '../components/feedback-send.component'; + +export type SuccessDialogComponentClass = + | DialogBcproviderCreateComponent + | DialogBcproviderEditComponent + | FeedbackSendComponent; diff --git a/workspace/apps/pidp/src/app/shared/components/success-dialog/success-dialog.component.ts b/workspace/apps/pidp/src/app/shared/components/success-dialog/success-dialog.component.ts index dcb78d7ad..02cfda326 100644 --- a/workspace/apps/pidp/src/app/shared/components/success-dialog/success-dialog.component.ts +++ b/workspace/apps/pidp/src/app/shared/components/success-dialog/success-dialog.component.ts @@ -1,3 +1,4 @@ +import { NgClass, NgIf } from '@angular/common'; import { Component, Input, @@ -7,7 +8,6 @@ import { ViewContainerRef, } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; -import { NgClass, NgIf } from '@angular/common'; import { FaIconComponent } from '@fortawesome/angular-fontawesome'; import { faCircleCheck, faXmark } from '@fortawesome/free-solid-svg-icons'; @@ -15,9 +15,9 @@ import { NavigationService } from '@pidp/presentation'; import { InjectViewportCssClassDirective } from '@bcgov/shared/ui'; +import { SuccessDialogComponentClass } from './classes/success-dialog-component.class'; import { DialogBcproviderCreateComponent } from './components/dialog-bcprovider-create.component'; import { DialogBcproviderEditComponent } from './components/dialog-bcprovider-edit.component'; -import { FeedbackSendComponent } from './components/feedback-send.component'; @Component({ selector: 'app-success-dialog', @@ -33,9 +33,7 @@ export class SuccessDialogComponent implements OnInit { @Input() public username!: string; @Input() public title!: string; - @Input() public componentType!: Type< - DialogBcproviderCreateComponent | DialogBcproviderEditComponent | FeedbackSendComponent - >; + @Input() public componentType!: Type; @ViewChild('dialogParagraphHost', { static: true, read: ViewContainerRef }) public dialogParagraphHost!: ViewContainerRef; @@ -51,19 +49,21 @@ export class SuccessDialogComponent implements OnInit { public ngOnInit(): void { this.loadDialogParagraphComponent(this.componentType); - if(this.componentType instanceof DialogBcproviderCreateComponent || this.componentType instanceof DialogBcproviderEditComponent) { + if ( + this.componentType instanceof DialogBcproviderCreateComponent || + this.componentType instanceof DialogBcproviderEditComponent + ) { this.showHeader = true; } } private loadDialogParagraphComponent( - componentType: Type< - DialogBcproviderCreateComponent | DialogBcproviderEditComponent | FeedbackSendComponent - >, + componentType: Type, ): void { - const componentRef = this.dialogParagraphHost.createComponent< - DialogBcproviderCreateComponent | DialogBcproviderEditComponent | FeedbackSendComponent - >(componentType); + const componentRef = + this.dialogParagraphHost.createComponent( + componentType, + ); componentRef.instance.username = this.username; } } From dd4ed7ecf0239fecc3de369bfb568ae4147c7665 Mon Sep 17 00:00:00 2001 From: Panos Hatzinikolaou Date: Tue, 7 Jan 2025 16:13:37 -0800 Subject: [PATCH 2/2] remove navigationService --- .../success-dialog/success-dialog.component.spec.ts | 7 +------ .../components/success-dialog/success-dialog.component.ts | 6 +----- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/workspace/apps/pidp/src/app/shared/components/success-dialog/success-dialog.component.spec.ts b/workspace/apps/pidp/src/app/shared/components/success-dialog/success-dialog.component.spec.ts index fe01e366d..a8bd28682 100644 --- a/workspace/apps/pidp/src/app/shared/components/success-dialog/success-dialog.component.spec.ts +++ b/workspace/apps/pidp/src/app/shared/components/success-dialog/success-dialog.component.spec.ts @@ -1,7 +1,6 @@ import { TestBed } from '@angular/core/testing'; import { MatDialog, MatDialogModule } from '@angular/material/dialog'; -import { NavigationService } from '@pidp/presentation'; import { provideAutoSpy } from 'jest-auto-spies'; import { SuccessDialogComponent } from './success-dialog.component'; @@ -12,11 +11,7 @@ describe('SuccessDialogComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ imports: [MatDialogModule], - providers: [ - SuccessDialogComponent, - provideAutoSpy(NavigationService), - provideAutoSpy(MatDialog), - ], + providers: [SuccessDialogComponent, provideAutoSpy(MatDialog)], }).compileComponents(); component = TestBed.inject(SuccessDialogComponent); diff --git a/workspace/apps/pidp/src/app/shared/components/success-dialog/success-dialog.component.ts b/workspace/apps/pidp/src/app/shared/components/success-dialog/success-dialog.component.ts index 02cfda326..60f4db86f 100644 --- a/workspace/apps/pidp/src/app/shared/components/success-dialog/success-dialog.component.ts +++ b/workspace/apps/pidp/src/app/shared/components/success-dialog/success-dialog.component.ts @@ -11,7 +11,6 @@ import { MatDialog } from '@angular/material/dialog'; import { FaIconComponent } from '@fortawesome/angular-fontawesome'; import { faCircleCheck, faXmark } from '@fortawesome/free-solid-svg-icons'; -import { NavigationService } from '@pidp/presentation'; import { InjectViewportCssClassDirective } from '@bcgov/shared/ui'; @@ -38,10 +37,7 @@ export class SuccessDialogComponent implements OnInit { @ViewChild('dialogParagraphHost', { static: true, read: ViewContainerRef }) public dialogParagraphHost!: ViewContainerRef; - public constructor( - public dialog: MatDialog, - private navigationService: NavigationService, - ) {} + public constructor(public dialog: MatDialog) {} public onSuccessDialogClose(): void { this.dialog.closeAll();