From 4574407a9e3d2f210b0a50121f43356bf9a58c10 Mon Sep 17 00:00:00 2001 From: Volker Theile Date: Mon, 3 Sep 2018 16:29:29 +0200 Subject: [PATCH] mgr/dashboard: Make deletion dialog more touch device friendly * Refactor deletion dialog * Add directives.module.ts to be able to use 'autofocus' in deletion dialog Signed-off-by: Volker Theile --- .../ceph/block/rbd-list/rbd-list.component.ts | 1 - .../rbd-snapshot-list.component.ts | 1 - .../auth/role-list/role-list.component.ts | 1 - .../auth/user-list/user-list.component.ts | 1 - .../shared/components/components.module.ts | 4 +- .../deletion-modal.component.html | 56 +++++-------- .../deletion-modal.component.scss | 6 ++ .../deletion-modal.component.spec.ts | 82 ++++++------------- .../deletion-modal.component.ts | 24 +----- .../shared/directives/directives.module.ts | 24 ++++++ .../frontend/src/app/shared/shared.module.ts | 20 ++--- 11 files changed, 86 insertions(+), 134 deletions(-) create mode 100644 src/pybind/mgr/dashboard/frontend/src/app/shared/directives/directives.module.ts 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 1c14a8b6ebdba..2a4ac07d79e4b 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 @@ -201,7 +201,6 @@ export class RbdListComponent implements OnInit { this.modalRef = this.modalService.show(DeletionModalComponent); this.modalRef.content.setUp({ metaType: 'RBD', - pattern: `${poolName}/${imageName}`, deletionObserver: () => this.taskWrapper.wrapTaskAroundCall({ task: new FinishedTask('rbd/delete', { 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 09bfdaea5f9a7..c22ace30b2e92 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 @@ -256,7 +256,6 @@ export class RbdSnapshotListComponent implements OnInit, OnChanges { this.modalRef = this.modalService.show(DeletionModalComponent); this.modalRef.content.setUp({ metaType: 'RBD snapshot', - pattern: snapshotName, deletionMethod: () => this._asyncTask('deleteSnapshot', 'rbd/snap/delete', snapshotName), modalRef: this.modalRef }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-list/role-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-list/role-list.component.ts index 5919d38f32b01..cc668434e3bac 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-list/role-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-list/role-list.component.ts @@ -94,7 +94,6 @@ export class RoleListComponent implements OnInit { const name = this.selection.first().name; this.modalRef.content.setUp({ metaType: 'Role', - pattern: `${name}`, deletionMethod: () => this.deleteRole(name), modalRef: this.modalRef }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-list/user-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-list/user-list.component.ts index e4bbf9ff3e0bb..ea62fc24a6c6b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-list/user-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-list/user-list.component.ts @@ -103,7 +103,6 @@ export class UserListComponent implements OnInit { this.modalRef = this.modalService.show(DeletionModalComponent); this.modalRef.content.setUp({ metaType: 'User', - pattern: `${username}`, deletionMethod: () => this.deleteUser(username), modalRef: this.modalRef }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/components.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/components.module.ts index ae30c292ecafe..6d1376b1a2a02 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/components.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/components.module.ts @@ -5,6 +5,7 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { ChartsModule } from 'ng2-charts/ng2-charts'; import { AlertModule, ModalModule, PopoverModule, TooltipModule } from 'ngx-bootstrap'; +import { DirectivesModule } from '../directives/directives.module'; import { PipesModule } from '../pipes/pipes.module'; import { ConfirmationModalComponent } from './confirmation-modal/confirmation-modal.component'; import { DeletionModalComponent } from './deletion-modal/deletion-modal.component'; @@ -31,7 +32,8 @@ import { WarningPanelComponent } from './warning-panel/warning-panel.component'; ChartsModule, ReactiveFormsModule, PipesModule, - ModalModule.forRoot() + ModalModule.forRoot(), + DirectivesModule ], declarations: [ ViewCacheComponent, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/deletion-modal/deletion-modal.component.html b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/deletion-modal/deletion-modal.component.html index ca2f4ca5138de..a6dc08babdad4 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/deletion-modal/deletion-modal.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/deletion-modal/deletion-modal.component.html @@ -11,41 +11,27 @@ novalidate>