]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: disable cluster selection in NFS export editing form 37946/head
authorKiefer Chang <kiefer.chang@suse.com>
Wed, 4 Nov 2020 03:00:21 +0000 (11:00 +0800)
committerKiefer Chang <kiefer.chang@suse.com>
Wed, 4 Nov 2020 09:42:31 +0000 (17:42 +0800)
We should not allow changing an export's cluster because an export ID
might live in one cluster but not in another one. Editing a non-existing
export in a cluster causes an error.

Fixes: https://tracker.ceph.com/issues/47373
Signed-off-by: Kiefer Chang <kiefer.chang@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

index f17ee20a3de3529851bab12d772c7c607aafc021..66b8af29b01488e0de93f6c4d7ce0435eede93ca 100644 (file)
@@ -6,13 +6,10 @@ import { RouterTestingModule } from '@angular/router/testing';
 
 import { NgbTypeaheadModule } from '@ng-bootstrap/ng-bootstrap';
 import { ToastrModule } from 'ngx-toastr';
-import { of } from 'rxjs';
 
 import { ActivatedRouteStub } from '../../../../testing/activated-route-stub';
 import { configureTestBed } from '../../../../testing/unit-test-helper';
 import { LoadingPanelComponent } from '../../../shared/components/loading-panel/loading-panel.component';
-import { CephReleaseNamePipe } from '../../../shared/pipes/ceph-release-name.pipe';
-import { SummaryService } from '../../../shared/services/summary.service';
 import { SharedModule } from '../../../shared/shared.module';
 import { NfsFormClientComponent } from '../nfs-form-client/nfs-form-client.component';
 import { NfsFormComponent } from './nfs-form.component';
@@ -38,23 +35,13 @@ describe('NfsFormComponent', () => {
         {
           provide: ActivatedRoute,
           useValue: new ActivatedRouteStub({ cluster_id: undefined, export_id: undefined })
-        },
-        SummaryService,
-        CephReleaseNamePipe
+        }
       ]
     },
     [LoadingPanelComponent]
   );
 
   beforeEach(() => {
-    const summaryService = TestBed.inject(SummaryService);
-    spyOn(summaryService, 'refresh').and.callFake(() => true);
-    spyOn(summaryService, 'subscribeOnce').and.callFake(() =>
-      of({
-        version: 'master'
-      })
-    );
-
     fixture = TestBed.createComponent(NfsFormComponent);
     component = fixture.componentInstance;
     httpTesting = TestBed.inject(HttpTestingController);
@@ -119,6 +106,7 @@ describe('NfsFormComponent', () => {
       transportTCP: true,
       transportUDP: true
     });
+    expect(component.nfsForm.get('cluster_id').disabled).toBeFalsy();
   });
 
   it('should prepare data when selecting an cluster', () => {
@@ -142,6 +130,12 @@ describe('NfsFormComponent', () => {
     expect(component.nfsForm.getValue('daemons')).toEqual([]);
   });
 
+  it('should not allow changing cluster in edit mode', () => {
+    component.isEdit = true;
+    component.ngOnInit();
+    expect(component.nfsForm.get('cluster_id').disabled).toBeTruthy();
+  });
+
   describe('should submit request', () => {
     beforeEach(() => {
       component.nfsForm.patchValue({
index 52568696f91a56a2c9371a75c12cad83919ba525..d51ef4271491c531da4bc99f56a831e4f11e6dea 100644 (file)
@@ -118,6 +118,7 @@ export class NfsFormComponent extends CdForm implements OnInit {
 
         this.getData(promises);
       });
+      this.nfsForm.get('cluster_id').disable();
     } else {
       this.action = this.actionLabels.CREATE;
       this.getData(promises);