From 6eaac0d6ec5d9010c5b1771db3fa122a5eeacdcc Mon Sep 17 00:00:00 2001 From: Tiago Melo Date: Thu, 16 May 2019 23:19:31 +0000 Subject: [PATCH] mgr/dashboard: Unify action naming for NFS Fixes: http://tracker.ceph.com/issues/39102 Signed-off-by: Tiago Melo --- .../frontend/src/app/app-routing.module.ts | 13 +++++++++---- .../ceph/nfs/nfs-form/nfs-form.component.html | 14 +++++++------- .../app/ceph/nfs/nfs-form/nfs-form.component.ts | 10 +++++++++- .../ceph/nfs/nfs-list/nfs-list.component.spec.ts | 16 ++++++++-------- .../app/ceph/nfs/nfs-list/nfs-list.component.ts | 16 +++++++++------- 5 files changed, 42 insertions(+), 27 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts index 944847ff681d7..12250fddcc52c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts @@ -23,6 +23,7 @@ import { LoginComponent } from './core/auth/login/login.component'; import { SsoNotFoundComponent } from './core/auth/sso/sso-not-found/sso-not-found.component'; import { ForbiddenComponent } from './core/forbidden/forbidden.component'; import { NotFoundComponent } from './core/not-found/not-found.component'; +import { ActionLabels, URLVerbs } from './shared/constants/app.constants'; import { BreadcrumbsResolver, IBreadcrumb } from './shared/models/breadcrumbs'; import { AuthGuardService } from './shared/services/auth-guard.service'; import { FeatureTogglesGuardService } from './shared/services/feature-toggles-guard.service'; @@ -90,7 +91,7 @@ const routes: Routes = [ { path: 'edit/:name', component: ConfigurationFormComponent, - data: { breadcrumbs: 'Edit' } + data: { breadcrumbs: ActionLabels.EDIT } } ] }, @@ -206,11 +207,15 @@ const routes: Routes = [ }, children: [ { path: '', component: NfsListComponent }, - { path: 'add', component: NfsFormComponent, data: { breadcrumbs: 'Add' } }, { - path: 'edit/:cluster_id/:export_id', + path: URLVerbs.CREATE, component: NfsFormComponent, - data: { breadcrumbs: 'Edit' } + data: { breadcrumbs: ActionLabels.CREATE } + }, + { + path: `${URLVerbs.EDIT}/:cluster_id/:export_id`, + component: NfsFormComponent, + data: { breadcrumbs: ActionLabels.EDIT } } ] }, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.html index e3effc8a52516..d1300cb3d4174 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.html @@ -6,8 +6,8 @@ novalidate>
-

NFS export {{ export_id ? cluster_id + ':' + export_id : '' }}

+

{{ action | titlecase }} {{ resource | upperFirst }}

@@ -509,11 +509,11 @@ diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.ts index 124214f313159..540d8669a454b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.ts @@ -11,6 +11,7 @@ import { NfsService } from '../../../shared/api/nfs.service'; import { RgwUserService } from '../../../shared/api/rgw-user.service'; import { SelectMessages } from '../../../shared/components/select/select-messages.model'; import { SelectOption } from '../../../shared/components/select/select-option.model'; +import { ActionLabelsI18n } from '../../../shared/constants/app.constants'; import { CdFormBuilder } from '../../../shared/forms/cd-form-builder'; import { CdFormGroup } from '../../../shared/forms/cd-form-group'; import { CdValidators } from '../../../shared/forms/cd-validators'; @@ -51,6 +52,9 @@ export class NfsFormComponent implements OnInit { nfsAccessType: any[] = this.nfsService.nfsAccessType; nfsSquash: any[] = this.nfsService.nfsSquash; + action: string; + resource: string; + daemonsSelections: SelectOption[] = []; daemonsMessages = new SelectMessages( { noOptions: this.i18n('There are no daemons available.') }, @@ -77,9 +81,11 @@ export class NfsFormComponent implements OnInit { private formBuilder: CdFormBuilder, private taskWrapper: TaskWrapperService, private cdRef: ChangeDetectorRef, - private i18n: I18n + private i18n: I18n, + public actionLabels: ActionLabelsI18n ) { this.permission = this.authStorageService.getPermissions().pool; + this.resource = this.i18n('NFS export'); this.createForm(); } @@ -96,6 +102,7 @@ export class NfsFormComponent implements OnInit { } if (this.isEdit) { + this.action = this.actionLabels.EDIT; this.route.params.subscribe((params: { cluster_id: string; export_id: string }) => { this.cluster_id = decodeURIComponent(params.cluster_id); this.export_id = decodeURIComponent(params.export_id); @@ -104,6 +111,7 @@ export class NfsFormComponent implements OnInit { this.getData(promises); }); } else { + this.action = this.actionLabels.CREATE; this.getData(promises); } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-list/nfs-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-list/nfs-list.component.spec.ts index 056e6b45b053c..5d462da85bff6 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-list/nfs-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-list/nfs-list.component.spec.ts @@ -186,7 +186,7 @@ describe('NfsListComponent', () => { scenario = { fn: () => tableActions.getCurrentButton().name, single: 'Edit', - empty: 'Add' + empty: 'Create' }; }); @@ -195,7 +195,7 @@ describe('NfsListComponent', () => { 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)); it('shows all actions', () => { @@ -209,7 +209,7 @@ describe('NfsListComponent', () => { tableActions = permissionHelper.setPermissionsAndGetActions(1, 1, 0); }); - 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)); it(`shows all actions except for 'Delete'`, () => { @@ -224,12 +224,12 @@ describe('NfsListComponent', () => { 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' action`, () => { + it(`shows 'Create', and 'Delete' action`, () => { expect(tableActions.tableActions.length).toBe(2); expect(tableActions.tableActions).toEqual([ component.tableActions[0], @@ -262,12 +262,12 @@ describe('NfsListComponent', () => { tableActions = permissionHelper.setPermissionsAndGetActions(1, 0, 0); }); - it(`always shows 'Add' as main action`, () => { - scenario.single = 'Add'; + it(`always shows 'Create' as main action`, () => { + scenario.single = 'Create'; permissionHelper.testScenarios(scenario); }); - it(`shows 'Add' action`, () => { + it(`shows 'Create' action`, () => { expect(tableActions.tableActions.length).toBe(1); expect(tableActions.tableActions).toEqual([component.tableActions[0]]); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-list/nfs-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-list/nfs-list.component.ts index 2a52098923e09..14cbe2d664b9b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-list/nfs-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-list/nfs-list.component.ts @@ -7,6 +7,7 @@ import { Subscription } from 'rxjs'; import { NfsService } from '../../../shared/api/nfs.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'; @@ -61,7 +62,8 @@ export class NfsListComponent implements OnInit, OnDestroy { private modalService: BsModalService, private nfsService: NfsService, private taskListService: TaskListService, - private taskWrapper: TaskWrapperService + private taskWrapper: TaskWrapperService, + public actionLabels: ActionLabelsI18n ) { this.permission = this.authStorageService.getPermissions().nfs; const getNfsUri = () => @@ -70,29 +72,29 @@ export class NfsListComponent implements OnInit, OnDestroy { this.selection.first().export_id )}`; - const addAction: CdTableAction = { + const createAction: CdTableAction = { permission: 'create', icon: 'fa-plus', - routerLink: () => '/nfs/add', + routerLink: () => '/nfs/create', canBePrimary: (selection: CdTableSelection) => !selection.hasSingleSelection, - name: this.i18n('Add') + name: this.actionLabels.CREATE }; const editAction: CdTableAction = { permission: 'update', icon: 'fa-pencil', routerLink: () => `/nfs/edit/${getNfsUri()}`, - name: this.i18n('Edit') + name: this.actionLabels.EDIT }; const deleteAction: CdTableAction = { permission: 'delete', icon: 'fa-times', click: () => this.deleteNfsModal(), - name: this.i18n('Delete') + name: this.actionLabels.DELETE }; - this.tableActions = [addAction, editAction, deleteAction]; + this.tableActions = [createAction, editAction, deleteAction]; } ngOnInit() { -- 2.39.5