diff --git a/.changelog/19153.txt b/.changelog/19153.txt new file mode 100644 index 00000000000..6c9da374e1c --- /dev/null +++ b/.changelog/19153.txt @@ -0,0 +1,3 @@ +```release-note:improvement +ui: Added a new example template with Task Actions +``` diff --git a/ui/app/utils/default-job-templates.js b/ui/app/utils/default-job-templates.js index 1d89de7cc57..02d18ab97c6 100644 --- a/ui/app/utils/default-job-templates.js +++ b/ui/app/utils/default-job-templates.js @@ -7,6 +7,7 @@ import helloWorld from './default_jobs/hello-world'; import parameterized from './default_jobs/parameterized'; import serviceDiscovery from './default_jobs/service-discovery'; import variables from './default_jobs/variables'; +import actions from './default_jobs/actions'; export default [ { @@ -22,6 +23,20 @@ export default [ }, ], }, + { + id: 'nomad/job-templates/default/actions', + keyValues: [ + { + key: 'template', + value: actions, + }, + { + key: 'description', + value: + 'Nomad Actions let job authors describe commands that can be run in one click from the UI or one command from the CLI. This example job shows how to use them to simulate development on a Redis instance.', + }, + ], + }, { id: 'nomad/job-templates/default/parameterized-job', keyValues: [ diff --git a/ui/app/utils/default_jobs/actions.js b/ui/app/utils/default_jobs/actions.js new file mode 100644 index 00000000000..cd65feab831 --- /dev/null +++ b/ui/app/utils/default_jobs/actions.js @@ -0,0 +1,125 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: BUSL-1.1 + */ + +export default `job "redis-actions" { + + group "cache" { + network { + port "db" {} + } + + task "redis" { + driver = "docker" + + config { + image = "redis:7" + ports = ["db"] + command = "/bin/sh" + args = ["-c", "redis-server --port \${NOMAD_PORT_db} & /local/db_log.sh"] + } + + template { + data = < { @@ -245,7 +247,10 @@ module('Acceptance | job run', function (hooks) { // Assert assert .dom('[data-test-template-card]') - .exists({ count: 4 }, 'A list of default job templates is rendered.'); + .exists( + { count: NUMBER_OF_DEFAULT_TEMPLATES }, + 'A list of default job templates is rendered.' + ); await click('[data-test-create-new-button]'); assert.equal(currentRouteName(), 'jobs.run.templates.new'); @@ -331,7 +336,10 @@ module('Acceptance | job run', function (hooks) { // Assert assert .dom('[data-test-template-card]') - .exists({ count: 4 }, 'A list of default job templates is rendered.'); + .exists( + { count: NUMBER_OF_DEFAULT_TEMPLATES }, + 'A list of default job templates is rendered.' + ); await click('[data-test-create-new-button]'); assert.equal(currentRouteName(), 'jobs.run.templates.new'); @@ -380,7 +388,10 @@ module('Acceptance | job run', function (hooks) { // Assert assert .dom('[data-test-template-card]') - .exists({ count: 4 }, 'A list of default job templates is rendered.'); + .exists( + { count: NUMBER_OF_DEFAULT_TEMPLATES }, + 'A list of default job templates is rendered.' + ); await click('[data-test-create-new-button]'); assert.equal(currentRouteName(), 'jobs.run.templates.new'); @@ -576,7 +587,6 @@ module('Acceptance | job run', function (hooks) { test('default templates', async function (assert) { assert.expect(4); - const NUMBER_OF_DEFAULT_TEMPLATES = 4; await visit('/jobs/run/templates');