From 59354a2f25db930a17ad99a8a9b3694b299d8587 Mon Sep 17 00:00:00 2001 From: Kiefer Chang Date: Wed, 4 Nov 2020 11:00:21 +0800 Subject: [PATCH] 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 src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-list/nfs-list.component.spec.ts - Some imports differ from master; remove SummaryService and CephReleaseNamePipe from providers and no longer needed test case; also remove not working docsUrl (and related lines) from nfs-form.component.ts --- .../src/app/ceph/nfs/nfs-form/nfs-form.component.spec.ts | 7 +++++++ .../src/app/ceph/nfs/nfs-form/nfs-form.component.ts | 1 + 2 files changed, 8 insertions(+) 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 bcc51a84de0a..4d1c0c7aa4ef 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 @@ -113,6 +113,7 @@ describe('NfsFormComponent', () => { transportTCP: true, transportUDP: true }); + expect(component.nfsForm.get('cluster_id').disabled).toBeFalsy(); }); it('should prepare data when selecting an cluster', () => { @@ -136,6 +137,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 0beec9fc3bef..b32f7b8de599 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 @@ -116,6 +116,7 @@ export class NfsFormComponent implements OnInit { this.getData(promises); }); + this.nfsForm.get('cluster_id').disable(); } else { this.action = this.actionLabels.CREATE; this.getData(promises); -- 2.47.3