]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Unify action naming for NFS
authorTiago Melo <tmelo@suse.com>
Thu, 16 May 2019 23:19:31 +0000 (23:19 +0000)
committerTiago Melo <tmelo@suse.com>
Thu, 23 May 2019 11:05:18 +0000 (11:05 +0000)
Fixes: http://tracker.ceph.com/issues/39102
Signed-off-by: Tiago Melo <tmelo@suse.com>
src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-list/nfs-list.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-list/nfs-list.component.ts

index 944847ff681d746aced767074d9c81d94b366885..12250fddcc52c3f845b6f2920fda82a57a8a59ec 100644 (file)
@@ -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 }
       }
     ]
   },
index e3effc8a525168c7629c5b4fe7673e506c125773..d1300cb3d4174152130262bd2a774fd0cb3796e6 100644 (file)
@@ -6,8 +6,8 @@
         novalidate>
     <div class="panel panel-default">
       <div class="panel-heading">
-        <h3 class="panel-title"
-            i18n>NFS export {{ export_id ? cluster_id + ':' + export_id : '' }}</h3>
+        <h3 i18n="form title|Example: Create Pool@@formTitle"
+            class="panel-title">{{ action | titlecase }} {{ resource | upperFirst }}</h3>
       </div>
 
       <div class="panel-body">
 
       <div class="panel-footer">
         <div class="button-group text-right">
-          <cd-submit-button [form]="formDir"
-                            type="button"
-                            (submitAction)="submitAction()">
-            <ng-container i18n>Submit</ng-container>
-          </cd-submit-button>
+          <cd-submit-button
+            [form]="formDir"
+            (submitAction)="submitAction()"
+            i18n="form action button|Example: Create Pool@@formActionButton"
+            type="button">{{ action | titlecase }} {{ resource | upperFirst }}</cd-submit-button>
           <cd-back-button></cd-back-button>
         </div>
       </div>
index 124214f313159630911ada1212cdd3147013df13..540d8669a454bda97f1960950157ab7c895b7ad5 100644 (file)
@@ -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);
     }
   }
index 056e6b45b053c769bb74c846095047022f10d5a7..5d462da85bff64eb3d9c65d496154239eaedc910 100644 (file)
@@ -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]]);
       });
index 2a52098923e092d9c04ad6d35c5e796e3bde4af5..14cbe2d664b9bad79804ca375194a42c6e08b8a2 100644 (file)
@@ -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() {