From: Dnyaneshwari Date: Tue, 8 Oct 2024 07:18:57 +0000 (+0530) Subject: mgr/dashboard: Carbon Design - Create realm popup X-Git-Tag: v20.0.0~746^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4ef8a86fa41cfd5094d3d6ec97be45722827c540;p=ceph.git mgr/dashboard: Carbon Design - Create realm popup Fixes: https://tracker.ceph.com/issues/68341 Signed-off-by: Dnyaneshwari Talwekar --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.ts index 22da2851d5a6..67c98b0a59fc 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-details/rgw-multisite-details.component.ts @@ -139,9 +139,7 @@ export class RgwMultisiteDetailsComponent implements OnDestroy, OnInit { multisiteInfo: this.multisiteInfo }; if (entityName === 'realm') { - this.bsModalRef = this.modalService.show(RgwMultisiteRealmFormComponent, initialState, { - size: 'lg' - }); + this.bsModalRef = this.cdsModalService.show(RgwMultisiteRealmFormComponent, initialState); } else if (entityName === 'zonegroup') { this.bsModalRef = this.modalService.show(RgwMultisiteZonegroupFormComponent, initialState, { size: 'lg' diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-realm-form/rgw-multisite-realm-form.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-realm-form/rgw-multisite-realm-form.component.html index 1fa5b08f60d6..5ca36f4bd2fc 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-realm-form/rgw-multisite-realm-form.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-realm-form/rgw-multisite-realm-form.component.html @@ -1,58 +1,91 @@ - - {{ action | titlecase }} {{ resource | upperFirst }} + + +

{{ action | titlecase }} {{ resource | upperFirst }}

+
- +
-
+ + + diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-realm-form/rgw-multisite-realm-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-realm-form/rgw-multisite-realm-form.component.spec.ts index becb1569ad6f..f68619fe9ff1 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-realm-form/rgw-multisite-realm-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-realm-form/rgw-multisite-realm-form.component.spec.ts @@ -14,6 +14,7 @@ import { SharedModule } from '~/app/shared/shared.module'; import { RgwMultisiteRealmFormComponent } from './rgw-multisite-realm-form.component'; import { configureTestBed } from '~/testing/unit-test-helper'; +import { CheckboxModule, InputModule, ModalModule } from 'carbon-components-angular'; describe('RgwMultisiteRealmFormComponent', () => { let component: RgwMultisiteRealmFormComponent; @@ -26,9 +27,16 @@ describe('RgwMultisiteRealmFormComponent', () => { ReactiveFormsModule, RouterTestingModule, HttpClientTestingModule, - ToastrModule.forRoot() + ToastrModule.forRoot(), + ModalModule, + InputModule, + CheckboxModule + ], + providers: [ + NgbActiveModal, + { provide: 'multisiteInfo', useValue: [[]] }, + { provide: 'info', useValue: { data: { name: 'null' } } } ], - providers: [NgbActiveModal], declarations: [RgwMultisiteRealmFormComponent] }); @@ -68,7 +76,6 @@ describe('RgwMultisiteRealmFormComponent', () => { it('tests create success notification', () => { spyOn(rgwRealmService, 'create').and.returnValue(observableOf([])); - component.action = 'create'; component.multisiteRealmForm.markAsDirty(); component.submit(); expect(notificationService.show).toHaveBeenCalledWith( diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-realm-form/rgw-multisite-realm-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-realm-form/rgw-multisite-realm-form.component.ts index 20cd2032fafd..1e18598b0dbb 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-realm-form/rgw-multisite-realm-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-multisite-realm-form/rgw-multisite-realm-form.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, Inject, OnInit, Optional } from '@angular/core'; import { UntypedFormControl, Validators } from '@angular/forms'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { RgwRealmService } from '~/app/shared/api/rgw-realm.service'; @@ -9,26 +9,21 @@ import { CdValidators } from '~/app/shared/forms/cd-validators'; import { NotificationService } from '~/app/shared/services/notification.service'; import { RgwRealm } from '../models/rgw-multisite'; import { DocService } from '~/app/shared/services/doc.service'; +import { BaseModal } from 'carbon-components-angular'; @Component({ selector: 'cd-rgw-multisite-realm-form', templateUrl: './rgw-multisite-realm-form.component.html', styleUrls: ['./rgw-multisite-realm-form.component.scss'] }) -export class RgwMultisiteRealmFormComponent implements OnInit { - action: string; +export class RgwMultisiteRealmFormComponent extends BaseModal implements OnInit { multisiteRealmForm: CdFormGroup; - info: any; - editing = false; - resource: string; - multisiteInfo: object[] = []; realm: RgwRealm; realmList: RgwRealm[] = []; zonegroupList: RgwRealm[] = []; realmNames: string[]; newRealmName: string; isMaster: boolean; - defaultsInfo: string[]; defaultRealmDisabled = false; docUrl: string; @@ -37,11 +32,17 @@ export class RgwMultisiteRealmFormComponent implements OnInit { public actionLabels: ActionLabelsI18n, public rgwRealmService: RgwRealmService, public notificationService: NotificationService, - public docService: DocService + public docService: DocService, + @Optional() @Inject('action') public action: string, + @Optional() @Inject('resource') public resource: string, + @Optional() @Inject('info') public info: any, + @Optional() @Inject('multisiteInfo') public multisiteInfo: object[], + @Optional() @Inject('defaultsInfo') public defaultsInfo: string[], + @Optional() @Inject('editing') public editing: boolean ) { - this.action = this.editing - ? this.actionLabels.EDIT + this.resource - : this.actionLabels.CREATE + this.resource; + super(); + + this.action = this.editing ? this.actionLabels.EDIT : this.actionLabels.CREATE; this.createForm(); } @@ -52,7 +53,7 @@ export class RgwMultisiteRealmFormComponent implements OnInit { Validators.required, CdValidators.custom('uniqueName', (realmName: string) => { return ( - this.action === 'create' && + this.action === this.actionLabels.CREATE && this.realmNames && this.realmNames.indexOf(realmName) !== -1 ); @@ -71,7 +72,7 @@ export class RgwMultisiteRealmFormComponent implements OnInit { this.realmNames = this.realmList.map((realm) => { return realm['name']; }); - if (this.action === 'edit') { + if (this.action === this.actionLabels.EDIT) { this.zonegroupList = this.multisiteInfo[1] !== undefined && this.multisiteInfo[1].hasOwnProperty('zonegroups') ? this.multisiteInfo[1]['zonegroups'] @@ -97,7 +98,7 @@ export class RgwMultisiteRealmFormComponent implements OnInit { submit() { const values = this.multisiteRealmForm.getRawValue(); this.realm = new RgwRealm(); - if (this.action === 'create') { + if (this.action === this.actionLabels.CREATE) { this.realm.name = values['realmName']; this.rgwRealmService.create(this.realm, values['default_realm']).subscribe( () => { @@ -105,13 +106,13 @@ export class RgwMultisiteRealmFormComponent implements OnInit { NotificationType.success, $localize`Realm: '${values['realmName']}' created successfully` ); - this.activeModal.close(); + this.closeModal(); }, () => { this.multisiteRealmForm.setErrors({ cdSubmitButton: true }); } ); - } else if (this.action === 'edit') { + } else { this.realm.name = this.info.data.name; this.newRealmName = values['realmName']; this.rgwRealmService.update(this.realm, values['default_realm'], this.newRealmName).subscribe( @@ -120,7 +121,7 @@ export class RgwMultisiteRealmFormComponent implements OnInit { NotificationType.success, $localize`Realm: '${values['realmName']}' updated successfully` ); - this.activeModal.close(); + this.closeModal(); }, () => { this.multisiteRealmForm.setErrors({ cdSubmitButton: true }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw.module.ts index 5f8c6f50135c..a55cb1797786 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw.module.ts @@ -71,7 +71,9 @@ import { LoadingModule, ModalModule, ProgressIndicatorModule, - CodeSnippetModule + CodeSnippetModule, + InputModule, + CheckboxModule } from 'carbon-components-angular'; import { CephSharedModule } from '../shared/ceph-shared.module'; @@ -99,7 +101,9 @@ import { CephSharedModule } from '../shared/ceph-shared.module'; ButtonModule, LoadingModule, IconModule, - NgbProgressbar + NgbProgressbar, + InputModule, + CheckboxModule ], exports: [ RgwDaemonListComponent,