From: Kiefer Chang Date: Wed, 4 Nov 2020 03:00:21 +0000 (+0800) Subject: mgr/dashboard: disable cluster selection in NFS export editing form X-Git-Tag: v15.2.9~96^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F37969%2Fhead;p=ceph.git mgr/dashboard: disable cluster selection in NFS export editing form 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 (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. --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.spec.ts index 7e271d6d4e9f..2b9a07d81082 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.spec.ts @@ -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({ diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.ts index a85a32fc6f62..f1a0394698ae 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.ts @@ -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);