From 4f75d5f9ee2d0790c54f8ee3683746198da822e1 Mon Sep 17 00:00:00 2001 From: hc-github-team-secure-vault-core <82990506+hc-github-team-secure-vault-core@users.noreply.github.com> Date: Fri, 8 Sep 2023 12:28:23 -0400 Subject: [PATCH] Backport of UI: Show error if tool action is not recognized into release/1.14.x (#22830) * backport of commit 2ca784ad11cac0e4b131f00770a774389d16a36c --------- Co-authored-by: Chelsea Shaw <82459713+hashishaw@users.noreply.github.com> Co-authored-by: Chelsea Shaw --- ui/app/routes/vault/cluster/tools/tool.js | 15 +++++---------- ui/app/templates/vault/cluster/tools/error.hbs | 1 + 2 files changed, 6 insertions(+), 10 deletions(-) create mode 100644 ui/app/templates/vault/cluster/tools/error.hbs diff --git a/ui/app/routes/vault/cluster/tools/tool.js b/ui/app/routes/vault/cluster/tools/tool.js index 948d46bdd..1eb0a2737 100644 --- a/ui/app/routes/vault/cluster/tools/tool.js +++ b/ui/app/routes/vault/cluster/tools/tool.js @@ -7,17 +7,12 @@ import Route from '@ember/routing/route'; import { toolsActions } from 'vault/helpers/tools-actions'; export default Route.extend({ - beforeModel(transition) { - const supportedActions = toolsActions(); - const { selected_action: selectedAction } = this.paramsFor(this.routeName); - if (!selectedAction || !supportedActions.includes(selectedAction)) { - transition.abort(); - return this.transitionTo(this.routeName, supportedActions[0]); - } - }, - model(params) { - return params.selected_action; + const supportedActions = toolsActions(); + if (supportedActions.includes(params.selected_action)) { + return params.selected_action; + } + throw new Error('Given param is not a supported tool action'); }, setupController(controller, model) { diff --git a/ui/app/templates/vault/cluster/tools/error.hbs b/ui/app/templates/vault/cluster/tools/error.hbs new file mode 100644 index 000000000..95d71697f --- /dev/null +++ b/ui/app/templates/vault/cluster/tools/error.hbs @@ -0,0 +1 @@ + \ No newline at end of file