From edf623adf07eaff5a730a728020ce3bc03ba6d7b Mon Sep 17 00:00:00 2001 From: Dharini Jeeva Date: Mon, 12 Jun 2023 08:38:55 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20worker=20form=20navigatio?= =?UTF-8?q?n=20(#1711)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 🐛 Show done only when a worker is registered successfully, otherwise show cancel and navigate to the workers list --- .../form/worker/create-worker-led/index.hbs | 13 +++++-------- ui/admin/app/routes/scopes/scope/workers.js | 7 +++++++ .../routes/scopes/scope/workers/worker/index.js | 9 ++++++++- .../app/templates/scopes/scope/workers/new.hbs | 2 +- .../form/worker/create-worker-led-test.js | 16 ++++++++-------- 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/ui/admin/app/components/form/worker/create-worker-led/index.hbs b/ui/admin/app/components/form/worker/create-worker-led/index.hbs index 5ed7d7fbc..7aeebd54d 100644 --- a/ui/admin/app/components/form/worker/create-worker-led/index.hbs +++ b/ui/admin/app/components/form/worker/create-worker-led/index.hbs @@ -190,12 +190,9 @@ {{/unless}} - - - {{t 'actions.done'}} - + \ No newline at end of file diff --git a/ui/admin/app/routes/scopes/scope/workers.js b/ui/admin/app/routes/scopes/scope/workers.js index 2233369e6..ac4cc2591 100644 --- a/ui/admin/app/routes/scopes/scope/workers.js +++ b/ui/admin/app/routes/scopes/scope/workers.js @@ -47,6 +47,13 @@ export default class ScopesScopeWorkersRoute extends Route { return super.refresh(...arguments); } + @action + cancel(worker) { + const { isNew } = worker; + if (isNew) worker.rollbackAttributes(); + this.router.replaceWith('scopes.scope.workers'); + this.refresh(); + } /** * Save a worker in current scope. * @param {WorkerModel} worker diff --git a/ui/admin/app/routes/scopes/scope/workers/worker/index.js b/ui/admin/app/routes/scopes/scope/workers/worker/index.js index 600cec296..d1c082f48 100644 --- a/ui/admin/app/routes/scopes/scope/workers/worker/index.js +++ b/ui/admin/app/routes/scopes/scope/workers/worker/index.js @@ -4,5 +4,12 @@ */ import Route from '@ember/routing/route'; +import { action } from '@ember/object'; -export default class ScopesScopeWorkersWorkerIndexRoute extends Route {} +export default class ScopesScopeWorkersWorkerIndexRoute extends Route { + @action + cancel(worker) { + worker.rollbackAttributes(); + this.refresh(); + } +} diff --git a/ui/admin/app/templates/scopes/scope/workers/new.hbs b/ui/admin/app/templates/scopes/scope/workers/new.hbs index 0353346dc..00a343fe4 100644 --- a/ui/admin/app/templates/scopes/scope/workers/new.hbs +++ b/ui/admin/app/templates/scopes/scope/workers/new.hbs @@ -20,8 +20,8 @@ diff --git a/ui/admin/tests/integration/components/form/worker/create-worker-led-test.js b/ui/admin/tests/integration/components/form/worker/create-worker-led-test.js index 46f9fcdfe..93328b665 100644 --- a/ui/admin/tests/integration/components/form/worker/create-worker-led-test.js +++ b/ui/admin/tests/integration/components/form/worker/create-worker-led-test.js @@ -28,12 +28,12 @@ module( const guid = v1(); this.model = {}; this.submit = () => {}; - this.refresh = () => {}; + this.cancel = () => {}; windowService.location.hostname = `${guid}.boundary.hcp.dev`; await render( - hbs`` + hbs`` ); assert.dom('[name="cluster_id"]').hasValue(guid); @@ -44,12 +44,12 @@ module( const guid = v1(); this.model = {}; this.submit = () => {}; - this.refresh = () => {}; + this.cancel = () => {}; windowService.location.hostname = `${guid}.boundary.hcp.to`; await render( - hbs`` + hbs`` ); assert.dom('[name="cluster_id"]').hasValue(guid); @@ -60,12 +60,12 @@ module( const guid = v1(); this.model = {}; this.submit = () => {}; - this.refresh = () => {}; + this.cancel = () => {}; windowService.location.hostname = `${guid}.boundary.hashicorp.cloud`; await render( - hbs`` + hbs`` ); assert.dom('[name="cluster_id"]').hasValue(guid); @@ -75,12 +75,12 @@ module( const windowService = this.owner.lookup('service:browser/window'); this.model = {}; this.submit = () => {}; - this.refresh = () => {}; + this.cancel = () => {}; windowService.location.hostname = `personal.website.com`; await render( - hbs`` + hbs`` ); assert.dom('[name="cluster_id"]').hasNoValue();