diff --git a/addons/core/translations/resources/en-us.yaml b/addons/core/translations/resources/en-us.yaml
index b381c96b8e..32f098cc4a 100644
--- a/addons/core/translations/resources/en-us.yaml
+++ b/addons/core/translations/resources/en-us.yaml
@@ -278,6 +278,9 @@ target:
types:
tcp: TCP
ssh: SSH
+ help:
+ tcp: This target belongs to an TCP host catalog and will use TCP to connect
+ ssh: This target belongs to an SSH host catalog and will use SSH to connect
host-source:
title: Host Source
title_plural: Host Sources
diff --git a/ui/admin/app/components/form/target/details/index.hbs b/ui/admin/app/components/form/target/details/index.hbs
new file mode 100644
index 0000000000..41f8d8c7c6
--- /dev/null
+++ b/ui/admin/app/components/form/target/details/index.hbs
@@ -0,0 +1,134 @@
+
+
+ {{#if @model.errors.name}}
+
+ {{#each @model.errors.name as |error|}}
+ {{error.message}}
+ {{/each}}
+
+ {{/if}}
+
+
+
+ {{#if @model.errors.description}}
+
+ {{#each @model.errors.description as |error|}}
+ {{error.message}}
+ {{/each}}
+
+ {{/if}}
+
+
+
+ <:title>{{t 'form.type.label'}}
+ <:body>
+
+
+
+
+
+
+
+ {{#if @model.errors.session_max_seconds}}
+
+ {{#each @model.errors.session_max_seconds as |error|}}
+ {{error.message}}
+ {{/each}}
+
+ {{/if}}
+
+
+
+ {{#if @model.errors.session_connection_limit}}
+
+ {{#each @model.errors.session_connection_limit as |error|}}
+ {{error.message}}
+ {{/each}}
+
+ {{/if}}
+
+
+
+ {{#if @model.errors.default_port}}
+
+ {{#each @model.errors.default_port as |error|}}
+ {{error.message}}
+ {{/each}}
+
+ {{/if}}
+
+ {{#if (can 'save model' @model)}}
+
+ {{/if}}
+
\ No newline at end of file
diff --git a/ui/admin/app/components/form/target/index.hbs b/ui/admin/app/components/form/target/index.hbs
index fc87570415..35086d4a9d 100644
--- a/ui/admin/app/components/form/target/index.hbs
+++ b/ui/admin/app/components/form/target/index.hbs
@@ -1,122 +1,6 @@
-
-
-
-
-
- {{#if @model.errors.name}}
-
- {{#each @model.errors.name as |error|}}
- {{error.message}}
- {{/each}}
-
- {{/if}}
-
-
-
- {{#if @model.errors.description}}
-
- {{#each @model.errors.description as |error|}}
- {{error.message}}
- {{/each}}
-
- {{/if}}
-
-
-
- {{#if @model.errors.session_max_seconds}}
-
- {{#each @model.errors.session_max_seconds as |error|}}
- {{error.message}}
- {{/each}}
-
- {{/if}}
-
-
-
- {{#if @model.errors.session_connection_limit}}
-
- {{#each @model.errors.session_connection_limit as |error|}}
- {{error.message}}
- {{/each}}
-
- {{/if}}
-
-
- {{! TODO this is a type-specific field }}
-
- {{! TODO need to figure out how to reference `attributes.errors` here }}
- {{#if @model.errors.default_port}}
-
- {{#each @model.errors.default_port as |error|}}
- {{error.message}}
- {{/each}}
-
- {{/if}}
-
- {{#if (can 'save model' @model)}}
-
- {{/if}}
-
\ No newline at end of file
+{{component
+ (concat 'form/target/' @model.type)
+ model=@model
+ submit=@submit
+ cancel=@cancel
+}}
\ No newline at end of file
diff --git a/ui/admin/app/components/form/target/ssh/index.hbs b/ui/admin/app/components/form/target/ssh/index.hbs
new file mode 100644
index 0000000000..7deff40789
--- /dev/null
+++ b/ui/admin/app/components/form/target/ssh/index.hbs
@@ -0,0 +1,6 @@
+
\ No newline at end of file
diff --git a/ui/admin/app/components/form/target/tcp/index.hbs b/ui/admin/app/components/form/target/tcp/index.hbs
new file mode 100644
index 0000000000..878c8e6f31
--- /dev/null
+++ b/ui/admin/app/components/form/target/tcp/index.hbs
@@ -0,0 +1,6 @@
+
\ No newline at end of file
diff --git a/ui/admin/app/templates/scopes/scope/targets/index.hbs b/ui/admin/app/templates/scopes/scope/targets/index.hbs
index 4705b4a2f2..8215961d13 100644
--- a/ui/admin/app/templates/scopes/scope/targets/index.hbs
+++ b/ui/admin/app/templates/scopes/scope/targets/index.hbs
@@ -17,9 +17,26 @@
{{#if (can 'create model' this.scope collection='targets')}}
{{#if @model}}
- {{t
- 'titles.new'
- }}
+
+
+ {{t 'resources.target.types.tcp'}}
+
+ {{#if (feature-flag 'ssh-target')}}
+
+ {{t 'resources.target.types.ssh'}}
+
+ {{/if}}
+
{{/if}}
{{/if}}
@@ -37,37 +54,74 @@
{{#each @model as |target|}}
-
-
- {{#if (can 'read model' target)}}
-
+ {{#if (feature-flag 'ssh-target')}}
+
+
+
+ {{#if (can 'read model' target)}}
+
+ {{target.displayName}}
+
+ {{else}}
{{target.displayName}}
-
- {{else}}
- {{target.displayName}}
- {{/if}}
- {{target.description}}
-
-
- {{#if target.type}}
-
- {{t (concat 'resources.target.types.' target.type)}}
-
- {{/if}}
-
-
-
- {{target.id}}
-
-
-
+ {{/if}}
+ {{target.description}}
+
+
+ {{#if target.type}}
+
+ {{t (concat 'resources.target.types.' target.type)}}
+
+ {{/if}}
+
+
+
+ {{target.id}}
+
+
+
+ {{else}}
+ {{#if target.isTCP}}
+
+
+ {{#if (can 'read model' target)}}
+
+ {{target.displayName}}
+
+ {{else}}
+ {{target.displayName}}
+ {{/if}}
+ {{target.description}}
+
+
+ {{#if target.type}}
+
+ {{t (concat 'resources.target.types.' target.type)}}
+
+ {{/if}}
+
+
+
+ {{target.id}}
+
+
+
+ {{/if}}
+ {{/if}}
{{/each}}
diff --git a/ui/admin/tests/acceptance/targets/create-test.js b/ui/admin/tests/acceptance/targets/create-test.js
index fd69af27ec..7e46e243ef 100644
--- a/ui/admin/tests/acceptance/targets/create-test.js
+++ b/ui/admin/tests/acceptance/targets/create-test.js
@@ -29,7 +29,8 @@ module('Acceptance | targets | create', function (hooks) {
projectScope: null,
targets: null,
target: null,
- newTarget: null,
+ newTCPTarget: null,
+ newSSHTarget: null,
};
hooks.beforeEach(function () {
@@ -52,16 +53,26 @@ module('Acceptance | targets | create', function (hooks) {
urls.targets = `${urls.projectScope}/targets`;
urls.target = `${urls.targets}/${instances.target.id}`;
urls.unknownTarget = `${urls.targets}/foo`;
- urls.newTarget = `${urls.targets}/new`;
+ urls.newTCPTarget = `${urls.targets}/new?type=tcp`;
+ urls.newSSHTarget = `${urls.targets}/new?type=ssh`;
// Generate resource couner
getTargetCount = () => this.server.schema.targets.all().models.length;
authenticateSession({});
});
- test('can create new targets', async function (assert) {
+ test('can create new targets of type TCP', async function (assert) {
assert.expect(1);
const count = getTargetCount();
- await visit(urls.newTarget);
+ await visit(urls.newTCPTarget);
+ await fillIn('[name="name"]', 'random string');
+ await click('[type="submit"]');
+ assert.equal(getTargetCount(), count + 1);
+ });
+
+ test('can create new targets of type SSH', async function (assert) {
+ assert.expect(1);
+ const count = getTargetCount();
+ await visit(urls.newSSHTarget);
await fillIn('[name="name"]', 'random string');
await click('[type="submit"]');
assert.equal(getTargetCount(), count + 1);
@@ -75,7 +86,7 @@ module('Acceptance | targets | create', function (hooks) {
'create'
)
);
- assert.ok(find(`[href="${urls.newTarget}"]`));
+ assert.ok(find(`[href="${urls.newTCPTarget}"]`));
});
test('cannot navigate to new targets route without proper authorization', async function (assert) {
@@ -87,13 +98,13 @@ module('Acceptance | targets | create', function (hooks) {
'create'
)
);
- assert.notOk(find(`[href="${urls.newTarget}"]`));
+ assert.notOk(find(`[href="${urls.newTCPTarget}"]`));
});
test('can cancel create new targets', async function (assert) {
assert.expect(2);
const count = getTargetCount();
- await visit(urls.newTarget);
+ await visit(urls.newTCPTarget);
await fillIn('[name="name"]', 'random string');
await click('.rose-form-actions [type="button"]');
assert.equal(currentURL(), urls.targets);
@@ -121,7 +132,7 @@ module('Acceptance | targets | create', function (hooks) {
}
);
});
- await visit(urls.newTarget);
+ await visit(urls.newTCPTarget);
await click('[type="submit"]');
assert.ok(
find('[role="alert"]').textContent.trim(),