]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Add required field validation for managed policies in account user... 70558/head
authorNaman Munet <naman.munet@ibm.com>
Mon, 27 Jul 2026 07:35:28 +0000 (13:05 +0530)
committerNaman Munet <naman.munet@ibm.com>
Thu, 30 Jul 2026 10:39:47 +0000 (16:09 +0530)
fixes: https://tracker-origin.ceph.com/issues/78684

Signed-off-by: Naman Munet <naman.munet@ibm.com>
src/pybind/mgr/dashboard/frontend/cypress/e2e/rgw/users.po.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.ts

index 16a79f8ec97ea9a585fe8d2881773aa500279e5d..219a66c066253a416ff928202110d639c31fe8cc 100644 (file)
@@ -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');
index 9daef795ab186757631739ce5865013d1b33cd2a..f05ae5e10e3a58c90529bbaf3326a590a42ebd11 100644 (file)
             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
           >
index ba474fc779b4ab352fa18f411a8dc5524f7ce630..4e3e35d78785dc67623072c222a889e973709458 100644 (file)
@@ -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,