import { I18n } from '@ngx-translate/i18n-polyfill';
import { SelectMessages } from '../../../shared/components/select/select-messages.model';
-import { SelectOption } from '../../../shared/components/select/select-option.model';
import { Pool } from '../pool';
export class PoolFormData {
this.poolTypes = ['erasure', 'replicated'];
this.applications = {
selected: [],
- available: [
- new SelectOption(false, 'cephfs', ''),
- new SelectOption(false, 'rbd', ''),
- new SelectOption(false, 'rgw', '')
- ],
+ default: ['cephfs', 'rbd', 'rgw'],
+ available: [], // Filled during runtime
validators: [Validators.pattern('[A-Za-z0-9_]+'), Validators.maxLength(128)],
messages: new SelectMessages(
{
testAddApp('g', ['rgw']);
testAddApp('b', ['rbd', 'rgw']);
testAddApp('c', ['cephfs', 'rbd', 'rgw']);
- testAddApp('something', ['cephfs', 'rbd', 'rgw', 'something']);
+ testAddApp('ownApp', ['cephfs', 'ownApp', 'rbd', 'rgw']);
});
it('only allows 4 apps to be added to the array', () => {
pool.options.compression_max_blob_size = 1024 * 1024;
pool.options.compression_required_ratio = 0.8;
pool.flags_names = 'someFlag1,someFlag2';
- pool.application_metadata = ['rbd', 'rgw'];
+ pool.application_metadata = ['rbd', 'ownApp'];
pool.quota_max_bytes = 1024 * 1024 * 1024;
pool.quota_max_objects = 3000;
});
});
+ it('should include the custom app as valid option', () => {
+ expect(component.data.applications.available.map((app) => app.name)).toEqual([
+ 'cephfs',
+ 'ownApp',
+ 'rbd',
+ 'rgw'
+ ]);
+ });
+
it('set all control values to the given pool', () => {
expect(form.getValue('name')).toBe(pool.pool_name);
expect(form.getValue('poolType')).toBe(pool.type);
formHelper.setValue('ratio', '').markAsDirty();
expectValidSubmit(
{
- application_metadata: ['rbd', 'rgw'],
+ application_metadata: ['ownApp', 'rbd'],
compression_max_blob_size: 0,
compression_min_blob_size: 0,
compression_required_ratio: 0,
formHelper.setValue('mode', 'none').markAsDirty();
expectValidSubmit(
{
- application_metadata: ['rbd', 'rgw'],
+ application_metadata: ['ownApp', 'rbd'],
compression_mode: 'unset',
pool: 'somePoolName'
},
import { ErasureCodeProfileService } from '../../../shared/api/erasure-code-profile.service';
import { PoolService } from '../../../shared/api/pool.service';
import { CriticalConfirmationModalComponent } from '../../../shared/components/critical-confirmation-modal/critical-confirmation-modal.component';
+import { SelectOption } from '../../../shared/components/select/select-option.model';
import { ActionLabelsI18n, URLVerbs } from '../../../shared/constants/app.constants';
import { Icons } from '../../../shared/enum/icons.enum';
import { CdFormGroup } from '../../../shared/forms/cd-form-group';
this.initEcp(data[2]);
if (this.editing) {
this.initEditMode();
+ } else {
+ this.setAvailableApps();
}
this.listenToChanges();
this.setComplexValidators();
}
});
this.data.pgs = this.form.getValue('pgNum');
+ this.setAvailableApps(this.data.applications.default.concat(pool.application_metadata));
this.data.applications.selected = pool.application_metadata;
}
+ private setAvailableApps(apps: string[] = this.data.applications.default) {
+ this.data.applications.available = _.uniq(apps.sort()).map(
+ (x: string) => new SelectOption(false, x, '')
+ );
+ }
+
private listenToChanges() {
this.listenToChangesDuringAddEdit();
if (!this.editing) {