for="protocols"
i18n>NFS Protocol</label>
<div class="cd-col-form-input">
+ <div class="custom-control custom-checkbox">
+ <input type="checkbox"
+ class="custom-control-input"
+ formControlName="protocolNfsv3"
+ name="protocolNfsv3"
+ id="protocolNfsv3">
+ <label for="protocolNfsv3"
+ class="custom-control-label"
+ i18n>NFSv3</label>
+ </div>
<div class="custom-control custom-checkbox">
<input type="checkbox"
class="custom-control-input"
formControlName="protocolNfsv4"
name="protocolNfsv4"
- id="protocolNfsv4"
- disabled>
- <label i18n
+ id="protocolNfsv4">
+ <label for="protocolNfsv4"
class="custom-control-label"
- for="protocolNfsv4">NFSv4</label>
+ i18n>NFSv4</label>
</div>
<span class="invalid-feedback"
- *ngIf="nfsForm.showError('protocolNfsv4', formDir, 'required')"
+ *ngIf="nfsForm.showError('protocolNfsv3', formDir, 'required') ||
+ nfsForm.showError('protocolNfsv4', formDir, 'required')"
i18n>This field is required.</span>
+ <hr>
</div>
</div>
<!-- Pseudo -->
<div class="form-group row"
- *ngIf="nfsForm.getValue('protocolNfsv4')">
+ *ngIf="nfsForm.getValue('protocolNfsv4') || nfsForm.getValue('protocolNfsv3')">
<label class="cd-col-form-label"
for="pseudo">
<span class="required"
fsal: { fs_name: 'a', name: 'CEPH' },
path: '/',
protocolNfsv4: true,
+ protocolNfsv3: true,
pseudo: '',
sec_label_xattr: 'security.selinux',
security_label: false,
expect(component.nfsForm.get('cluster_id').disabled).toBeTruthy();
});
- it('should mark NFSv4 protocol as enabled always', () => {
+ it('should mark NFSv4 & NFSv3 protocols as enabled always', () => {
expect(component.nfsForm.get('protocolNfsv4')).toBeTruthy();
+ expect(component.nfsForm.get('protocolNfsv3')).toBeTruthy();
});
it('should match backend squash values with ui values', () => {
fsal: { name: 'CEPH', fs_name: 1 },
path: '/foo',
protocolNfsv4: true,
+ protocolNfsv3: true,
pseudo: '/baz',
squash: 'no_root_squash',
transportTCP: true,
component.nfsForm.patchValue({ export_id: 1 });
component.submitAction();
+ const req = httpTesting.expectOne('api/nfs-ganesha/export/cluster1/1');
+ expect(req.request.method).toBe('PUT');
+ expect(req.request.body).toEqual({
+ access_type: 'RW',
+ clients: [],
+ cluster_id: 'cluster1',
+ export_id: 1,
+ fsal: { fs_name: 1, name: 'CEPH', sec_label_xattr: null },
+ path: '/foo',
+ protocols: [3, 4],
+ pseudo: '/baz',
+ security_label: false,
+ squash: 'no_root_squash',
+ transports: ['TCP', 'UDP']
+ });
+ });
+
+ it('should call update with selected nfs protocol', () => {
+ activatedRoute.setParams({ cluster_id: 'cluster1', export_id: '1' });
+ component.isEdit = true;
+ component.cluster_id = 'cluster1';
+ component.export_id = '1';
+ component.nfsForm.patchValue({ export_id: 1, protocolNfsv3: false });
+ component.submitAction();
+
const req = httpTesting.expectOne('api/nfs-ganesha/export/cluster1/1');
expect(req.request.method).toBe('PUT');
expect(req.request.body).toEqual({
sec_label_xattr: null
},
path: '/foo',
- protocols: [4],
+ protocols: [3, 4],
pseudo: '/baz',
security_label: false,
squash: 'no_root_squash',
})
}),
path: new UntypedFormControl('/'),
- protocolNfsv4: new UntypedFormControl(true),
+ protocolNfsv3: new UntypedFormControl(true, {
+ validators: [
+ CdValidators.requiredIf({ protocolNfsv4: false }, (value: boolean) => {
+ return !value;
+ })
+ ]
+ }),
+ protocolNfsv4: new UntypedFormControl(true, {
+ validators: [
+ CdValidators.requiredIf({ protocolNfsv3: false }, (value: boolean) => {
+ return !value;
+ })
+ ]
+ }),
pseudo: new UntypedFormControl('', {
validators: [
- CdValidators.requiredIf({ protocolNfsv4: true }),
+ CdValidators.requiredIf({ protocolNfsv4: true, protocolNfsv3: true }),
Validators.pattern('^/[^><|&()]*$')
]
}),
}
res.protocolNfsv4 = res.protocols.indexOf(4) !== -1;
+ res.protocolNfsv3 = res.protocols.indexOf(3) !== -1;
delete res.protocols;
res.transportTCP = res.transports.indexOf('TCP') !== -1;
}
requestModel.protocols = [];
+ if (requestModel.protocolNfsv3) {
+ requestModel.protocols.push(3);
+ }
if (requestModel.protocolNfsv4) {
requestModel.protocols.push(4);
- } else {
+ }
+ if (!requestModel.protocolNfsv3 && !requestModel.protocolNfsv4) {
requestModel.pseudo = null;
}
+ delete requestModel.protocolNfsv3;
delete requestModel.protocolNfsv4;
requestModel.transports = [];