UI secret navigation improvements (#5976)

* don't pass id when using createRecord

* add find nearest ancestor mixin

* re-throw the error if we've deleted something and encounter a 404

* use the with-nav-to-nearest-ancestor mixin

* add some comments

* add acceptance test to verify new behavior

* yield final transition in ec task
This commit is contained in:
Matthew Irish
2018-12-20 13:46:37 -06:00
committed by GitHub
parent fe0bb20c04
commit dc30fa9cf3
8 changed files with 132 additions and 17 deletions

View File

@@ -5,6 +5,7 @@ import { computed, set } from '@ember/object';
import { alias, or } from '@ember/object/computed';
import { task, waitForEvent } from 'ember-concurrency';
import FocusOnInsertMixin from 'vault/mixins/focus-on-insert';
import WithNavToNearestAncestor from 'vault/mixins/with-nav-to-nearest-ancestor';
import keys from 'vault/lib/keycodes';
import KVObject from 'vault/lib/kv-object';
import { maybeQueryRecord } from 'vault/macros/maybe-query-record';
@@ -13,7 +14,7 @@ const LIST_ROUTE = 'vault.cluster.secrets.backend.list';
const LIST_ROOT_ROUTE = 'vault.cluster.secrets.backend.list-root';
const SHOW_ROUTE = 'vault.cluster.secrets.backend.show';
export default Component.extend(FocusOnInsertMixin, {
export default Component.extend(FocusOnInsertMixin, WithNavToNearestAncestor, {
wizard: service(),
router: service(),
store: service(),
@@ -163,7 +164,7 @@ export default Component.extend(FocusOnInsertMixin, {
}),
transitionToRoute() {
this.router.transitionTo(...arguments);
return this.router.transitionTo(...arguments);
},
onEscape(e) {
@@ -304,8 +305,9 @@ export default Component.extend(FocusOnInsertMixin, {
},
deleteKey() {
let { id } = this.model;
this.model.destroyRecord().then(() => {
this.transitionToRoute(LIST_ROOT_ROUTE);
this.navToNearestAncestor.perform(id);
});
},