From: Aashish Sharma Date: Thu, 10 Dec 2020 06:00:36 +0000 (+0530) Subject: mgr/dashboard: RGW User Form is validating disabled fields X-Git-Tag: v16.1.0~292^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F38519%2Fhead;p=ceph.git mgr/dashboard: RGW User Form is validating disabled fields When you try to submit a non valid form, angular is checking all the fields of the form, resulting in some wrong validations. Fixes:https://tracker.ceph.com/issues/47727 Signed-off-by: Aashish Sharma --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.ts index 0b3103c9f8de9..75dd109cd1237 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.ts @@ -61,6 +61,8 @@ export class RgwUserFormComponent extends CdForm implements OnInit { this.subuserLabel = $localize`subuser`; this.s3keyLabel = $localize`S3 Key`; this.capabilityLabel = $localize`capability`; + this.editing = this.router.url.startsWith(`/rgw/user/${URLVerbs.EDIT}`); + this.action = this.editing ? this.actionLabels.EDIT : this.actionLabels.CREATE; this.createForm(); } @@ -70,7 +72,7 @@ export class RgwUserFormComponent extends CdForm implements OnInit { uid: [ null, [Validators.required], - [CdValidators.unique(this.rgwUserService.exists, this.rgwUserService)] + this.editing ? [] : [CdValidators.unique(this.rgwUserService.exists, this.rgwUserService)] ], display_name: [null, [Validators.required]], email: [ @@ -148,8 +150,6 @@ export class RgwUserFormComponent extends CdForm implements OnInit { } ngOnInit() { - this.editing = this.router.url.startsWith(`/rgw/user/${URLVerbs.EDIT}`); - this.action = this.editing ? this.actionLabels.EDIT : this.actionLabels.CREATE; // Process route parameters. this.route.params.subscribe((params: { uid: string }) => { if (!params.hasOwnProperty('uid')) {