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 <naman.munet@ibm.com>
This commit is contained in:
Naman Munet 2026-07-27 13:05:28 +05:30
parent 6beaf71d96
commit b9fccdffd2
3 changed files with 50 additions and 2 deletions

View 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');

View File

@ -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
>

View 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,