Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle api explorer routing error #12354

Merged
merged 2 commits into from Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/12354.txt
@@ -0,0 +1,3 @@
```release-note:bug
ui: Fixed api explorer routing bug
```
30 changes: 18 additions & 12 deletions ui/app/components/console/ui-panel.js
Expand Up @@ -92,12 +92,11 @@ export default Component.extend({

refreshRoute: task(function*() {
let owner = getOwner(this);
let routeName = this.router.currentRouteName;
let route = owner.lookup(`route:${routeName}`);
let currentRoute = owner.lookup(`router:main`).get('currentRouteName');

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

routeToExplore: task(function*(command) {
let filter = command.replace('api', '').trim();
let content =
'Welcome to the Vault API explorer! \nYou can search for endpoints, see what parameters they accept, and even execute requests with your current token.';
if (filter) {
content = `Welcome to the Vault API explorer! \nWe've filtered the list of endpoints for '${filter}'.`;
}
try {
yield this.router.transitionTo('vault.cluster.open-api-explorer.index', {
queryParams: { filter },
});
let content =
'Welcome to the Vault API explorer! \nYou can search for endpoints, see what parameters they accept, and even execute requests with your current token.';
if (filter) {
content = `Welcome to the Vault API explorer! \nWe've filtered the list of endpoints for '${filter}'.`;
}
this.logAndOutput(null, {
type: 'success',
content,
});
} catch (error) {
this.logAndOutput(null, {
type: 'error',
content: 'There was a problem navigating to the api explorer.',
});
if (error.message === 'TransitionAborted') {
this.logAndOutput(null, {
type: 'success',
content,
});
} else {
this.logAndOutput(null, {
type: 'error',
content: 'There was a problem navigating to the api explorer.',
});
}
}
}),

Expand Down