From 2ec694566adf7b0467b869a9a259ddf7e52d6fe1 Mon Sep 17 00:00:00 2001 From: Tiago Melo Date: Fri, 17 May 2019 10:55:43 +0000 Subject: [PATCH] mgr/dashboard: Unify the labels on all table actions objects Fixes: http://tracker.ceph.com/issues/39102 Signed-off-by: Tiago Melo --- .../src/app/ceph/block/block.module.ts | 4 +-- .../iscsi-target-list.component.spec.ts | 14 ++++---- .../iscsi-target-list.component.ts | 12 ++++--- .../ceph/block/rbd-list/rbd-list.component.ts | 6 ++-- .../rbd-snapshot-actions.model.ts | 19 +++++----- .../rbd-snapshot-list.component.spec.ts | 5 ++- .../rbd-snapshot-list.component.ts | 6 ++-- .../rbd-trash-list.component.ts | 8 +++-- .../configuration/configuration.component.ts | 6 ++-- .../osd/osd-list/osd-list.component.ts | 22 ++++++------ .../src/app/shared/constants/app.constants.ts | 35 +++++++++++++++++-- 11 files changed, 91 insertions(+), 46 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/block.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/block.module.ts index b4322d2d0fdf4..ca56b9623aee3 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/block.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/block.module.ts @@ -149,9 +149,9 @@ const routes: Routes = [ children: [ { path: '', component: IscsiTargetListComponent }, { - path: URLVerbs.ADD, + path: URLVerbs.CREATE, component: IscsiTargetFormComponent, - data: { breadcrumbs: ActionLabels.ADD } + data: { breadcrumbs: ActionLabels.CREATE } }, { path: `${URLVerbs.EDIT}/:target_iqn`, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-list/iscsi-target-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-list/iscsi-target-list.component.spec.ts index 7a48d2ab6bf22..09070055170fb 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-list/iscsi-target-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-list/iscsi-target-list.component.spec.ts @@ -190,7 +190,7 @@ describe('IscsiTargetListComponent', () => { scenario = { fn: () => tableActions.getCurrentButton().name, single: 'Edit', - empty: 'Add' + empty: 'Create' }; }); @@ -199,7 +199,7 @@ describe('IscsiTargetListComponent', () => { tableActions = permissionHelper.setPermissionsAndGetActions(1, 1, 1); }); - it(`shows 'Edit' for single selection else 'Add' as main action`, () => { + it(`shows 'Edit' for single selection else 'Create' as main action`, () => { permissionHelper.testScenarios(scenario); }); @@ -231,12 +231,12 @@ describe('IscsiTargetListComponent', () => { tableActions = permissionHelper.setPermissionsAndGetActions(1, 0, 1); }); - it(`shows 'Delete' for single selection else 'Add' as main action`, () => { + it(`shows 'Delete' for single selection else 'Create' as main action`, () => { scenario.single = 'Delete'; permissionHelper.testScenarios(scenario); }); - it(`shows 'Add' and 'Delete' actions`, () => { + it(`shows 'Create' and 'Delete' actions`, () => { expect(tableActions.tableActions.length).toBe(2); expect(tableActions.tableActions).toEqual([ component.tableActions[0], @@ -269,12 +269,12 @@ describe('IscsiTargetListComponent', () => { tableActions = permissionHelper.setPermissionsAndGetActions(1, 0, 0); }); - it(`shows 'Add' for single selection and 'Add' as main action`, () => { - scenario.single = 'Add'; + it(`shows 'Create' for single selection and 'Create' as main action`, () => { + scenario.single = 'Create'; permissionHelper.testScenarios(scenario); }); - it(`shows 'Add' actions`, () => { + it(`shows 'Create' actions`, () => { expect(tableActions.tableActions.length).toBe(1); expect(tableActions.tableActions).toEqual([component.tableActions[0]]); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-list/iscsi-target-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-list/iscsi-target-list.component.ts index c1f66967f9b56..42a2a80b7751e 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-list/iscsi-target-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-list/iscsi-target-list.component.ts @@ -6,6 +6,7 @@ import { Subscription } from 'rxjs'; import { IscsiService } from '../../../shared/api/iscsi.service'; import { CriticalConfirmationModalComponent } from '../../../shared/components/critical-confirmation-modal/critical-confirmation-modal.component'; +import { ActionLabelsI18n } from '../../../shared/constants/app.constants'; import { TableComponent } from '../../../shared/datatable/table/table.component'; import { CellTemplate } from '../../../shared/enum/cell-template.enum'; import { CdTableAction } from '../../../shared/models/cd-table-action'; @@ -58,7 +59,8 @@ export class IscsiTargetListComponent implements OnInit, OnDestroy { private cephReleaseNamePipe: CephReleaseNamePipe, private summaryservice: SummaryService, private modalService: BsModalService, - private taskWrapper: TaskWrapperService + private taskWrapper: TaskWrapperService, + public actionLabels: ActionLabelsI18n ) { this.permissions = this.authStorageService.getPermissions(); @@ -66,20 +68,20 @@ export class IscsiTargetListComponent implements OnInit, OnDestroy { { permission: 'create', icon: 'fa-plus', - routerLink: () => '/block/iscsi/targets/add', - name: this.i18n('Add') + routerLink: () => '/block/iscsi/targets/create', + name: this.actionLabels.CREATE }, { permission: 'update', icon: 'fa-pencil', routerLink: () => `/block/iscsi/targets/edit/${this.selection.first().target_iqn}`, - name: this.i18n('Edit') + name: this.actionLabels.EDIT }, { permission: 'delete', icon: 'fa-times', click: () => this.deleteIscsiTargetModal(), - name: this.i18n('Delete') + name: this.actionLabels.DELETE } ]; } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts index 0ba72c8ef6797..de6eca2aa81e5 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts @@ -120,7 +120,7 @@ export class RbdListComponent implements OnInit { !selection.hasSingleSelection || selection.first().cdExecuting, icon: 'fa-copy', routerLink: () => `/block/rbd/copy/${getImageUri()}`, - name: this.i18n('Copy') + name: this.actionLabels.COPY }; const flattenAction: CdTableAction = { permission: 'update', @@ -128,13 +128,13 @@ export class RbdListComponent implements OnInit { !selection.hasSingleSelection || selection.first().cdExecuting || !selection.first().parent, icon: 'fa-chain-broken', click: () => this.flattenRbdModal(), - name: this.i18n('Flatten') + name: this.actionLabels.FLATTEN }; const moveAction: CdTableAction = { permission: 'delete', icon: 'fa-trash-o', click: () => this.trashRbdModal(), - name: this.i18n('Move to Trash') + name: this.actionLabels.TRASH }; this.tableActions = [ addAction, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-actions.model.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-actions.model.ts index eb408eb5f2d0f..b3e3a186a3a7c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-actions.model.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-actions.model.ts @@ -1,5 +1,6 @@ import { I18n } from '@ngx-translate/i18n-polyfill'; +import { ActionLabelsI18n } from '../../../shared/constants/app.constants'; import { CdTableAction } from '../../../shared/models/cd-table-action'; import { CdTableSelection } from '../../../shared/models/cd-table-selection'; @@ -16,32 +17,32 @@ export class RbdSnapshotActionsModel { deleteSnap: CdTableAction; ordering: CdTableAction[]; - constructor(i18n: I18n) { + constructor(i18n: I18n, actionLabels: ActionLabelsI18n) { this.i18n = i18n; this.create = { permission: 'create', icon: 'fa-plus', - name: this.i18n('Create') + name: actionLabels.CREATE }; this.rename = { permission: 'update', icon: 'fa-pencil', - name: this.i18n('Rename') + name: actionLabels.RENAME }; this.protect = { permission: 'update', icon: 'fa-lock', visible: (selection: CdTableSelection) => selection.hasSingleSelection && !selection.first().is_protected, - name: this.i18n('Protect') + name: actionLabels.PROTECT }; this.unprotect = { permission: 'update', icon: 'fa-unlock', visible: (selection: CdTableSelection) => selection.hasSingleSelection && selection.first().is_protected, - name: this.i18n('Unprotect') + name: actionLabels.UNPROTECT }; this.clone = { permission: 'create', @@ -49,7 +50,7 @@ export class RbdSnapshotActionsModel { disable: (selection: CdTableSelection) => !selection.hasSingleSelection || selection.first().cdExecuting, icon: 'fa-clone', - name: this.i18n('Clone') + name: actionLabels.CLONE }; this.copy = { permission: 'create', @@ -57,12 +58,12 @@ export class RbdSnapshotActionsModel { disable: (selection: CdTableSelection) => !selection.hasSingleSelection || selection.first().cdExecuting, icon: 'fa-copy', - name: this.i18n('Copy') + name: actionLabels.COPY }; this.rollback = { permission: 'update', icon: 'fa-undo', - name: this.i18n('Rollback') + name: actionLabels.ROLLBACK }; this.deleteSnap = { permission: 'delete', @@ -71,7 +72,7 @@ export class RbdSnapshotActionsModel { const first = selection.first(); return !selection.hasSingleSelection || first.cdExecuting || first.is_protected; }, - name: this.i18n('Delete') + name: actionLabels.DELETE }; this.ordering = [ diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.spec.ts index e6d0031b6d5e7..0159f99cc9d0e 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.spec.ts @@ -16,6 +16,7 @@ import { import { ApiModule } from '../../../shared/api/api.module'; import { RbdService } from '../../../shared/api/rbd.service'; import { ComponentsModule } from '../../../shared/components/components.module'; +import { ActionLabelsI18n } from '../../../shared/constants/app.constants'; import { DataTableModule } from '../../../shared/datatable/datatable.module'; import { TableActionsComponent } from '../../../shared/datatable/table-actions/table-actions.component'; import { ExecutingTask } from '../../../shared/models/executing-task'; @@ -82,6 +83,7 @@ describe('RbdSnapshotListComponent', () => { beforeEach(() => { fixture.detectChanges(); const i18n = TestBed.get(I18n); + const actionLabelsI18n = TestBed.get(ActionLabelsI18n); called = false; rbdService = new RbdService(null, null); notificationService = new NotificationService(null, null, null); @@ -97,7 +99,8 @@ describe('RbdSnapshotListComponent', () => { notificationService, null, null, - i18n + i18n, + actionLabelsI18n ); spyOn(rbdService, 'deleteSnapshot').and.returnValue(observableThrowError({ status: 500 })); spyOn(notificationService, 'notifyTask').and.stub(); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.ts index 101525bf30b55..e8ef32a41114a 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.ts @@ -8,6 +8,7 @@ import { of } from 'rxjs'; import { RbdService } from '../../../shared/api/rbd.service'; import { ConfirmationModalComponent } from '../../../shared/components/confirmation-modal/confirmation-modal.component'; import { CriticalConfirmationModalComponent } from '../../../shared/components/critical-confirmation-modal/critical-confirmation-modal.component'; +import { ActionLabelsI18n } from '../../../shared/constants/app.constants'; import { CellTemplate } from '../../../shared/enum/cell-template.enum'; import { CdTableAction } from '../../../shared/models/cd-table-action'; import { CdTableColumn } from '../../../shared/models/cd-table-column'; @@ -74,10 +75,11 @@ export class RbdSnapshotListComponent implements OnInit, OnChanges { private notificationService: NotificationService, private summaryService: SummaryService, private taskListService: TaskListService, - private i18n: I18n + private i18n: I18n, + private actionLabels: ActionLabelsI18n ) { this.permission = this.authStorageService.getPermissions().rbdImage; - const actions = new RbdSnapshotActionsModel(this.i18n); + const actions = new RbdSnapshotActionsModel(this.i18n, this.actionLabels); actions.create.click = () => this.openCreateSnapshotModal(); actions.rename.click = () => this.openEditSnapshotModal(); actions.protect.click = () => this.toggleProtection(); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-list/rbd-trash-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-list/rbd-trash-list.component.ts index 71f32dbeb2845..f5770ebdddf59 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-list/rbd-trash-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-list/rbd-trash-list.component.ts @@ -7,6 +7,7 @@ import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; import { RbdService } from '../../../shared/api/rbd.service'; import { CriticalConfirmationModalComponent } from '../../../shared/components/critical-confirmation-modal/critical-confirmation-modal.component'; +import { ActionLabelsI18n } from '../../../shared/constants/app.constants'; import { TableComponent } from '../../../shared/datatable/table/table.component'; import { CellTemplate } from '../../../shared/enum/cell-template.enum'; import { ViewCacheStatus } from '../../../shared/enum/view-cache-status.enum'; @@ -54,7 +55,8 @@ export class RbdTrashListComponent implements OnInit { private cdDatePipe: CdDatePipe, private taskListService: TaskListService, private taskWrapper: TaskWrapperService, - private i18n: I18n + private i18n: I18n, + public actionLabels: ActionLabelsI18n ) { this.permission = this.authStorageService.getPermissions().rbdImage; @@ -62,13 +64,13 @@ export class RbdTrashListComponent implements OnInit { permission: 'update', icon: 'fa-undo', click: () => this.restoreModal(), - name: this.i18n('Restore') + name: this.actionLabels.RESTORE }; const deleteAction: CdTableAction = { permission: 'delete', icon: 'fa-times', click: () => this.deleteModal(), - name: this.i18n('Delete') + name: this.actionLabels.DELETE }; this.tableActions = [restoreAction, deleteAction]; } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration.component.ts index f504d54485321..82ea4b444e68d 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration.component.ts @@ -3,6 +3,7 @@ import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core'; import { I18n } from '@ngx-translate/i18n-polyfill'; import { ConfigurationService } from '../../../shared/api/configuration.service'; +import { ActionLabelsI18n } from '../../../shared/constants/app.constants'; import { CellTemplate } from '../../../shared/enum/cell-template.enum'; import { CdTableAction } from '../../../shared/models/cd-table-action'; import { CdTableColumn } from '../../../shared/models/cd-table-column'; @@ -83,7 +84,8 @@ export class ConfigurationComponent implements OnInit { constructor( private authStorageService: AuthStorageService, private configurationService: ConfigurationService, - private i18n: I18n + private i18n: I18n, + public actionLabels: ActionLabelsI18n ) { this.permission = this.authStorageService.getPermissions().configOpt; const getConfigOptUri = () => @@ -92,7 +94,7 @@ export class ConfigurationComponent implements OnInit { permission: 'update', icon: 'fa-pencil', routerLink: () => `/configuration/edit/${getConfigOptUri()}`, - name: this.i18n('Edit'), + name: this.actionLabels.EDIT, disable: () => !this.isEditable(this.selection) }; this.tableActions = [editAction]; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts index 7fe5abd41b0ce..86cd7bd0ab503 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts @@ -7,6 +7,7 @@ import { Observable } from 'rxjs'; import { OsdService } from '../../../../shared/api/osd.service'; import { ConfirmationModalComponent } from '../../../../shared/components/confirmation-modal/confirmation-modal.component'; import { CriticalConfirmationModalComponent } from '../../../../shared/components/critical-confirmation-modal/critical-confirmation-modal.component'; +import { ActionLabelsI18n } from '../../../../shared/constants/app.constants'; import { TableComponent } from '../../../../shared/datatable/table/table.component'; import { CellTemplate } from '../../../../shared/enum/cell-template.enum'; import { CdTableAction } from '../../../../shared/models/cd-table-action'; @@ -58,54 +59,55 @@ export class OsdListComponent implements OnInit { private osdService: OsdService, private dimlessBinaryPipe: DimlessBinaryPipe, private modalService: BsModalService, - private i18n: I18n + private i18n: I18n, + public actionLabels: ActionLabelsI18n ) { this.permissions = this.authStorageService.getPermissions(); this.tableActions = [ { - name: this.i18n('Scrub'), + name: this.actionLabels.SCRUB, permission: 'update', icon: 'fa-stethoscope', click: () => this.scrubAction(false), disable: () => !this.hasOsdSelected }, { - name: this.i18n('Deep Scrub'), + name: this.actionLabels.DEEP_SCRUB, permission: 'update', icon: 'fa-cog', click: () => this.scrubAction(true), disable: () => !this.hasOsdSelected }, { - name: this.i18n('Reweight'), + name: this.actionLabels.REWEIGHT, permission: 'update', click: () => this.reweight(), disable: () => !this.hasOsdSelected, icon: 'fa-balance-scale' }, { - name: this.i18n('Mark Out'), + name: this.actionLabels.MARK_OUT, permission: 'update', click: () => this.showConfirmationModal(this.i18n('out'), this.osdService.markOut), disable: () => this.isNotSelectedOrInState('out'), icon: 'fa-arrow-left' }, { - name: this.i18n('Mark In'), + name: this.actionLabels.MARK_IN, permission: 'update', click: () => this.showConfirmationModal(this.i18n('in'), this.osdService.markIn), disable: () => this.isNotSelectedOrInState('in'), icon: 'fa-arrow-right' }, { - name: this.i18n('Mark Down'), + name: this.actionLabels.MARK_DOWN, permission: 'update', click: () => this.showConfirmationModal(this.i18n('down'), this.osdService.markDown), disable: () => this.isNotSelectedOrInState('down'), icon: 'fa-arrow-down' }, { - name: this.i18n('Mark Lost'), + name: this.actionLabels.MARK_LOST, permission: 'delete', click: () => this.showCriticalConfirmationModal( @@ -118,7 +120,7 @@ export class OsdListComponent implements OnInit { icon: 'fa-unlink' }, { - name: this.i18n('Purge'), + name: this.actionLabels.PURGE, permission: 'delete', click: () => this.showCriticalConfirmationModal( @@ -131,7 +133,7 @@ export class OsdListComponent implements OnInit { icon: 'fa-eraser' }, { - name: this.i18n('Destroy'), + name: this.actionLabels.DESTROY, permission: 'delete', click: () => this.showCriticalConfirmationModal( diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/constants/app.constants.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/constants/app.constants.ts index c60d8d7544477..15bafc6c7da8a 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/constants/app.constants.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/constants/app.constants.ts @@ -74,7 +74,23 @@ export class ActionLabelsI18n { CANCEL: string; COPY: string; CLONE: string; + DEEP_SCRUB: string; + DESTROY: string; + FLATTEN: string; + MARK_DOWN: string; + MARK_IN: string; + MARK_LOST: string; + MARK_OUT: string; + PROTECT: string; + PURGE: string; + RENAME: string; + RESTORE: string; + REWEIGHT: string; + ROLLBACK: string; + SCRUB: string; SHOW: string; + TRASH: string; + UNPROTECT: string; constructor(private i18n: I18n) { /* Create a new item */ @@ -94,9 +110,24 @@ export class ActionLabelsI18n { this.CANCEL = this.i18n('Cancel'); /* Non-standard actions */ - this.COPY = this.i18n('Copy'); this.CLONE = this.i18n('Clone'); - + this.COPY = this.i18n('Copy'); + this.DEEP_SCRUB = this.i18n('Deep Scrub'); + this.DESTROY = this.i18n('Destroy'); + this.FLATTEN = this.i18n('Flatten'); + this.MARK_DOWN = this.i18n('Mark Down'); + this.MARK_IN = this.i18n('Mark In'); + this.MARK_LOST = this.i18n('Mark Lost'); + this.MARK_OUT = this.i18n('Mark Out'); + this.PROTECT = this.i18n('Protect'); + this.PURGE = this.i18n('Purge'); + this.RENAME = this.i18n('Rename'); + this.RESTORE = this.i18n('Restore'); + this.REWEIGHT = this.i18n('Reweight'); + this.ROLLBACK = this.i18n('Rollback'); + this.SCRUB = this.i18n('Scrub'); this.SHOW = this.i18n('Show'); + this.TRASH = this.i18n('Move to Trash'); + this.UNPROTECT = this.i18n('Unprotect'); } } -- 2.39.5