]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: rbd image primary ui
authorPedro Gonzalez Gomez <pegonzal@localhost.localdomain>
Fri, 3 Jun 2022 10:13:44 +0000 (12:13 +0200)
committerNizamudeen A <nia@redhat.com>
Tue, 16 Aug 2022 07:32:06 +0000 (13:02 +0530)
Resolves: rhbz#2115243

Signed-off-by: Pedro Gonzalez Gomez <pegonzal@redhat.com>
Signed-off-by: Pere Diaz Bou <pdiazbou@redhat.com>
(cherry picked from commit 1a17bd27a08d87ef24457788542f064f4e917d54)

src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form-edit-request.model.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts
src/pybind/mgr/dashboard/frontend/src/app/core/error/error.component.html
src/pybind/mgr/dashboard/frontend/src/app/core/error/error.component.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/constants/app.constants.ts

index 6d1f8c7d3c9fd561eddae9041b3a5ee296aa5d95..8b994d958a7246dbfcd67af3ab9da1203d7efd45 100644 (file)
@@ -8,6 +8,7 @@ export class RbdFormEditRequestModel {
 
   enable_mirror?: boolean;
   mirror_mode?: string;
+  primary?: boolean;
   schedule_interval: string;
   remove_scheduling? = false;
 }
index 824e05f8034f3df7db15664475bc8fbe4164e9df..0f68f2df252cfe7c20462028a8cf095a55e14ea2 100644 (file)
 </ng-template>
 
 <ng-template #mirroringTpl
-             let-value="value">
+             let-value="value"
+             let-row="row">
   <span *ngIf="value.length === 3; else probb"
         class="badge badge-info">{{ value[0] }}</span>&nbsp;
   <span *ngIf="value.length === 3"
         class="badge badge-info"
         [ngbTooltip]="'Next scheduled snapshot on' + ' ' + (value[2] | cdDate)">{{ value[1] }}</span>
+  <span *ngIf="row.primary === true"
+        class="badge badge-info"
+        i18n>primary</span>
+  <span *ngIf="row.primary === false"
+        class="badge badge-info"
+        i18n>secondary</span>
   <ng-template #probb>
     <span class="badge badge-info">{{ value }}</span>
   </ng-template>
index c6dde029233d649abf63adc1aa5b5ef509b656b3..f192d25e6f79385635836fbb1b9697914fa1bb47 100644 (file)
@@ -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: {
index 215f7f6f874ac8f29e9f3f96b7a57ad229900a50..86819762164fcee1968f37989f24dcda0aa05abf 100644 (file)
@@ -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;
index 5bda4e0476c4a8f8804b6cd77a174d65cb084ef2..164c181dab4bb76ad865ad9ed1c2dea5746a23bf 100644 (file)
@@ -30,7 +30,6 @@
         </div>
       </div>
     </div>
-    </ng-template>
   </div>
 </div>
 
index 6a995bc4e583a1a7f5212b2ca5761a9b5cfe538b..650121fb3c69b761063a0ad1ddeea838d13bcb2c 100644 (file)
@@ -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;
index 40d12653ea6b58c82e8b00ac118428aaa90e6d6e..913723e82273ea57a9d7a9b46cfacdfae1f80222 100644 (file)
@@ -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`;
   }
 }