UI: Show error if tool action is not recognized (#22821)

This commit is contained in:
Chelsea Shaw
2023-09-06 15:29:35 -05:00
committed by GitHub
parent 862b7dbb95
commit 2ca784ad11
2 changed files with 11 additions and 10 deletions

View File

@@ -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) {

View File

@@ -0,0 +1,6 @@
{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: BUSL-1.1
~}}
<NotFound @model={{this.model}} />