diff --git a/addons/api/addon/models/target.js b/addons/api/addon/models/target.js index fd5c43358..08db9715c 100644 --- a/addons/api/addon/models/target.js +++ b/addons/api/addon/models/target.js @@ -2,6 +2,8 @@ import GeneratedTargetModel from '../generated/models/target'; import { attr } from '@ember-data/model'; import { inject as service } from '@ember/service'; +export const types = ['tcp', 'ssh']; + export default class TargetModel extends GeneratedTargetModel { // =services diff --git a/ui/admin/app/components/form/credential-store/static/index.hbs b/ui/admin/app/components/form/credential-store/static/index.hbs index 0dbb997dc..2d44e3dd5 100644 --- a/ui/admin/app/components/form/credential-store/static/index.hbs +++ b/ui/admin/app/components/form/credential-store/static/index.hbs @@ -49,7 +49,7 @@ {{t 'form.type.label'}} - {{#each-in this.mapResourceTypewithIcon as |credentialStoreType icon|}} + {{#each-in this.mapResourceTypeWithIcon as |credentialStoreType icon|}} ({ ...obj, [type]: icons[i] }), {}); } } diff --git a/ui/admin/app/components/form/credential-store/vault/index.hbs b/ui/admin/app/components/form/credential-store/vault/index.hbs index fcc1196be..ed6e1f16c 100644 --- a/ui/admin/app/components/form/credential-store/vault/index.hbs +++ b/ui/admin/app/components/form/credential-store/vault/index.hbs @@ -49,7 +49,7 @@ {{#if @model.isNew}} {{t 'form.type.label'}} - {{#each-in this.mapResourceTypewithIcon as |credentialStoreType icon|}} + {{#each-in this.mapResourceTypeWithIcon as |credentialStoreType icon|}} ({ ...obj, [type]: icons[i] }), {}); } } diff --git a/ui/admin/app/components/form/credential/ssh_private_key/index.hbs b/ui/admin/app/components/form/credential/ssh_private_key/index.hbs index 3e06da207..c87c33efa 100644 --- a/ui/admin/app/components/form/credential/ssh_private_key/index.hbs +++ b/ui/admin/app/components/form/credential/ssh_private_key/index.hbs @@ -44,30 +44,27 @@ {{/if}} {{#if @model.isNew}} - - <:title>{{t 'form.type.label'}} - <:body> - + {{t 'form.type.label'}} + {{#each this.credentialTypes as |credentialType|}} + - - - - - + {{t + (concat 'resources.credential.types.' credentialType) + }} + {{t + (concat 'resources.credential.help.' credentialType) + }} + + + {{/each}} + {{else}} {{#if @model.isNew}} - - <:title>{{t 'form.type.label'}} - <:body> - + {{t 'form.type.label'}} + {{#each this.credentialTypes as |credentialType|}} + - - - - - + {{t + (concat 'resources.credential.types.' credentialType) + }} + {{t + (concat 'resources.credential.help.' credentialType) + }} + + + {{/each}} + {{else}} - - <:title>{{t 'form.type.label'}} - <:body> - {{#if @model.isNew}} - + {{t 'form.type.label'}} + {{#each-in this.mapResourceTypeWithIcon as |targetType icon|}} + - - {{#if (feature-flag 'ssh-target')}} - - {{/if}} - - {{else}} - - + {{t (concat 'resources.target.types.' targetType)}} + {{t + (concat 'resources.target.help.' targetType) + }} + + + {{/each-in}} + - - {{/if}} - - + {{else}} + + {{t 'form.type.label'}} + {{t (concat 'resources.target.types.' @model.type)}} + + + {{/if}} ({ ...obj, [type]: icons[i] }), {}); + } + + /** + * returns icons based on the model type + * unlike other resources, this is needed as we use generic details component for both tcp and ssh + * @type {string} + */ + get icon() { + if (this.args.model.type === 'tcp') { + return icons[0]; + } else { + return icons[1]; + } + } +} diff --git a/ui/admin/tests/acceptance/targets/create-test.js b/ui/admin/tests/acceptance/targets/create-test.js index 58df58ecd..856d33fd2 100644 --- a/ui/admin/tests/acceptance/targets/create-test.js +++ b/ui/admin/tests/acceptance/targets/create-test.js @@ -80,7 +80,7 @@ module('Acceptance | targets | create', function (hooks) { test('defaults to a new TCP target when no query param provided', async function (assert) { assert.expect(1); await visit(urls.newTarget); - assert.strictEqual(find('input[name=types]:checked').value, 'tcp'); + assert.strictEqual(find('input[name=tcp]:checked').value, 'tcp'); }); test('can create new targets of type TCP', async function (assert) { @@ -176,8 +176,8 @@ module('Acceptance | targets | create', function (hooks) { 'create' ) ); - assert.dom('.rose-form-radio-card').exists({ count: 1 }); - assert.dom('.rose-form-radio-card label').includesText('TCP'); + assert.dom('.info-field').exists({ count: 1 }); + assert.dom('.hds-form-helper-text').includesText('TCP'); }); test('can cancel create new TCP target', async function (assert) {