diff --git a/src/app/modules/slide-ins/slide-in.ts b/src/app/modules/slide-ins/slide-in.ts index 7c2e03217eb..fcbf7e7bb22 100644 --- a/src/app/modules/slide-ins/slide-in.ts +++ b/src/app/modules/slide-ins/slide-in.ts @@ -82,6 +82,16 @@ export class SlideIn extends ComponentStore { }; }); + closeLast = this.updater((state) => { + const newMap = new Map(state.components); + const { id } = this.getAliveComponents(newMap).pop(); + newMap.set(id, { ...newMap.get(id), isComponentAlive: false }); + this.focusOnTheCloseButton(); + return { + components: newMap, + }; + }); + closeAll = this.updater(() => { this.focusOnTheCloseButton(); return { diff --git a/src/app/pages/apps/components/app-wizard/app-wizard.component.spec.ts b/src/app/pages/apps/components/app-wizard/app-wizard.component.spec.ts index c1eb03c0baf..be88bceebb8 100644 --- a/src/app/pages/apps/components/app-wizard/app-wizard.component.spec.ts +++ b/src/app/pages/apps/components/app-wizard/app-wizard.component.spec.ts @@ -16,14 +16,13 @@ import { DialogService } from 'app/modules/dialog/dialog.service'; import { IxInputHarness } from 'app/modules/forms/ix-forms/components/ix-input/ix-input.harness'; import { IxFormHarness } from 'app/modules/forms/ix-forms/testing/ix-form.harness'; import { PageHeaderComponent } from 'app/modules/page-header/page-title-header/page-header.component'; -import { OldSlideInRef } from 'app/modules/slide-ins/old-slide-in-ref'; -import { SLIDE_IN_DATA } from 'app/modules/slide-ins/slide-in.token'; +import { SlideIn } from 'app/modules/slide-ins/slide-in'; +import { SlideInRef } from 'app/modules/slide-ins/slide-in-ref'; import { ApiService } from 'app/modules/websocket/api.service'; import { AppWizardComponent } from 'app/pages/apps/components/app-wizard/app-wizard.component'; import { DockerHubRateInfoDialogComponent } from 'app/pages/apps/components/dockerhub-rate-limit-info-dialog/dockerhub-rate-limit-info-dialog.component'; import { ApplicationsService } from 'app/pages/apps/services/applications.service'; import { DockerStore } from 'app/pages/apps/store/docker.store'; -import { OldSlideInService } from 'app/services/old-slide-in.service'; const appVersion121 = { healthy: true, @@ -270,6 +269,12 @@ describe('AppWizardComponent', () => { }, } as App; + const slideInRef: SlideInRef = { + close: jest.fn(), + requireConfirmationWhen: jest.fn(), + getData: jest.fn(() => undefined), + }; + const createComponent = createComponentFactory({ component: AppWizardComponent, imports: [ @@ -281,7 +286,7 @@ describe('AppWizardComponent', () => { mockProvider(MatDialog), ], providers: [ - mockProvider(OldSlideInService), + mockProvider(SlideIn), mockProvider(DialogService, { jobDialog: jest.fn(() => ({ afterClosed: () => of({}), @@ -308,10 +313,9 @@ describe('AppWizardComponent', () => { mockProvider(DockerStore, { selectedPool$: of('pool set'), }), - mockProvider(OldSlideInRef), + mockProvider(SlideInRef, slideInRef), mockProvider(Router), mockAuth(), - { provide: SLIDE_IN_DATA, useValue: undefined }, ], }); diff --git a/src/app/pages/datasets/components/dataset-form/utils/dataset-form.service.spec.ts b/src/app/pages/datasets/components/dataset-form/utils/dataset-form.service.spec.ts index fbeac6c8926..acec4e4b7b8 100644 --- a/src/app/pages/datasets/components/dataset-form/utils/dataset-form.service.spec.ts +++ b/src/app/pages/datasets/components/dataset-form/utils/dataset-form.service.spec.ts @@ -6,9 +6,9 @@ import { inherit } from 'app/enums/with-inherit.enum'; import { helptextDatasetForm } from 'app/helptext/storage/volumes/datasets/dataset-form'; import { Dataset } from 'app/interfaces/dataset.interface'; import { DialogService } from 'app/modules/dialog/dialog.service'; +import { SlideIn } from 'app/modules/slide-ins/slide-in'; import { ApiService } from 'app/modules/websocket/api.service'; import { DatasetFormService } from 'app/pages/datasets/components/dataset-form/utils/dataset-form.service'; -import { OldSlideInService } from 'app/services/old-slide-in.service'; describe('DatasetFormService', () => { let spectator: SpectatorService; @@ -22,7 +22,10 @@ describe('DatasetFormService', () => { mockProvider(DialogService, { warn: jest.fn(() => of(true)), }), - mockProvider(OldSlideInService), + mockProvider(SlideIn, { + components$: of([]), + closeLast: jest.fn(), + }), ], }); @@ -37,7 +40,7 @@ describe('DatasetFormService', () => { helptextDatasetForm.pathWarningTitle, helptextDatasetForm.pathIsTooLongWarning, ); - expect(spectator.inject(OldSlideInService).closeLast).toHaveBeenCalled(); + expect(spectator.inject(SlideIn).closeLast).toHaveBeenCalled(); }); it('checks parent path, shows error if it nesting level is too deep and closes slide in', async () => { @@ -48,7 +51,7 @@ describe('DatasetFormService', () => { helptextDatasetForm.pathWarningTitle, helptextDatasetForm.pathIsTooDeepWarning, ); - expect(spectator.inject(OldSlideInService).closeLast).toHaveBeenCalled(); + expect(spectator.inject(SlideIn).closeLast).toHaveBeenCalled(); }); }); diff --git a/src/app/pages/datasets/components/dataset-form/utils/dataset-form.service.ts b/src/app/pages/datasets/components/dataset-form/utils/dataset-form.service.ts index 49e5fcc7488..0cf624fd5d5 100644 --- a/src/app/pages/datasets/components/dataset-form/utils/dataset-form.service.ts +++ b/src/app/pages/datasets/components/dataset-form/utils/dataset-form.service.ts @@ -10,8 +10,8 @@ import { helptextDatasetForm } from 'app/helptext/storage/volumes/datasets/datas import { Dataset } from 'app/interfaces/dataset.interface'; import { Option } from 'app/interfaces/option.interface'; import { DialogService } from 'app/modules/dialog/dialog.service'; +import { SlideIn } from 'app/modules/slide-ins/slide-in'; import { ApiService } from 'app/modules/websocket/api.service'; -import { OldSlideInService } from 'app/services/old-slide-in.service'; @Injectable({ providedIn: 'root', @@ -21,7 +21,7 @@ export class DatasetFormService { private dialog: DialogService, private api: ApiService, private translate: TranslateService, - private slideInService: OldSlideInService, + private slideIn: SlideIn, ) {} checkAndWarnForLengthAndDepth(path: string): Observable { @@ -35,7 +35,7 @@ export class DatasetFormService { this.translate.instant(helptextDatasetForm.pathWarningTitle), this.translate.instant(helptextDatasetForm.pathIsTooDeepWarning), ).pipe( - tap(() => this.slideInService.closeLast()), + tap(() => this.slideIn.closeLast()), map(() => false), ); } @@ -44,7 +44,7 @@ export class DatasetFormService { this.translate.instant(helptextDatasetForm.pathWarningTitle), this.translate.instant(helptextDatasetForm.pathIsTooLongWarning), ).pipe( - tap(() => this.slideInService.closeLast()), + tap(() => this.slideIn.closeLast()), map(() => false), ); } diff --git a/src/app/pages/datasets/components/zvol-form/zvol-form.component.spec.ts b/src/app/pages/datasets/components/zvol-form/zvol-form.component.spec.ts index bfcb4a1aebb..f5052c2f57c 100644 --- a/src/app/pages/datasets/components/zvol-form/zvol-form.component.spec.ts +++ b/src/app/pages/datasets/components/zvol-form/zvol-form.component.spec.ts @@ -191,7 +191,6 @@ describe('ZvolFormComponent', () => { spectator = createComponent({ providers: [ mockProvider(SlideInRef, { ...slideInRef, getData: jest.fn(() => ({ isNew: false, parentId: 'test pool' })) }), - ], }); loader = TestbedHarnessEnvironment.loader(spectator.fixture); diff --git a/src/app/pages/sharing/iscsi/authorized-access/authorized-access-form/authorized-access-form.component.html b/src/app/pages/sharing/iscsi/authorized-access/authorized-access-form/authorized-access-form.component.html index cbe8e5d923c..2ad24fd2d76 100644 --- a/src/app/pages/sharing/iscsi/authorized-access/authorized-access-form/authorized-access-form.component.html +++ b/src/app/pages/sharing/iscsi/authorized-access/authorized-access-form/authorized-access-form.component.html @@ -1,4 +1,8 @@ - + diff --git a/src/app/pages/sharing/iscsi/authorized-access/authorized-access-form/authorized-access-form.component.spec.ts b/src/app/pages/sharing/iscsi/authorized-access/authorized-access-form/authorized-access-form.component.spec.ts index 82f10184aef..f54b2657d43 100644 --- a/src/app/pages/sharing/iscsi/authorized-access/authorized-access-form/authorized-access-form.component.spec.ts +++ b/src/app/pages/sharing/iscsi/authorized-access/authorized-access-form/authorized-access-form.component.spec.ts @@ -3,18 +3,18 @@ import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; import { ReactiveFormsModule } from '@angular/forms'; import { MatButtonHarness } from '@angular/material/button/testing'; import { createComponentFactory, mockProvider, Spectator } from '@ngneat/spectator/jest'; +import { of } from 'rxjs'; import { mockCall, mockApi } from 'app/core/testing/utils/mock-api.utils'; import { mockAuth } from 'app/core/testing/utils/mock-auth.utils'; import { IscsiAuthAccess } from 'app/interfaces/iscsi.interface'; import { DialogService } from 'app/modules/dialog/dialog.service'; import { IxFormHarness } from 'app/modules/forms/ix-forms/testing/ix-form.harness'; -import { OldSlideInRef } from 'app/modules/slide-ins/old-slide-in-ref'; -import { SLIDE_IN_DATA } from 'app/modules/slide-ins/slide-in.token'; +import { SlideIn } from 'app/modules/slide-ins/slide-in'; +import { SlideInRef } from 'app/modules/slide-ins/slide-in-ref'; import { ApiService } from 'app/modules/websocket/api.service'; import { AuthorizedAccessFormComponent, } from 'app/pages/sharing/iscsi/authorized-access/authorized-access-form/authorized-access-form.component'; -import { OldSlideInService } from 'app/services/old-slide-in.service'; describe('AuthorizedAccessFormComponent', () => { let spectator: Spectator; @@ -30,6 +30,12 @@ describe('AuthorizedAccessFormComponent', () => { peersecret: 'peer123456789012', } as IscsiAuthAccess; + const slideInRef: SlideInRef = { + close: jest.fn(), + requireConfirmationWhen: jest.fn(), + getData: jest.fn(() => undefined), + }; + const createComponent = createComponentFactory({ component: AuthorizedAccessFormComponent, imports: [ @@ -37,14 +43,15 @@ describe('AuthorizedAccessFormComponent', () => { ], providers: [ mockAuth(), - mockProvider(OldSlideInService), + mockProvider(SlideIn, { + components$: of([]), + }), mockProvider(DialogService), mockApi([ mockCall('iscsi.auth.create'), mockCall('iscsi.auth.update'), ]), - mockProvider(OldSlideInRef), - { provide: SLIDE_IN_DATA, useValue: undefined }, + mockProvider(SlideInRef, slideInRef), ], }); @@ -77,7 +84,7 @@ describe('AuthorizedAccessFormComponent', () => { peersecret: 'peer123456789012', discovery_auth: 'NONE', }]); - expect(spectator.inject(OldSlideInRef).close).toHaveBeenCalled(); + expect(spectator.inject(SlideInRef).close).toHaveBeenCalled(); }); }); @@ -85,7 +92,7 @@ describe('AuthorizedAccessFormComponent', () => { beforeEach(async () => { spectator = createComponent({ providers: [ - { provide: SLIDE_IN_DATA, useValue: existingAuthorizedAccess }, + mockProvider(SlideInRef, { ...slideInRef, getData: () => existingAuthorizedAccess }), ], }); loader = TestbedHarnessEnvironment.loader(spectator.fixture); @@ -135,7 +142,7 @@ describe('AuthorizedAccessFormComponent', () => { }, ], ); - expect(spectator.inject(OldSlideInRef).close).toHaveBeenCalled(); + expect(spectator.inject(SlideInRef).close).toHaveBeenCalled(); }); }); }); diff --git a/src/app/pages/sharing/iscsi/authorized-access/authorized-access-form/authorized-access-form.component.ts b/src/app/pages/sharing/iscsi/authorized-access/authorized-access-form/authorized-access-form.component.ts index 56a84a0d495..d1160d4953f 100644 --- a/src/app/pages/sharing/iscsi/authorized-access/authorized-access-form/authorized-access-form.component.ts +++ b/src/app/pages/sharing/iscsi/authorized-access/authorized-access-form/authorized-access-form.component.ts @@ -1,5 +1,5 @@ import { - ChangeDetectionStrategy, ChangeDetectorRef, Component, Inject, OnInit, + ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit, } from '@angular/core'; import { FormBuilder, Validators, ReactiveFormsModule } from '@angular/forms'; import { MatButton } from '@angular/material/button'; @@ -25,9 +25,8 @@ import { doesNotEqualFgValidator, matchOthersFgValidator, } from 'app/modules/forms/ix-forms/validators/password-validation/password-validation'; -import { OldModalHeaderComponent } from 'app/modules/slide-ins/components/old-modal-header/old-modal-header.component'; -import { OldSlideInRef } from 'app/modules/slide-ins/old-slide-in-ref'; -import { SLIDE_IN_DATA } from 'app/modules/slide-ins/slide-in.token'; +import { ModalHeaderComponent } from 'app/modules/slide-ins/components/modal-header/modal-header.component'; +import { SlideInRef } from 'app/modules/slide-ins/slide-in-ref'; import { TestDirective } from 'app/modules/test-id/test.directive'; import { ApiService } from 'app/modules/websocket/api.service'; @@ -38,7 +37,7 @@ import { ApiService } from 'app/modules/websocket/api.service'; changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [ - OldModalHeaderComponent, + ModalHeaderComponent, MatCard, MatCardContent, ReactiveFormsModule, @@ -105,6 +104,7 @@ export class AuthorizedAccessFormComponent implements OnInit { isLoading = false; discoveryAuthOptions$: Observable[]>; + protected editingAccess: IscsiAuthAccess | undefined; readonly defaultDiscoveryAuthOptions = [ { @@ -139,9 +139,10 @@ export class AuthorizedAccessFormComponent implements OnInit { private cdr: ChangeDetectorRef, private api: ApiService, private validatorService: IxValidatorsService, - private slideInRef: OldSlideInRef, - @Inject(SLIDE_IN_DATA) private editingAccess: IscsiAuthAccess, - ) {} + public slideInRef: SlideInRef, + ) { + this.editingAccess = this.slideInRef.getData(); + } ngOnInit(): void { this.discoveryAuthOptions$ = of(this.defaultDiscoveryAuthOptions); @@ -205,7 +206,7 @@ export class AuthorizedAccessFormComponent implements OnInit { request$.pipe(untilDestroyed(this)).subscribe({ next: () => { this.isLoading = false; - this.slideInRef.close(true); + this.slideInRef.close({ response: true, error: null }); }, error: (error: unknown) => { this.isLoading = false; diff --git a/src/app/pages/sharing/iscsi/authorized-access/authorized-access-list/authorized-access-list.component.spec.ts b/src/app/pages/sharing/iscsi/authorized-access/authorized-access-list/authorized-access-list.component.spec.ts index 891622c23ce..a3e9d37c4ae 100644 --- a/src/app/pages/sharing/iscsi/authorized-access/authorized-access-list/authorized-access-list.component.spec.ts +++ b/src/app/pages/sharing/iscsi/authorized-access/authorized-access-list/authorized-access-list.component.spec.ts @@ -16,11 +16,11 @@ import { IxTableColumnsSelectorComponent, } from 'app/modules/ix-table/components/ix-table-columns-selector/ix-table-columns-selector.component'; import { FakeProgressBarComponent } from 'app/modules/loader/components/fake-progress-bar/fake-progress-bar.component'; -import { OldSlideInRef } from 'app/modules/slide-ins/old-slide-in-ref'; +import { SlideIn } from 'app/modules/slide-ins/slide-in'; +import { SlideInRef } from 'app/modules/slide-ins/slide-in-ref'; import { ApiService } from 'app/modules/websocket/api.service'; import { AuthorizedAccessFormComponent } from 'app/pages/sharing/iscsi/authorized-access/authorized-access-form/authorized-access-form.component'; import { AuthorizedAccessListComponent } from 'app/pages/sharing/iscsi/authorized-access/authorized-access-list/authorized-access-list.component'; -import { OldSlideInService } from 'app/services/old-slide-in.service'; const authAccess: IscsiAuthAccess[] = [ { @@ -36,6 +36,12 @@ describe('AuthorizedAccessListComponent', () => { let loader: HarnessLoader; let table: IxTableHarness; + const slideInRef: SlideInRef = { + close: jest.fn(), + requireConfirmationWhen: jest.fn(), + getData: jest.fn(() => undefined), + }; + const createComponent = createComponentFactory({ component: AuthorizedAccessListComponent, imports: [ @@ -50,12 +56,12 @@ describe('AuthorizedAccessListComponent', () => { mockCall('iscsi.auth.query', authAccess), mockCall('iscsi.auth.delete'), ]), - mockProvider(OldSlideInRef), + mockProvider(SlideInRef, slideInRef), mockProvider(DialogService, { confirm: jest.fn(() => of(true)), }), - mockProvider(OldSlideInService, { - open: jest.fn(() => ({ slideInClosed$: of(true) })), + mockProvider(SlideIn, { + open: jest.fn(() => of()), }), mockProvider(MatDialog, { open: jest.fn(), @@ -78,14 +84,14 @@ describe('AuthorizedAccessListComponent', () => { const addButton = await loader.getHarness(MatButtonHarness.with({ text: 'Add' })); await addButton.click(); - expect(spectator.inject(OldSlideInService).open).toHaveBeenCalledWith(AuthorizedAccessFormComponent); + expect(spectator.inject(SlideIn).open).toHaveBeenCalledWith(AuthorizedAccessFormComponent); }); it('opens authorized access form when "Edit" button is pressed', async () => { const editButton = await table.getHarnessInCell(IxIconHarness.with({ name: 'edit' }), 1, 3); await editButton.click(); - expect(spectator.inject(OldSlideInService).open).toHaveBeenCalledWith(AuthorizedAccessFormComponent, { + expect(spectator.inject(SlideIn).open).toHaveBeenCalledWith(AuthorizedAccessFormComponent, { data: authAccess[0], }); }); diff --git a/src/app/pages/sharing/iscsi/authorized-access/authorized-access-list/authorized-access-list.component.ts b/src/app/pages/sharing/iscsi/authorized-access/authorized-access-list/authorized-access-list.component.ts index dc42ac38413..38a676d1dd2 100644 --- a/src/app/pages/sharing/iscsi/authorized-access/authorized-access-list/authorized-access-list.component.ts +++ b/src/app/pages/sharing/iscsi/authorized-access/authorized-access-list/authorized-access-list.component.ts @@ -30,6 +30,7 @@ import { IxTableEmptyDirective } from 'app/modules/ix-table/directives/ix-table- import { createTable } from 'app/modules/ix-table/utils'; import { AppLoaderService } from 'app/modules/loader/app-loader.service'; import { FakeProgressBarComponent } from 'app/modules/loader/components/fake-progress-bar/fake-progress-bar.component'; +import { SlideIn } from 'app/modules/slide-ins/slide-in'; import { TestDirective } from 'app/modules/test-id/test.directive'; import { ApiService } from 'app/modules/websocket/api.service'; import { AuthorizedAccessFormComponent } from 'app/pages/sharing/iscsi/authorized-access/authorized-access-form/authorized-access-form.component'; @@ -38,7 +39,6 @@ import { } from 'app/pages/sharing/iscsi/authorized-access/authorized-access-list/authorized-access-list.elements'; import { ErrorHandlerService } from 'app/services/error-handler.service'; import { IscsiService } from 'app/services/iscsi.service'; -import { OldSlideInService } from 'app/services/old-slide-in.service'; @UntilDestroy() @Component({ @@ -100,10 +100,11 @@ export class AuthorizedAccessListComponent implements OnInit { iconName: iconMarker('edit'), tooltip: this.translate.instant('Edit'), onClick: (row) => { - const slideInRef = this.slideInService.open(AuthorizedAccessFormComponent, { data: row }); - slideInRef.slideInClosed$ - .pipe(filter(Boolean), untilDestroyed(this)) - .subscribe(() => this.refresh()); + this.slideIn.open(AuthorizedAccessFormComponent, { data: row }) + .pipe( + filter((response) => !!response.response), + untilDestroyed(this), + ).subscribe(() => this.refresh()); }, }, { @@ -140,7 +141,7 @@ export class AuthorizedAccessListComponent implements OnInit { private dialogService: DialogService, private api: ApiService, private translate: TranslateService, - private slideInService: OldSlideInService, + private slideIn: SlideIn, private errorHandler: ErrorHandlerService, private cdr: ChangeDetectorRef, private iscsiService: IscsiService, @@ -161,8 +162,10 @@ export class AuthorizedAccessListComponent implements OnInit { } doAdd(): void { - const slideInRef = this.slideInService.open(AuthorizedAccessFormComponent); - slideInRef.slideInClosed$.pipe(filter(Boolean), untilDestroyed(this)).subscribe(() => this.refresh()); + this.slideIn.open(AuthorizedAccessFormComponent).pipe( + filter((response) => !!response.response), + untilDestroyed(this), + ).subscribe(() => this.refresh()); } onListFiltered(query: string): void { diff --git a/src/app/pages/sharing/iscsi/extent/extent-form/extent-form.component.html b/src/app/pages/sharing/iscsi/extent/extent-form/extent-form.component.html index 2aef200cc8a..82d59a8149b 100644 --- a/src/app/pages/sharing/iscsi/extent/extent-form/extent-form.component.html +++ b/src/app/pages/sharing/iscsi/extent/extent-form/extent-form.component.html @@ -1,4 +1,8 @@ - + diff --git a/src/app/pages/sharing/iscsi/extent/extent-form/extent-form.component.spec.ts b/src/app/pages/sharing/iscsi/extent/extent-form/extent-form.component.spec.ts index 51ee7b876d6..df5c6c6ad1d 100644 --- a/src/app/pages/sharing/iscsi/extent/extent-form/extent-form.component.spec.ts +++ b/src/app/pages/sharing/iscsi/extent/extent-form/extent-form.component.spec.ts @@ -3,6 +3,7 @@ import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; import { ReactiveFormsModule } from '@angular/forms'; import { MatButtonHarness } from '@angular/material/button/testing'; import { createComponentFactory, mockProvider, Spectator } from '@ngneat/spectator/jest'; +import { of } from 'rxjs'; import { KiB } from 'app/constants/bytes.constant'; import { mockCall, mockApi } from 'app/core/testing/utils/mock-api.utils'; import { mockAuth } from 'app/core/testing/utils/mock-auth.utils'; @@ -11,11 +12,10 @@ import { Choices } from 'app/interfaces/choices.interface'; import { IscsiExtent } from 'app/interfaces/iscsi.interface'; import { DialogService } from 'app/modules/dialog/dialog.service'; import { IxFormHarness } from 'app/modules/forms/ix-forms/testing/ix-form.harness'; -import { OldSlideInRef } from 'app/modules/slide-ins/old-slide-in-ref'; -import { SLIDE_IN_DATA } from 'app/modules/slide-ins/slide-in.token'; +import { SlideIn } from 'app/modules/slide-ins/slide-in'; +import { SlideInRef } from 'app/modules/slide-ins/slide-in-ref'; import { ApiService } from 'app/modules/websocket/api.service'; import { ExtentFormComponent } from 'app/pages/sharing/iscsi/extent/extent-form/extent-form.component'; -import { OldSlideInService } from 'app/services/old-slide-in.service'; import { StorageService } from 'app/services/storage.service'; describe('ExtentFormComponent', () => { @@ -23,6 +23,12 @@ describe('ExtentFormComponent', () => { let loader: HarnessLoader; let form: IxFormHarness; + const slideInRef: SlideInRef = { + close: jest.fn(), + requireConfirmationWhen: jest.fn(), + getData: jest.fn(() => undefined), + }; + const existingExtent = { id: 123, name: 'test_name', @@ -49,7 +55,9 @@ describe('ExtentFormComponent', () => { ], providers: [ mockAuth(), - mockProvider(OldSlideInService), + mockProvider(SlideIn, { + components$: of([]), + }), mockProvider(StorageService), mockProvider(DialogService), mockApi([ @@ -61,8 +69,7 @@ describe('ExtentFormComponent', () => { key_device_3: 'value_device_3', } as Choices), ]), - mockProvider(OldSlideInRef), - { provide: SLIDE_IN_DATA, useValue: undefined }, + mockProvider(SlideInRef, slideInRef), ], }); @@ -124,7 +131,7 @@ describe('ExtentFormComponent', () => { type: IscsiExtentType.Disk, xen: true, }]); - expect(spectator.inject(OldSlideInRef).close).toHaveBeenCalled(); + expect(spectator.inject(SlideInRef).close).toHaveBeenCalled(); }); }); @@ -132,7 +139,7 @@ describe('ExtentFormComponent', () => { beforeEach(async () => { spectator = createComponent({ providers: [ - { provide: SLIDE_IN_DATA, useValue: existingExtent }, + mockProvider(SlideInRef, { ...slideInRef, getData: () => existingExtent }), ], }); loader = TestbedHarnessEnvironment.loader(spectator.fixture); @@ -188,7 +195,7 @@ describe('ExtentFormComponent', () => { xen: true, }, ]); - expect(spectator.inject(OldSlideInRef).close).toHaveBeenCalled(); + expect(spectator.inject(SlideInRef).close).toHaveBeenCalled(); }); }); }); diff --git a/src/app/pages/sharing/iscsi/extent/extent-form/extent-form.component.ts b/src/app/pages/sharing/iscsi/extent/extent-form/extent-form.component.ts index 81d2d735d2e..cebe94acbe0 100644 --- a/src/app/pages/sharing/iscsi/extent/extent-form/extent-form.component.ts +++ b/src/app/pages/sharing/iscsi/extent/extent-form/extent-form.component.ts @@ -1,5 +1,5 @@ import { - ChangeDetectionStrategy, ChangeDetectorRef, Component, Inject, OnInit, + ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit, } from '@angular/core'; import { Validators, ReactiveFormsModule } from '@angular/forms'; import { MatButton } from '@angular/material/button'; @@ -28,9 +28,8 @@ import { IxInputComponent } from 'app/modules/forms/ix-forms/components/ix-input import { IxSelectComponent } from 'app/modules/forms/ix-forms/components/ix-select/ix-select.component'; import { FormErrorHandlerService } from 'app/modules/forms/ix-forms/services/form-error-handler.service'; import { IxFormatterService } from 'app/modules/forms/ix-forms/services/ix-formatter.service'; -import { OldModalHeaderComponent } from 'app/modules/slide-ins/components/old-modal-header/old-modal-header.component'; -import { OldSlideInRef } from 'app/modules/slide-ins/old-slide-in-ref'; -import { SLIDE_IN_DATA } from 'app/modules/slide-ins/slide-in.token'; +import { ModalHeaderComponent } from 'app/modules/slide-ins/components/modal-header/modal-header.component'; +import { SlideInRef } from 'app/modules/slide-ins/slide-in-ref'; import { TestDirective } from 'app/modules/test-id/test.directive'; import { ApiService } from 'app/modules/websocket/api.service'; import { FilesystemService } from 'app/services/filesystem.service'; @@ -44,7 +43,7 @@ import { IscsiService } from 'app/services/iscsi.service'; changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [ - OldModalHeaderComponent, + ModalHeaderComponent, MatCard, MatCardContent, ReactiveFormsModule, @@ -98,6 +97,7 @@ export class ExtentFormComponent implements OnInit { }); isLoading = false; + protected editingExtent: IscsiExtent | undefined; private extentDiskBeingEdited$ = new BehaviorSubject