diff --git a/ui/app/adapters/transform.js b/ui/app/adapters/transform.js index ce41b0808367..1f7627ba1f1f 100644 --- a/ui/app/adapters/transform.js +++ b/ui/app/adapters/transform.js @@ -67,9 +67,20 @@ export default ApplicationAdapter.extend({ results.forEach(result => { if (result.value) { if (result.value.data.roles) { + // TODO: Check if this is needed and remove if not resp.data = assign({}, resp.data, { zero_address_roles: result.value.data.roles }); } else { - resp.data = assign({}, resp.data, result.value.data); + let d = result.value.data; + if (d.templates) { + // In Transformations data goes up as "template", but comes down as "templates" + // To keep the keys consistent we're translating here + d = { + ...d, + template: [d.templates], + }; + delete d.templates; + } + resp.data = assign({}, resp.data, d); } } }); diff --git a/ui/app/models/transform.js b/ui/app/models/transform.js index 106bf0f310fa..ccafb7f28324 100644 --- a/ui/app/models/transform.js +++ b/ui/app/models/transform.js @@ -63,7 +63,7 @@ const Model = DS.Model.extend({ label: 'Masking character', subText: 'Specify which character you’d like to mask your data.', }), - template: attr('string', { + template: attr('array', { editType: 'searchSelect', fallbackComponent: 'string-list', label: 'Template', // TODO: make this required for making a transformation @@ -73,7 +73,6 @@ const Model = DS.Model.extend({ 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.', }), - templates: attr('array'), // TODO: remove once BE changes the returned property to a singular template on the GET request. allowed_roles: attr('array', { editType: 'searchSelect', label: 'Allowed roles', @@ -83,9 +82,9 @@ const Model = DS.Model.extend({ }), transformAttrs: computed('type', function() { if (this.type === 'masking') { - return ['name', 'type', 'masking_character', 'template', 'templates', 'allowed_roles']; + return ['name', 'type', 'masking_character', 'template', 'allowed_roles']; } - return ['name', 'type', 'tweak_source', 'template', 'templates', 'allowed_roles']; + return ['name', 'type', 'tweak_source', 'template', 'allowed_roles']; }), transformFieldAttrs: computed('transformAttrs', function() { return expandAttributeMeta(this, this.get('transformAttrs')); diff --git a/ui/app/serializers/transform.js b/ui/app/serializers/transform.js index a466cc4d5df9..ab30958d06c2 100644 --- a/ui/app/serializers/transform.js +++ b/ui/app/serializers/transform.js @@ -5,7 +5,15 @@ export default ApplicationSerializer.extend({ if (payload.data.masking_character) { payload.data.masking_character = String.fromCharCode(payload.data.masking_character); } - // TODO: the BE is working on a ticket to amend these response, so revisit. return this._super(store, primaryModelClass, payload, id, requestType); }, + + serialize() { + let json = this._super(...arguments); + if (json.template && Array.isArray(json.template)) { + // Transformations should only ever have one template + json.template = json.template[0]; + } + return json; + }, }); diff --git a/ui/app/templates/components/transform-create-form.hbs b/ui/app/templates/components/transform-create-form.hbs index fced8c8e94c2..a35e16c68245 100644 --- a/ui/app/templates/components/transform-create-form.hbs +++ b/ui/app/templates/components/transform-create-form.hbs @@ -4,21 +4,11 @@ {{!-- TODO: figure out what this ?? --}} {{!-- --}} {{#each model.transformFieldAttrs as |attr|}} - {{#if (eq attr.name 'templates')}} - {{!-- TODO: for now don't show until backend makes api changes. --}} - {{else if (eq attr.name 'template')}} - - {{else}} - - {{/if}} + {{/each}}
diff --git a/ui/app/templates/components/transform-edit-form.hbs b/ui/app/templates/components/transform-edit-form.hbs index ee4b917ae7cb..3855980c7f9b 100644 --- a/ui/app/templates/components/transform-edit-form.hbs +++ b/ui/app/templates/components/transform-edit-form.hbs @@ -25,22 +25,6 @@ {{/if}} - {{else if (eq attr.name 'template')}} - - {{else if (eq attr.name 'templates')}} - {{!-- TODO: for now don't show until backend makes api changes. --}} - {{else if (eq attr.name 'allowed_roles')}} - {{else}}