9cc2f52bc1
* initial commit for glimmerizing search-select * fix credentials card tests * WIP/fixing manually passed in options * note for small change made in other PR * still a work in progress, but maybe fixed some tests...maybe * fix path filter config tests * remove comments * clean up merge conflicts * remove redundant subLabel * remove subLabel, change default label to form field size * split up format method * cleanup, try to keep types consistent * change logic for ss lable * remove comment * cleanup naming * fix incorrect glimmer change * refactor to allow for parent handling selected options * update jsdoc and reogranize functions * add test to path filter config * address comments, small cleanup * add test for path filter config ss * rearrange functions so git diff is easier to compare * change isNotSectionHeader to isSectionHeader * add more explicit test coverage, tidying for search select * small doc tidy * add comments, one more test! last cleanup! * fix search select tests
102 lines
3.2 KiB
JavaScript
102 lines
3.2 KiB
JavaScript
import Model, { attr } from '@ember-data/model';
|
||
import { computed } from '@ember/object';
|
||
import { apiPath } from 'vault/macros/lazy-capabilities';
|
||
import { expandAttributeMeta } from 'vault/utils/field-to-attrs';
|
||
import attachCapabilities from 'vault/lib/attach-capabilities';
|
||
|
||
// these arrays define the order in which the fields will be displayed
|
||
// see
|
||
//https://www.vaultproject.io/api-docs/secret/transform#create-update-transformation
|
||
const TYPES = [
|
||
{
|
||
value: 'fpe',
|
||
displayName: 'Format Preserving Encryption (FPE)',
|
||
},
|
||
{
|
||
value: 'masking',
|
||
displayName: 'Masking',
|
||
},
|
||
];
|
||
|
||
const TWEAK_SOURCE = [
|
||
{
|
||
value: 'supplied',
|
||
displayName: 'supplied',
|
||
},
|
||
{
|
||
value: 'generated',
|
||
displayName: 'generated',
|
||
},
|
||
{
|
||
value: 'internal',
|
||
displayName: 'internal',
|
||
},
|
||
];
|
||
|
||
const ModelExport = Model.extend({
|
||
useOpenAPI: false,
|
||
name: attr('string', {
|
||
// CBS TODO: make this required for making a transformation
|
||
label: 'Name',
|
||
fieldValue: 'id',
|
||
readOnly: true,
|
||
subText: 'The name for your transformation. This cannot be edited later.',
|
||
}),
|
||
type: attr('string', {
|
||
defaultValue: 'fpe',
|
||
label: 'Type',
|
||
possibleValues: TYPES,
|
||
subText:
|
||
'Vault provides two types of transformations: Format Preserving Encryption (FPE) is reversible, while Masking is not. This cannot be edited later.',
|
||
}),
|
||
tweak_source: attr('string', {
|
||
defaultValue: 'supplied',
|
||
label: 'Tweak source',
|
||
possibleValues: TWEAK_SOURCE,
|
||
subText: `A tweak value is used when performing FPE transformations. This can be supplied, generated, or internal.`, // CBS TODO: I do not include the link here. Need to figure out the best way to approach this.
|
||
}),
|
||
masking_character: attr('string', {
|
||
characterLimit: 1,
|
||
defaultValue: '*',
|
||
label: 'Masking character',
|
||
subText: 'Specify which character you’d like to mask your data.',
|
||
}),
|
||
template: attr('array', {
|
||
editType: 'searchSelect',
|
||
isSectionHeader: true,
|
||
fallbackComponent: 'string-list',
|
||
label: 'Template', // CBS TODO: make this required for making a transformation
|
||
models: ['transform/template'],
|
||
selectLimit: 1,
|
||
onlyAllowExisting: true,
|
||
subText:
|
||
'Templates allow Vault to determine what and how to capture the value to be transformed. Type to use an existing template or create a new one.',
|
||
}),
|
||
allowed_roles: attr('array', {
|
||
editType: 'searchSelect',
|
||
isSectionHeader: true,
|
||
label: 'Allowed roles',
|
||
fallbackComponent: 'string-list',
|
||
models: ['transform/role'],
|
||
subText: 'Search for an existing role, type a new role to create it, or use a wildcard (*).',
|
||
wildcardLabel: 'role',
|
||
}),
|
||
transformAttrs: computed('type', function () {
|
||
if (this.type === 'masking') {
|
||
return ['name', 'type', 'masking_character', 'template', 'allowed_roles'];
|
||
}
|
||
return ['name', 'type', 'tweak_source', 'template', 'allowed_roles'];
|
||
}),
|
||
transformFieldAttrs: computed('transformAttrs', function () {
|
||
return expandAttributeMeta(this, this.transformAttrs);
|
||
}),
|
||
|
||
backend: attr('string', {
|
||
readOnly: true,
|
||
}),
|
||
});
|
||
|
||
export default attachCapabilities(ModelExport, {
|
||
updatePath: apiPath`${'backend'}/transformation/${'id'}`,
|
||
});
|