]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: type the rbd mirror modes 65874/head
authorNizamudeen A <nia@redhat.com>
Wed, 17 Sep 2025 11:10:48 +0000 (16:40 +0530)
committerNizamudeen A <nia@redhat.com>
Fri, 10 Oct 2025 10:27:43 +0000 (15:57 +0530)
Fixes: https://tracker.ceph.com/issues/72458
Signed-off-by: Nizamudeen A <nia@redhat.com>
(cherry picked from commit 93e34a7cb58e27f8c60c9b4b3927c2548aff907e)

src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-contants.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.ts

index abc78f7612dcb80548e220516abc4fea7ee5f514..e24ab43d6b5a15cecad437bb874bcdfdb42d4aaa 100644 (file)
@@ -16,9 +16,9 @@ export const RBDActionHelpers = {
 export const RBDPoolMirrorModes = {
   pool: 'pool',
   image: 'image'
-}
+};
 
 export const RBDMirroringModes = {
   journal: 'journal',
   snapshot: 'snapshot'
-}
+};
index 225c52510814adfadfa28cb29f114c1df5cb1b2d..999c129ad065813b7a55f73bb526481087f5b223 100644 (file)
@@ -98,7 +98,7 @@
 
       <!-- Size -->
       <div class="form-item">
-        <cds-text-label for="size"
+        <cds-text-label labelInputID="size"
                         i18n
                         [invalid]="!rbdForm.controls['size'].valid && (rbdForm.controls['size'].dirty)"
                         [invalidText]="sizeError"
                  type="text"
                  placeholder="e.g., 10GiB"
                  id="size"
-                 name="size"
                  formControlName="size"
                  defaultUnit="GiB"
                  [invalid]="!rbdForm.controls['size'].valid && (rbdForm.controls['size'].dirty)"
                 i18n>This field is required.</span>
           <span class="invalid-feedback"
                 *ngIf="rbdForm.showError('size', formDir, 'invalidSizeObject')"
-                i18n>You have to increase the size.</span>
+                i18n>Size must be increased.</span>
           <span *ngIf="rbdForm.showError('size', formDir, 'pattern')"
                 class="invalid-feedback"
                 i18n>Size must be a number or in a valid format. eg: 5 GiB</span>
       <div class="form-item"
            *ngIf="mode !== 'editing' && rbdForm.getValue('pool') && namespaces === null">
         <cds-select label="Namespace"
-                    for="namespace"
-                    name="namespace"
+                    labelInputID="namespace"
                     id="namespace"
                     [skeleton]="true"
                     formControlName="namespace">
       <div class="form-item"
            *ngIf="(mode === 'editing' && rbdForm.getValue('namespace')) || mode !== 'editing' && (namespaces && namespaces.length > 0 || !poolPermission.read)">
         <cds-text-label label="Namespace"
-                        id="namespace"
+                        labelInputID="namespace"
                         [helperText]="namespaceHelperTpl"
                         *ngIf="mode === 'editing' || !poolPermission.read"
                         i18n>Namespace
 
         <cds-select label="Namespace"
                     [helperText]="namespaceHelperTpl"
-                    for="namespace"
-                    name="namespace"
                     id="namespace"
                     formControlName="namespace"
                     (valueChange)="disableMirroring($event)"
 
       <!-- Snapshot Schedule Interval -->
       <div class="form-item"
-           *ngIf="rbdForm.getValue('mirroringMode') === 'snapshot' && mirroring">
+           *ngIf="rbdForm.getValue('mirroringMode') === rbdMirrorModes.snapshot && mirroring">
         <cds-text-label for="schedule"
                         helperText="Create Mirror-Snapshots automatically on a periodic basis. The interval can be specified in days, hours, or minutes using d, h, m suffix respectively. To create mirror snapshots, you must import or create and have available peers to mirror"
                         cdRequiredField="Schedule Interval"
index fdc6d35cc01474f8f5ed993f2c49217055288261..d1a6d496bfc8c5689d7f9ad9b8e469e5a395f4aa 100644 (file)
@@ -34,7 +34,7 @@ import { RbdFormEditRequestModel } from './rbd-form-edit-request.model';
 import { RbdFormMode } from './rbd-form-mode.enum';
 import { RbdFormResponseModel } from './rbd-form-response.model';
 import { CdValidators } from '~/app/shared/forms/cd-validators';
-import { RBDActionHelpers } from '../rbd-contants';
+import { RBDActionHelpers, RBDMirroringModes, RBDPoolMirrorModes } from '../rbd-contants';
 
 class ExternalData {
   rbd: RbdFormResponseModel;
@@ -77,13 +77,16 @@ export class RbdFormComponent extends CdForm implements OnInit {
   snapName: string;
   defaultObjectSize = '4 MiB';
 
+  rbdPoolMirrorModes = RBDPoolMirrorModes;
+  rbdMirrorModes = RBDMirroringModes;
+
   mirroringOptions = [
     {
-      value: 'journal',
+      value: this.rbdMirrorModes.journal,
       text: RBDActionHelpers.journalTooltipText
     },
     {
-      value: 'snapshot',
+      value: this.rbdMirrorModes.snapshot,
       text: RBDActionHelpers.snapshotTooltipText
     }
   ];
@@ -216,7 +219,7 @@ export class RbdFormComponent extends CdForm implements OnInit {
           validators: [
             Validators.pattern(/^([0-9]+)d|([0-9]+)h|([0-9]+)m$/),
             CdValidators.requiredIf({
-              mirroringMode: 'snapshot',
+              mirroringMode: this.rbdMirrorModes.snapshot,
               mirroring: true
             })
           ] // check schedule interval to be in format - 1d or 1h or 1m
@@ -272,7 +275,7 @@ export class RbdFormComponent extends CdForm implements OnInit {
   }
 
   setExclusiveLock() {
-    if (this.mirroring && this.rbdForm.get('mirroringMode').value === 'journal') {
+    if (this.mirroring && this.rbdForm.get('mirroringMode').value === this.rbdMirrorModes.journal) {
       this.rbdForm.get('exclusive-lock').setValue(true);
       this.rbdForm.get('exclusive-lock').disable();
     } else {
@@ -318,7 +321,7 @@ export class RbdFormComponent extends CdForm implements OnInit {
           } else {
             this.showMirrorDisableMessage = false;
           }
-          if (this.currentPoolMirrorMode !== 'image') {
+          if (this.currentPoolMirrorMode !== this.rbdPoolMirrorModes.image) {
             this.rbdForm.get('mirroring').disable();
             this.rbdForm.get('mirroringMode').disable();
           }
@@ -658,7 +661,10 @@ export class RbdFormComponent extends CdForm implements OnInit {
     }
     if (this.mode === this.rbdFormMode.editing) {
       this.rbdForm.get('name').setValue(response.name);
-      if (response?.mirror_mode === 'snapshot' || response.features_name.includes('journaling')) {
+      if (
+        response?.mirror_mode === this.rbdMirrorModes.snapshot ||
+        response.features_name.includes('journaling')
+      ) {
         this.mirroring = true;
         this.rbdForm.get('mirroring').setValue(this.mirroring);
         this.rbdForm.get('mirroringMode').setValue(response?.mirror_mode);
@@ -704,7 +710,7 @@ export class RbdFormComponent extends CdForm implements OnInit {
     request.size = this.formatter.toBytes(this.rbdForm.getValue('size'));
     this.addObjectSizeAndStripingToRequest(request);
     request.configuration = this.getDirtyConfigurationValues();
-    if (this.mirroring && this.currentPoolMirrorMode === 'image') {
+    if (this.mirroring && this.currentPoolMirrorMode === this.rbdPoolMirrorModes.image) {
       request.mirror_mode = this.rbdForm.getValue('mirroringMode');
     }
     return request;
@@ -720,7 +726,7 @@ export class RbdFormComponent extends CdForm implements OnInit {
       }
     });
 
-    if (this.mirroring && this.rbdForm.getValue('mirroringMode') === 'journal') {
+    if (this.mirroring && this.rbdForm.getValue('mirroringMode') === this.rbdMirrorModes.journal) {
       request.features.push('journaling');
     }
 
@@ -758,11 +764,11 @@ export class RbdFormComponent extends CdForm implements OnInit {
     });
     if (request.enable_mirror) {
       request.image_mirror_mode = this.currentImageMirrorMode;
-      if (this.rbdForm.getValue('mirroringMode') === 'journal') {
-        request.mirror_mode = 'journal';
+      if (this.rbdForm.getValue('mirroringMode') === this.rbdMirrorModes.journal) {
+        request.mirror_mode = this.rbdMirrorModes.journal;
         request.features.push('journaling');
       }
-      if (this.currentPoolMirrorMode === 'image') {
+      if (this.currentPoolMirrorMode === this.rbdPoolMirrorModes.image) {
         request.mirror_mode = this.rbdForm.getValue('mirroringMode');
       }
     } else {
@@ -856,16 +862,19 @@ export class RbdFormComponent extends CdForm implements OnInit {
   }
 
   shouldDisable(option: string): boolean {
-    return this.currentPoolMirrorMode === 'pool' && option === 'snapshot' ? true : false;
+    return (
+      this.currentPoolMirrorMode === this.rbdPoolMirrorModes.pool &&
+      option === this.rbdMirrorModes.snapshot
+    );
   }
 
   disableMirroring(namespace: string) {
     const mirroringControl = this.rbdForm.get('mirroring');
     if (namespace) {
       this.mirroring = false;
+      mirroringControl.setValue(false);
       mirroringControl.disable();
     } else {
-      this.mirroring = true;
       mirroringControl.enable();
     }
   }