]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: disable cluster selection in NFS export editing form 37969/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, 9 Dec 2020 08:43:24 +0000 (16:43 +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>
(cherry picked from commit d678d8076c2a4c5edfe489d553e3c8770462f023)

 Conflicts:
src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.spec.ts
        - Unnecessary spies for SummaryService are removed in the master.
        - The LoadingPanelComponent is new in the master.

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 7e271d6d4e9f823bd9dcd091f8a0408e55c7b612..2b9a07d81082c2040a5fcfe444802fae8de47f36 100644 (file)
@@ -6,12 +6,9 @@ import { RouterTestingModule } from '@angular/router/testing';
 
 import { TypeaheadModule } from 'ngx-bootstrap/typeahead';
 import { ToastrModule } from 'ngx-toastr';
-import { of } from 'rxjs';
 
 import { ActivatedRouteStub } from '../../../../testing/activated-route-stub';
 import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-helper';
-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';
@@ -37,21 +34,11 @@ describe('NfsFormComponent', () => {
         provide: ActivatedRoute,
         useValue: new ActivatedRouteStub({ cluster_id: undefined, export_id: undefined })
       },
-      i18nProviders,
-      SummaryService,
-      CephReleaseNamePipe
+      i18nProviders
     ]
   });
 
   beforeEach(() => {
-    const summaryService = TestBed.get(SummaryService);
-    spyOn(summaryService, 'refresh').and.callFake(() => true);
-    spyOn(summaryService, 'subscribeOnce').and.callFake(() =>
-      of({
-        version: 'master'
-      })
-    );
-
     fixture = TestBed.createComponent(NfsFormComponent);
     component = fixture.componentInstance;
     httpTesting = TestBed.get(HttpTestingController);
@@ -116,6 +103,7 @@ describe('NfsFormComponent', () => {
       transportTCP: true,
       transportUDP: true
     });
+    expect(component.nfsForm.get('cluster_id').disabled).toBeFalsy();
   });
 
   it('should prepare data when selecting an cluster', () => {
@@ -139,6 +127,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 a85a32fc6f62499d5c35dae3cfeb2b6b4064759b..f1a0394698aee04011f98c3e6a442e938a956b20 100644 (file)
@@ -113,6 +113,7 @@ export class NfsFormComponent implements OnInit {
 
         this.getData(promises);
       });
+      this.nfsForm.get('cluster_id').disable();
     } else {
       this.action = this.actionLabels.CREATE;
       this.getData(promises);