From 78a988f35dbb3daab8f1c75001d5dbcc92ae6528 Mon Sep 17 00:00:00 2001 From: Aashish Sharma Date: Thu, 13 Mar 2025 17:33:54 +0530 Subject: [PATCH] mgr/dashboard: Fix rgw user key modal not shown Fixes: https://tracker.ceph.com/issues/70450 Signed-off-by: Aashish Sharma --- .../frontend/cypress/e2e/rgw/users.e2e-spec.ts | 4 ++++ .../frontend/cypress/e2e/rgw/users.po.ts | 11 +++++++++++ .../rgw-user-details.component.spec.ts | 16 ++++++---------- .../rgw-user-details.component.ts | 12 ++++++------ 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/cypress/e2e/rgw/users.e2e-spec.ts b/src/pybind/mgr/dashboard/frontend/cypress/e2e/rgw/users.e2e-spec.ts index 396231b52b52..62060c958cad 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/e2e/rgw/users.e2e-spec.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/e2e/rgw/users.e2e-spec.ts @@ -24,6 +24,10 @@ describe('RGW users page', () => { users.getFirstTableCell(user_id).should('exist'); }); + it('should show user key details', () => { + users.checkUserKeys(user_name); + }); + it('should edit users full name, email and max buckets', () => { users.edit(user_name, 'Another Identity', 'changed@othersite.com', '1969'); }); 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 c2bc0bf5ff80..6a931faf17bd 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 @@ -155,4 +155,15 @@ export class UsersPageHelper extends PageHelper { this.navigateTo(); this.delete(tenant + '$' + uname, null, null, true, false, false, true); } + + checkUserKeys(user_name: string) { + this.getExpandCollapseElement(user_name).should('be.visible').click(); + cy.get('cd-table').contains('td', user_name).click(); + cy.get('cd-rgw-user-details cd-table').eq(0).first().click(); + cy.get("[aria-label='Show']").should('exist').click(); + cy.get('input#user').should('exist'); + cy.get('input#access_key').should('exist'); + cy.get('input#secret_key').should('exist'); + cy.get('cds-modal').should('exist'); + } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-details/rgw-user-details.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-details/rgw-user-details.component.spec.ts index 01b28dc3481d..c308bc6d94b1 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-details/rgw-user-details.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-details/rgw-user-details.component.spec.ts @@ -82,12 +82,10 @@ describe('RgwUserDetailsComponent', () => { component.keysSelection.first = () => { return { type: 'S3', ref: { user: '', access_key: '', secret_key: '' } }; }; - const modalShowSpy = spyOn(component['modalService'], 'show').and.callFake(() => { + const modalShowSpy = spyOn(component['cdsModalService'], 'show').and.callFake(() => { modalRef = { - componentInstance: { - setValues: jest.fn(), - setViewing: jest.fn() - } + setValues: jest.fn(), + setViewing: jest.fn() }; return modalRef; }); @@ -99,12 +97,10 @@ describe('RgwUserDetailsComponent', () => { component.keysSelection.first = () => { return { type: 'Swift', ref: { user: '', access_key: '', secret_key: '' } }; }; - const modalShowSpy = spyOn(component['modalService'], 'show').and.callFake(() => { + const modalShowSpy = spyOn(component['cdsModalService'], 'show').and.callFake(() => { modalRef = { - componentInstance: { - setValues: jest.fn(), - setViewing: jest.fn() - } + setValues: jest.fn(), + setViewing: jest.fn() }; return modalRef; }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-details/rgw-user-details.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-details/rgw-user-details.component.ts index 0accf141c785..dd2f6d35e209 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-details/rgw-user-details.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-details/rgw-user-details.component.ts @@ -6,7 +6,6 @@ import { RgwUserService } from '~/app/shared/api/rgw-user.service'; import { Icons } from '~/app/shared/enum/icons.enum'; import { CdTableColumn } from '~/app/shared/models/cd-table-column'; import { CdTableSelection } from '~/app/shared/models/cd-table-selection'; -import { ModalService } from '~/app/shared/services/modal.service'; import { RgwUserS3Key } from '../models/rgw-user-s3-key'; import { RgwUserSwiftKey } from '../models/rgw-user-swift-key'; import { RgwUserS3KeyModalComponent } from '../rgw-user-s3-key-modal/rgw-user-s3-key-modal.component'; @@ -14,6 +13,7 @@ import { RgwUserSwiftKeyModalComponent } from '../rgw-user-swift-key-modal/rgw-u import { CdTableAction } from '~/app/shared/models/cd-table-action'; import { Permissions } from '~/app/shared/models/permissions'; import { RgwRateLimitConfig } from '../models/rgw-rate-limit'; +import { ModalCdsService } from '~/app/shared/services/modal-cds.service'; @Component({ selector: 'cd-rgw-user-details', @@ -42,7 +42,7 @@ export class RgwUserDetailsComponent implements OnChanges, OnInit { icons = Icons; - constructor(private rgwUserService: RgwUserService, private modalService: ModalService) {} + constructor(private rgwUserService: RgwUserService, private cdsModalService: ModalCdsService) {} ngOnInit() { this.keysColumns = [ @@ -123,16 +123,16 @@ export class RgwUserDetailsComponent implements OnChanges, OnInit { showKeyModal() { const key = this.keysSelection.first(); - const modalRef = this.modalService.show( + const modalRef = this.cdsModalService.show( key.type === 'S3' ? RgwUserS3KeyModalComponent : RgwUserSwiftKeyModalComponent ); switch (key.type) { case 'S3': - modalRef.componentInstance.setViewing(); - modalRef.componentInstance.setValues(key.ref.user, key.ref.access_key, key.ref.secret_key); + modalRef.setViewing(); + modalRef.setValues(key.ref.user, key.ref.access_key, key.ref.secret_key); break; case 'Swift': - modalRef.componentInstance.setValues(key.ref.user, key.ref.secret_key); + modalRef.setValues(key.ref.user, key.ref.secret_key); break; } } -- 2.47.3