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:
Dharini Jeeva authored and GitHub committed 2023-06-12 08:38:55 -07:00
1 parent 37c0c55a60
commit edf623adf0
5 files changed
+29 -18

No files matched your search

@@ -190,12 +190,9 @@
</div>
{{/unless}}
</div>
<Rose::LinkButton
@route='scopes.scope.workers'
@style='secondary'
{{on 'click' @refresh}}
>
{{t 'actions.done'}}
</Rose::LinkButton>
<Hds::Button
@color='secondary'
@text={{if @model.isNew (t 'actions.cancel') (t 'actions.done')}}
{{on 'click' @cancel}}
/>
</Rose::Form>
@@ -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
@@ -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();
}
}
@@ -20,8 +20,8 @@
<page.body>
<Form::Worker::CreateWorkerLed
@model={{@model}}
@cancel={{route-action 'cancel' @model}}
@submit={{route-action 'createWorkerLed' @model}}
@refresh={{route-action 'refresh'}}
/>
</page.body>