From: Stephan Müller Date: Mon, 2 Jul 2018 17:33:13 +0000 (+0200) Subject: mgr/dashboard: Handle pool permissions X-Git-Tag: v14.0.1~96^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2d74c97c7c150def5a1fdeb7f7588484ef6f285e;p=ceph-ci.git mgr/dashboard: Handle pool permissions Handles pool action permissions in pool listing. Fixes: https://tracker.ceph.com/issues/36355 Signed-off-by: Stephan Müller --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.html index 8037c174809..ea84ca0d036 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.html @@ -5,55 +5,17 @@ [columns]="columns" selectionType="single" (updateSelection)="updateSelection($event)"> -
-
- - - - -
-
+ + - + { fixture = TestBed.createComponent(PoolListComponent); component = fixture.componentInstance; fixture.detectChanges(); + component.permission.read = true; }); it('should create', () => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.ts index 0e2562c2f44..887b74dcf7e 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-list/pool-list.component.ts @@ -3,14 +3,15 @@ import { Component } from '@angular/core'; import { BsModalRef, BsModalService } from 'ngx-bootstrap'; import { PoolService } from '../../../shared/api/pool.service'; -import { - DeletionModalComponent -} from '../../../shared/components/deletion-modal/deletion-modal.component'; +import { DeletionModalComponent } from '../../../shared/components/deletion-modal/deletion-modal.component'; +import { CdTableAction } from '../../../shared/models/cd-table-action'; import { CdTableColumn } from '../../../shared/models/cd-table-column'; import { CdTableFetchDataContext } from '../../../shared/models/cd-table-fetch-data-context'; import { CdTableSelection } from '../../../shared/models/cd-table-selection'; import { ExecutingTask } from '../../../shared/models/executing-task'; import { FinishedTask } from '../../../shared/models/finished-task'; +import { Permission } from '../../../shared/models/permissions'; +import { AuthStorageService } from '../../../shared/services/auth-storage.service'; import { TaskWrapperService } from '../../../shared/services/task-wrapper.service'; import { Pool } from '../pool'; @@ -25,12 +26,31 @@ export class PoolListComponent { selection = new CdTableSelection(); modalRef: BsModalRef; executingTasks: ExecutingTask[] = []; + permission: Permission; + tableActions: CdTableAction[]; constructor( private poolService: PoolService, private taskWrapper: TaskWrapperService, + private authStorageService: AuthStorageService, private modalService: BsModalService ) { + this.permission = this.authStorageService.getPermissions().pool; + this.tableActions = [ + { permission: 'create', icon: 'fa-plus', routerLink: () => '/pool/add', name: 'Add' }, + { + permission: 'update', + icon: 'fa-pencil', + routerLink: () => '/pool/edit/' + this.selection.first().pool_name, + name: 'Edit' + }, + { + permission: 'delete', + icon: 'fa-trash-o', + click: () => this.deletePoolModal(), + name: 'Delete' + } + ]; this.columns = [ { prop: 'pool_name',