]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: hide Report an Issue for users without config-opt read
authorAbhishek Desai <abhishek.desai1@ibm.com>
Mon, 6 Jul 2026 10:40:41 +0000 (16:10 +0530)
committerAbhishek Desai <abhishek.desai1@ibm.com>
Mon, 20 Jul 2026 08:36:13 +0000 (14:06 +0530)
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 <adesai@redhat.com>
src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.html
src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.ts

index 7c43de237e6c65806c67512f8fe9b41e4aa53b62..63fdec3d88095989cf7c6277f19c336d27fc09e5 100644 (file)
       ></svg>
     </a>
   </li>
-  <cds-overflow-menu-option
-    (click)="openAboutModal()"
-    i18n
-    >About</cds-overflow-menu-option
-  >
-  <cds-overflow-menu-option
-    (click)="openFeedbackModal()"
-    i18n
-    >Report an issue...</cds-overflow-menu-option
-  >
+  <cds-overflow-menu-option (click)="openAboutModal()"
+                            i18n>About</cds-overflow-menu-option>
+  @if (configOptPermission.read) {
+    <cds-overflow-menu-option (click)="openFeedbackModal()"
+                              i18n>Report an issue...</cds-overflow-menu-option>
+  }
 </cds-overflow-menu>
 
 <ng-template #customTrigger>
index 1c9e0a5f7e6b4b201cab82616eba56a2dd1286e5..7b836feb0b28a01fdefa11b4f55e509f4b4201ef 100644 (file)
@@ -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<DashboardHelpComponent>;
+  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);
+  });
 });
index 6a85bb4564e6efc389f5099e27635485d4182364..f2fae397142f124684029013ed48b0b57b27358c 100644 (file)
@@ -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) => {