]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: Fix NFS pseudo validation
authorTiago Melo <tmelo@suse.com>
Mon, 1 Apr 2019 14:13:37 +0000 (14:13 +0000)
committerTiago Melo <tmelo@suse.com>
Wed, 3 Apr 2019 19:16:33 +0000 (19:16 +0000)
Fixes: http://tracker.ceph.com/issues/39063
Signed-off-by: Tiago Melo <tmelo@suse.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.ts
src/pybind/mgr/dashboard/services/ganesha.py

index 60024884acb718fc57acf6cdc1d6931fd8a99bdc..1ebd776a05e17b59d901720394fc9a1c642756cd 100644 (file)
@@ -147,6 +147,16 @@ describe('NfsFormComponent', () => {
       });
     });
 
+    it('should remove "pseudo" requirement when NFS v4 disabled', () => {
+      component.nfsForm.patchValue({
+        protocolNfsv4: false,
+        pseudo: ''
+      });
+
+      component.nfsForm.updateValueAndValidity({ emitEvent: false });
+      expect(component.nfsForm.valid).toBeTruthy();
+    });
+
     it('should call update', () => {
       activatedRoute.setParams({ cluster_id: 'cluster1', export_id: '1' });
       component.isEdit = true;
index aa1ce7abb981ca8fc2847ccaaea2e1cc4cb1927d..48349f4a5583a9c1484ca027a73820cabe870e48 100644 (file)
@@ -169,7 +169,10 @@ export class NfsFormComponent implements OnInit {
       }),
       tag: new FormControl(''),
       pseudo: new FormControl('', {
-        validators: [Validators.required, Validators.pattern('^/[^><|&()]*$')]
+        validators: [
+          CdValidators.requiredIf({ protocolNfsv4: true }),
+          Validators.pattern('^/[^><|&()]*$')
+        ]
       }),
       access_type: new FormControl('RW', {
         validators: [Validators.required]
@@ -198,6 +201,10 @@ export class NfsFormComponent implements OnInit {
         CdValidators.requiredIf({ security_label: true, 'fsal.name': 'CEPH' })
       )
     });
+
+    this.nfsForm.get('protocolNfsv4').valueChanges.subscribe(() => {
+      this.nfsForm.get('pseudo').updateValueAndValidity({ emitEvent: false });
+    });
   }
 
   resolveModel(res) {
index 2fe427e5d946fd9de907483d95480d9fcae2debd..8a81e5bb35b05a1694d899681098c685a8af1393 100644 (file)
@@ -857,9 +857,10 @@ class GaneshaConf(object):
 
     @classmethod
     def format_path(cls, path):
-        path = path.strip()
-        if len(path) > 1 and path[-1] == '/':
-            path = path[:-1]
+        if path is not None:
+            path = path.strip()
+            if len(path) > 1 and path[-1] == '/':
+                path = path[:-1]
         return path
 
     def validate(self, export):