fix: 🐛 worker form navigation (#1711)
* fix: 🐛 Show done only when a worker is registered successfully, otherwise show cancel and navigate to the workers list
This commit is contained in:
1 parent
37c0c55a60
commit
edf623adf0
5 files changed
+29
-18
No files matched your search
@@ -190,12 +190,9 @@
|
|||||||
</div>
|
</div>
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
</div>
|
</div>
|
||||||
|
<Hds::Button
|
||||||
<Rose::LinkButton
|
@color='secondary'
|
||||||
@route='scopes.scope.workers'
|
@text={{if @model.isNew (t 'actions.cancel') (t 'actions.done')}}
|
||||||
@style='secondary'
|
{{on 'click' @cancel}}
|
||||||
{{on 'click' @refresh}}
|
/>
|
||||||
>
|
|
||||||
{{t 'actions.done'}}
|
|
||||||
</Rose::LinkButton>
|
|
||||||
</Rose::Form>
|
</Rose::Form>
|
||||||
@@ -47,6 +47,13 @@ export default class ScopesScopeWorkersRoute extends Route {
|
|||||||
return super.refresh(...arguments);
|
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.
|
* Save a worker in current scope.
|
||||||
* @param {WorkerModel} worker
|
* @param {WorkerModel} worker
|
||||||
|
|||||||
@@ -4,5 +4,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import Route from '@ember/routing/route';
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,8 +20,8 @@
|
|||||||
<page.body>
|
<page.body>
|
||||||
<Form::Worker::CreateWorkerLed
|
<Form::Worker::CreateWorkerLed
|
||||||
@model={{@model}}
|
@model={{@model}}
|
||||||
|
@cancel={{route-action 'cancel' @model}}
|
||||||
@submit={{route-action 'createWorkerLed' @model}}
|
@submit={{route-action 'createWorkerLed' @model}}
|
||||||
@refresh={{route-action 'refresh'}}
|
|
||||||
/>
|
/>
|
||||||
</page.body>
|
</page.body>
|
||||||
|
|
||||||
|
|||||||
@@ -28,12 +28,12 @@ module(
|
|||||||
const guid = v1();
|
const guid = v1();
|
||||||
this.model = {};
|
this.model = {};
|
||||||
this.submit = () => {};
|
this.submit = () => {};
|
||||||
this.refresh = () => {};
|
this.cancel = () => {};
|
||||||
|
|
||||||
windowService.location.hostname = `${guid}.boundary.hcp.dev`;
|
windowService.location.hostname = `${guid}.boundary.hcp.dev`;
|
||||||
|
|
||||||
await render(
|
await render(
|
||||||
hbs`<Form::Worker::CreateWorkerLed @model={{this.model}} @submit={{this.submit}} @refresh={{this.refresh}} />`
|
hbs`<Form::Worker::CreateWorkerLed @model={{this.model}} @submit={{this.submit}} @cancel={{this.cancel}} />`
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.dom('[name="cluster_id"]').hasValue(guid);
|
assert.dom('[name="cluster_id"]').hasValue(guid);
|
||||||
@@ -44,12 +44,12 @@ module(
|
|||||||
const guid = v1();
|
const guid = v1();
|
||||||
this.model = {};
|
this.model = {};
|
||||||
this.submit = () => {};
|
this.submit = () => {};
|
||||||
this.refresh = () => {};
|
this.cancel = () => {};
|
||||||
|
|
||||||
windowService.location.hostname = `${guid}.boundary.hcp.to`;
|
windowService.location.hostname = `${guid}.boundary.hcp.to`;
|
||||||
|
|
||||||
await render(
|
await render(
|
||||||
hbs`<Form::Worker::CreateWorkerLed @model={{this.model}} @submit={{this.submit}} @refresh={{this.refresh}} />`
|
hbs`<Form::Worker::CreateWorkerLed @model={{this.model}} @submit={{this.submit}} @cancel={{this.cancel}} />`
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.dom('[name="cluster_id"]').hasValue(guid);
|
assert.dom('[name="cluster_id"]').hasValue(guid);
|
||||||
@@ -60,12 +60,12 @@ module(
|
|||||||
const guid = v1();
|
const guid = v1();
|
||||||
this.model = {};
|
this.model = {};
|
||||||
this.submit = () => {};
|
this.submit = () => {};
|
||||||
this.refresh = () => {};
|
this.cancel = () => {};
|
||||||
|
|
||||||
windowService.location.hostname = `${guid}.boundary.hashicorp.cloud`;
|
windowService.location.hostname = `${guid}.boundary.hashicorp.cloud`;
|
||||||
|
|
||||||
await render(
|
await render(
|
||||||
hbs`<Form::Worker::CreateWorkerLed @model={{this.model}} @submit={{this.submit}} @refresh={{this.refresh}} />`
|
hbs`<Form::Worker::CreateWorkerLed @model={{this.model}} @submit={{this.submit}} @cancel={{this.cancel}} />`
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.dom('[name="cluster_id"]').hasValue(guid);
|
assert.dom('[name="cluster_id"]').hasValue(guid);
|
||||||
@@ -75,12 +75,12 @@ module(
|
|||||||
const windowService = this.owner.lookup('service:browser/window');
|
const windowService = this.owner.lookup('service:browser/window');
|
||||||
this.model = {};
|
this.model = {};
|
||||||
this.submit = () => {};
|
this.submit = () => {};
|
||||||
this.refresh = () => {};
|
this.cancel = () => {};
|
||||||
|
|
||||||
windowService.location.hostname = `personal.website.com`;
|
windowService.location.hostname = `personal.website.com`;
|
||||||
|
|
||||||
await render(
|
await render(
|
||||||
hbs`<Form::Worker::CreateWorkerLed @model={{this.model}} @submit={{this.submit}} @refresh={{this.refresh}} />`
|
hbs`<Form::Worker::CreateWorkerLed @model={{this.model}} @submit={{this.submit}} @cancel={{this.cancel}} />`
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.dom('[name="cluster_id"]').hasNoValue();
|
assert.dom('[name="cluster_id"]').hasNoValue();
|
||||||
|
|||||||
Reference in new issue
Block a user