From: Pedro Gonzalez Gomez Date: Fri, 3 Jun 2022 10:13:44 +0000 (+0200) Subject: mgr/dashboard: rbd image primary ui X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=6cc81723601884a03c9796e61bd79a0896a05a37;p=ceph.git mgr/dashboard: rbd image primary ui Resolves: rhbz#2115243 Signed-off-by: Pedro Gonzalez Gomez Signed-off-by: Pere Diaz Bou (cherry picked from commit 1a17bd27a08d87ef24457788542f064f4e917d54) --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form-edit-request.model.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form-edit-request.model.ts index 6d1f8c7d3c9fd..8b994d958a724 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form-edit-request.model.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form-edit-request.model.ts @@ -8,6 +8,7 @@ export class RbdFormEditRequestModel { enable_mirror?: boolean; mirror_mode?: string; + primary?: boolean; schedule_interval: string; remove_scheduling? = false; } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.html index 824e05f8034f3..0f68f2df252cf 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.html @@ -57,12 +57,19 @@ + let-value="value" + let-row="row"> {{ value[0] }}  {{ value[1] }} + primary + secondary {{ value }} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.spec.ts index c6dde029233d6..f192d25e6f793 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.spec.ts @@ -322,12 +322,23 @@ describe('RbdListComponent', () => { 'Resync', 'Delete', 'Move to Trash', - 'Remove Scheduling' + 'Remove Scheduling', + 'Promote', + 'Demote' ], primary: { multiple: 'Create', executing: 'Edit', single: 'Edit', no: 'Create' } }, 'create,update': { - actions: ['Create', 'Edit', 'Copy', 'Flatten', 'Resync', 'Remove Scheduling'], + actions: [ + 'Create', + 'Edit', + 'Copy', + 'Flatten', + 'Resync', + 'Remove Scheduling', + 'Promote', + 'Demote' + ], primary: { multiple: 'Create', executing: 'Edit', single: 'Edit', no: 'Create' } }, 'create,delete': { @@ -339,11 +350,20 @@ describe('RbdListComponent', () => { primary: { multiple: 'Create', executing: 'Copy', single: 'Copy', no: 'Create' } }, 'update,delete': { - actions: ['Edit', 'Flatten', 'Resync', 'Delete', 'Move to Trash', 'Remove Scheduling'], + actions: [ + 'Edit', + 'Flatten', + 'Resync', + 'Delete', + 'Move to Trash', + 'Remove Scheduling', + 'Promote', + 'Demote' + ], primary: { multiple: 'Edit', executing: 'Edit', single: 'Edit', no: 'Edit' } }, update: { - actions: ['Edit', 'Flatten', 'Resync', 'Remove Scheduling'], + actions: ['Edit', 'Flatten', 'Resync', 'Remove Scheduling', 'Promote', 'Demote'], primary: { multiple: 'Edit', executing: 'Edit', single: 'Edit', no: 'Edit' } }, 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 215f7f6f874ac..86819762164fc 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 @@ -202,6 +202,20 @@ export class RbdListComponent extends ListWithDetails implements OnInit { this.getInvalidNameDisable(selection) || selection.first().schedule_info === undefined }; + const promoteAction: CdTableAction = { + permission: 'update', + icon: Icons.edit, + click: () => this.actionPrimary(true), + name: this.actionLabels.PROMOTE, + visible: () => this.selection.first() != null && !this.selection.first().primary + }; + const demoteAction: CdTableAction = { + permission: 'update', + icon: Icons.edit, + click: () => this.actionPrimary(false), + name: this.actionLabels.DEMOTE, + visible: () => this.selection.first() != null && this.selection.first().primary + }; this.tableActions = [ addAction, editAction, @@ -210,7 +224,9 @@ export class RbdListComponent extends ListWithDetails implements OnInit { resyncAction, deleteAction, moveAction, - removeSchedulingAction + removeSchedulingAction, + promoteAction, + demoteAction ]; } @@ -530,6 +546,24 @@ export class RbdListComponent extends ListWithDetails implements OnInit { }); } + actionPrimary(primary: boolean) { + const request = new RbdFormEditRequestModel(); + request.primary = primary; + const imageSpec = new ImageSpec( + this.selection.first().pool_name, + this.selection.first().namespace, + this.selection.first().name + ); + this.taskWrapper + .wrapTaskAroundCall({ + task: new FinishedTask('rbd/edit', { + image_spec: imageSpec.toString() + }), + call: this.rbdService.update(imageSpec, request) + }) + .subscribe(); + } + hasSnapshots() { const snapshots = this.selection.first()['snapshots'] || []; return snapshots.length > 0; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/error/error.component.html b/src/pybind/mgr/dashboard/frontend/src/app/core/error/error.component.html index 5bda4e0476c4a..164c181dab4bb 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/error/error.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/error/error.component.html @@ -30,7 +30,6 @@ - diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/error/error.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/error/error.component.ts index 6a995bc4e583a..650121fb3c69b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/error/error.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/error/error.component.ts @@ -75,13 +75,9 @@ export class ErrorComponent implements OnDestroy, OnInit { this.message = history.state.message; this.header = history.state.header; this.section = history.state.section; -<<<<<<< HEAD this.section_info = history.state.section_info; this.button_name = history.state.button_name; this.button_route = history.state.button_route; -======= - this.sectionInfo = history.state.section_info; ->>>>>>> 5b33f500f5d (mgr/dashboard: Error page cleanup) this.icon = history.state.icon; this.source = history.state.source; this.uiConfig = history.state.uiConfig; 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 40d12653ea6b5..913723e82273e 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 @@ -131,6 +131,8 @@ export class ActionLabelsI18n { ENTER_MAINTENANCE: string; EXIT_MAINTENANCE: string; REMOVE_SCHEDULING: string; + PROMOTE: string; + DEMOTE: string; START_DRAIN: string; STOP_DRAIN: string; START: string; @@ -205,6 +207,8 @@ export class ActionLabelsI18n { this.RESTART = $localize`Restart`; this.REMOVE_SCHEDULING = $localize`Remove Scheduling`; + this.PROMOTE = $localize`Promote`; + this.DEMOTE = $localize`Demote`; } }