Skip to content

Commit f5c7649

Browse files
authored
Merge pull request ceph#53991 from rhcs-dashboard/fix-cephfs-edit-form-placement
mgr/dashboard: disable hosts field while editing the filesystem Reviewed-by: Avan Thakkar <[email protected]> Reviewed-by: Ankush Behl <[email protected]>
2 parents c31f506 + b18a144 commit f5c7649

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
</div>
6060

6161
<!-- Label -->
62-
<div *ngIf="form.controls.placement.value === 'label'"
62+
<div *ngIf="form.controls.placement.value === 'label' && !editing"
6363
class="form-group row">
6464
<label i18n
6565
class="cd-col-form-label"
@@ -79,7 +79,7 @@
7979
</div>
8080

8181
<!-- Hosts -->
82-
<div *ngIf="form.controls.placement.value === 'hosts'"
82+
<div *ngIf="form.controls.placement.value === 'hosts' && !editing"
8383
class="form-group row">
8484
<label class="cd-col-form-label"
8585
for="hosts"

src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.spec.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@ import { FormHelper, configureTestBed } from '~/testing/unit-test-helper';
77
import { SharedModule } from '~/app/shared/shared.module';
88
import { ToastrModule } from 'ngx-toastr';
99
import { ReactiveFormsModule } from '@angular/forms';
10+
import { By } from '@angular/platform-browser';
11+
import { OrchestratorService } from '~/app/shared/api/orchestrator.service';
12+
import { of } from 'rxjs';
13+
1014
describe('CephfsVolumeFormComponent', () => {
1115
let component: CephfsVolumeFormComponent;
1216
let fixture: ComponentFixture<CephfsVolumeFormComponent>;
1317
let formHelper: FormHelper;
18+
let orchService: OrchestratorService;
1419

1520
configureTestBed({
1621
imports: [
@@ -27,6 +32,8 @@ describe('CephfsVolumeFormComponent', () => {
2732
fixture = TestBed.createComponent(CephfsVolumeFormComponent);
2833
component = fixture.componentInstance;
2934
formHelper = new FormHelper(component.form);
35+
orchService = TestBed.inject(OrchestratorService);
36+
spyOn(orchService, 'status').and.returnValue(of({ available: true }));
3037
fixture.detectChanges();
3138
});
3239

@@ -50,4 +57,26 @@ describe('CephfsVolumeFormComponent', () => {
5057
formHelper.expectError('name', 'pattern');
5158
}
5259
}));
60+
61+
it('should show placement when orchestrator is available', () => {
62+
const placement = fixture.debugElement.query(By.css('#placement'));
63+
expect(placement).not.toBeNull();
64+
});
65+
66+
describe('when editing', () => {
67+
beforeEach(() => {
68+
component.editing = true;
69+
component.ngOnInit();
70+
fixture.detectChanges();
71+
});
72+
73+
it('should not show placement while editing even if orch is available', () => {
74+
const placement = fixture.debugElement.query(By.css('#placement'));
75+
const label = fixture.debugElement.query(By.css('#label'));
76+
const hosts = fixture.debugElement.query(By.css('#hosts'));
77+
expect(placement).toBeNull();
78+
expect(label).toBeNull();
79+
expect(hosts).toBeNull();
80+
});
81+
});
5382
});

0 commit comments

Comments
 (0)