From 2d74c97c7c150def5a1fdeb7f7588484ef6f285e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stephan=20M=C3=BCller?= Date: Mon, 2 Jul 2018 19:33:13 +0200 Subject: [PATCH] mgr/dashboard: Handle pool permissions MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Handles pool action permissions in pool listing. Fixes: https://tracker.ceph.com/issues/36355 Signed-off-by: Stephan Müller --- .../pool/pool-list/pool-list.component.html | 54 +++---------------- .../pool-list/pool-list.component.spec.ts | 1 + .../pool/pool-list/pool-list.component.ts | 26 +++++++-- 3 files changed, 32 insertions(+), 49 deletions(-) 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 8037c1748099d..ea84ca0d036aa 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 0e2562c2f4443..887b74dcf7e61 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', -- 2.39.5