From b9fccdffd244c38754177e6fd785328c609ea19f Mon Sep 17 00:00:00 2001 From: Naman Munet Date: Mon, 27 Jul 2026 13:05:28 +0530 Subject: [PATCH] mgr/dashboard: Add required field validation for managed policies in account user creation fixes: https://tracker-origin.ceph.com/issues/78684 Signed-off-by: Naman Munet --- .../frontend/cypress/e2e/rgw/users.po.ts | 36 ++++++++++++++++++- .../rgw-user-form.component.html | 6 ++++ .../rgw-user-form/rgw-user-form.component.ts | 10 +++++- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/cypress/e2e/rgw/users.po.ts b/src/pybind/mgr/dashboard/frontend/cypress/e2e/rgw/users.po.ts index 16a79f8ec97..219a66c0662 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/e2e/rgw/users.po.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/e2e/rgw/users.po.ts @@ -9,13 +9,37 @@ export class UsersPageHelper extends PageHelper { pages = pages; @PageHelper.restrictTo(pages.create.url) - create(tenant: string, user_id: string, fullname: string, email: string, maxbuckets: string) { + create( + tenant: string, + user_id: string, + fullname: string, + email: string, + maxbuckets: string, + account_id?: string, + selectPolicy: boolean = false + ) { // Enter in user_id cy.get('#user_id').type(user_id); // Show Tenant cy.get('#show_tenant_input').click({ force: true }); // Enter in tenant cy.get('#tenant').type(tenant); + + if (account_id) { + cy.get('select#link_account').select(account_id); + if (selectPolicy) { + // Wait for the policies combo box to appear (it only shows when account is linked and not root user) + cy.get('cds-combo-box#account_policies').scrollIntoView().should('be.visible'); + cy.get('cds-combo-box#account_policies input[type="text"]').scrollIntoView().click(); + cy.get('cds-combo-box#account_policies cds-dropdown-list ul[role="listbox"]') + .should('be.visible') + .find('li[role="option"]') + .first() + .find('input[type="checkbox"]') + .check({ force: true }); + } + } + // Enter in full name cy.get('#display_name').click().type(fullname); @@ -179,6 +203,16 @@ export class UsersPageHelper extends PageHelper { 'contain.text', `${account_name} - ${tenant}` ); + + cy.get('cds-combo-box#account_policies').scrollIntoView().should('be.visible'); + cy.get('cds-combo-box#account_policies input[type="text"]').scrollIntoView().click(); + cy.get('cds-combo-box#account_policies cds-dropdown-list ul[role="listbox"]') + .should('be.visible') + .find('li[role="option"]') + .first() + .find('input[type="checkbox"]') + .check({ force: true }); + cy.contains('button', 'Edit User').click(); this.getTableRow(tenant + '$' + user_id).as('AccountUser'); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.html index 9daef795ab1..f05ae5e10e3 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.html @@ -341,8 +341,14 @@ i18n-placeholder [appendInline]="true" [items]="managedPolicies" + cdRequiredField="Policies" + cdValidate + #policies="cdValidate" + [invalid]="policies.isInvalid" + invalidText="This field is required" (selected)="multiSelector($event)" itemValueKey="name" + i18n-invalidText i18n-label i18n > 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 ba474fc779b..4e3e35d7878 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 @@ -132,7 +132,15 @@ export class RgwUserFormComponent extends CdForm implements OnInit { ], account_id: [null, [this.tenantedAccountValidator.bind(this)]], account_root_user: [false], - account_policies: [[]], + account_policies: [ + [], + [ + CdValidators.requiredIf({ + account_id: { op: '!empty' }, + account_root_user: false + }) + ] + ], max_buckets_mode: [1], max_buckets: [ 1000,