Skip to content

Commit b882dde

Browse files
authored
Handle api explorer routing error (#12354) (#12385)
* Handle api explorer routing error - For some reason when routing is done during async process, router transtionTo throws the TransitionAbortedError - As a fix treat this particular error as success since it doesn't interfere in the routing - Reference: emberjs/ember-test-helpers#332 * Added changelog
1 parent 0818886 commit b882dde

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

changelog/12354.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
ui: Fixed api explorer routing bug
3+
```

ui/app/components/console/ui-panel.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,11 @@ export default Component.extend({
9292

9393
refreshRoute: task(function*() {
9494
let owner = getOwner(this);
95-
let routeName = this.router.currentRouteName;
96-
let route = owner.lookup(`route:${routeName}`);
95+
let currentRoute = owner.lookup(`router:main`).get('currentRouteName');
9796

9897
try {
9998
this.store.clearAllDatasets();
100-
yield route.refresh();
99+
yield this.router.transitionTo(currentRoute);
101100
this.logAndOutput(null, { type: 'success', content: 'The current screen has been refreshed!' });
102101
} catch (error) {
103102
this.logAndOutput(null, { type: 'error', content: 'The was a problem refreshing the current screen.' });
@@ -106,24 +105,31 @@ export default Component.extend({
106105

107106
routeToExplore: task(function*(command) {
108107
let filter = command.replace('api', '').trim();
108+
let content =
109+
'Welcome to the Vault API explorer! \nYou can search for endpoints, see what parameters they accept, and even execute requests with your current token.';
110+
if (filter) {
111+
content = `Welcome to the Vault API explorer! \nWe've filtered the list of endpoints for '${filter}'.`;
112+
}
109113
try {
110114
yield this.router.transitionTo('vault.cluster.open-api-explorer.index', {
111115
queryParams: { filter },
112116
});
113-
let content =
114-
'Welcome to the Vault API explorer! \nYou can search for endpoints, see what parameters they accept, and even execute requests with your current token.';
115-
if (filter) {
116-
content = `Welcome to the Vault API explorer! \nWe've filtered the list of endpoints for '${filter}'.`;
117-
}
118117
this.logAndOutput(null, {
119118
type: 'success',
120119
content,
121120
});
122121
} catch (error) {
123-
this.logAndOutput(null, {
124-
type: 'error',
125-
content: 'There was a problem navigating to the api explorer.',
126-
});
122+
if (error.message === 'TransitionAborted') {
123+
this.logAndOutput(null, {
124+
type: 'success',
125+
content,
126+
});
127+
} else {
128+
this.logAndOutput(null, {
129+
type: 'error',
130+
content: 'There was a problem navigating to the api explorer.',
131+
});
132+
}
127133
}
128134
}),
129135

0 commit comments

Comments
 (0)