From: Abhishek Desai Date: Mon, 6 Jul 2026 10:40:41 +0000 (+0530) Subject: mgr/dashboard: hide Report an Issue for users without config-opt read X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=21c6df7d22b7f7de7a2bf9e97fae981827318207;p=ceph.git mgr/dashboard: hide Report an Issue for users without config-opt read The Help menu option redirected read-only users to an Access Denied page. Hide it when the user lacks config-opt read permission. Fixes: https://tracker.ceph.com/issues/77952 Signed-off-by: Abhishek Desai --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.html b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.html index 7c43de237e6..63fdec3d880 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.html @@ -31,16 +31,12 @@ > - About - Report an issue... + About + @if (configOptPermission.read) { + Report an issue... + } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.spec.ts index 1c9e0a5f7e6..7b836feb0b2 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.spec.ts @@ -1,21 +1,29 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { By } from '@angular/platform-browser'; import { RouterTestingModule } from '@angular/router/testing'; import { SharedModule } from '~/app/shared/shared.module'; +import { AuthStorageService } from '~/app/shared/services/auth-storage.service'; +import { Permission, Permissions } from '~/app/shared/models/permissions'; import { configureTestBed } from '~/testing/unit-test-helper'; import { DashboardHelpComponent } from './dashboard-help.component'; describe('DashboardHelpComponent', () => { let component: DashboardHelpComponent; let fixture: ComponentFixture; + let permissions: Permissions; configureTestBed({ imports: [HttpClientTestingModule, SharedModule, RouterTestingModule], - declarations: [DashboardHelpComponent] + declarations: [DashboardHelpComponent], + providers: [AuthStorageService] }); beforeEach(() => { + permissions = new Permissions({}); + permissions.configOpt = new Permission(['read']); + spyOn(TestBed.inject(AuthStorageService), 'getPermissions').and.returnValue(permissions); fixture = TestBed.createComponent(DashboardHelpComponent); component = fixture.componentInstance; fixture.detectChanges(); @@ -24,4 +32,16 @@ describe('DashboardHelpComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + it('should hide report issue when config-opt is not readable', () => { + permissions.configOpt = new Permission([]); + (TestBed.inject(AuthStorageService).getPermissions as jasmine.Spy).and.returnValue(permissions); + + fixture = TestBed.createComponent(DashboardHelpComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + + const options = fixture.debugElement.queryAll(By.css('cds-overflow-menu-option')); + expect(options.length).toBe(3); + }); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.ts index 6a85bb4564e..f2fae397142 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.ts @@ -1,6 +1,8 @@ import { Component, OnInit } from '@angular/core'; import { Icons } from '~/app/shared/enum/icons.enum'; +import { Permission } from '~/app/shared/models/permissions'; +import { AuthStorageService } from '~/app/shared/services/auth-storage.service'; import { DocService } from '~/app/shared/services/doc.service'; import { AboutComponent } from '../about/about.component'; @@ -16,11 +18,15 @@ import { FeedbackComponent } from '~/app/ceph/shared/feedback/feedback.component export class DashboardHelpComponent implements OnInit { docsUrl: string; icons = Icons; + configOptPermission: Permission; constructor( private docService: DocService, - private modalCdsService: ModalCdsService - ) {} + private modalCdsService: ModalCdsService, + private authStorageService: AuthStorageService + ) { + this.configOptPermission = this.authStorageService.getPermissions().configOpt; + } ngOnInit() { this.docService.subscribeOnce('dashboard', (url: string) => {