5c2a08de6d
* Update browserslist * Add browserslistrc * ember-cli-update --to 3.26, fix conflicts * Run codemodes that start with ember-* * More codemods - before cp* * More codemods (curly data-test-*) * WIP ember-basic-dropdown template errors * updates ember-basic-dropdown and related deps to fix build issues * updates basic dropdown instances to new version API * updates more deps -- ember-template-lint is working again * runs no-implicit-this codemod * creates and runs no-quoteless-attributes codemod * runs angle brackets codemod * updates lint:hbs globs to only touch hbs files * removes yield only templates * creates and runs deprecated args transform * supresses lint error for invokeAction on LinkTo component * resolves remaining ambiguous path lint errors * resolves simple-unless lint errors * adds warnings for deprecated tagName arg on LinkTo components * adds warnings for remaining curly component invocation * updates global template lint rules * resolves remaining template lint errors * disables some ember specfic lint rules that target pre octane patterns * js lint fix run * resolves remaining js lint errors * fixes test run * adds npm-run-all dep * fixes test attribute issues * fixes console acceptance tests * fixes tests * adds yield only wizard/tutorial-active template * fixes more tests * attempts to fix more flaky tests * removes commented out settled in transit test * updates deprecations workflow and adds initializer to filter by version * updates flaky policies acl old test * updates to flaky transit test * bumps ember deps down to LTS version * runs linters after main merge * fixes client count tests after bad merge conflict fixes * fixes client count history test * more updates to lint config * another round of hbs lint fixes after extending stylistic rule * updates lint-staged commands * removes indent eslint rule since it seems to break things * fixes bad attribute in transform-edit-form template * test fixes * fixes enterprise tests * adds changelog * removes deprecated ember-concurrency-test-waiters dep and adds @ember/test-waiters * flaky test fix Co-authored-by: hashishaw <cshaw@hashicorp.com>
101 lines
3.2 KiB
JavaScript
101 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',
|
||
fallbackComponent: 'string-list',
|
||
label: 'Template', // CBS TODO: make this required for making a transformation
|
||
models: ['transform/template'],
|
||
selectLimit: 1,
|
||
onlyAllowExisting: true,
|
||
subLabel: 'Template Name',
|
||
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',
|
||
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'}`,
|
||
});
|