vault/ui/app/utils/backend-route-helpers.ts
Vault Automation 91025c9ce7
[VAULT-33083] UI: support builtin plugins as external plugins (#11244) (#11489)
* [VAULT-33083] UI: support builtin plugins as external plugins

* address copilot review comments

* add changelog

* remove unused id property

* address some nits & add test coverage

* should use utils instead of mixins

* update comments

* move/consolidate logic for 'transform' engine type into ENGINE_TYPE_TO_MODEL_TYPE_MAP, added/updated test coverage

* cleanup: extract transform engine model type logic into helper functions

* address pr comment

* separation of concerns - move relevant vars/fns from all engines metadata to external plugin helpers & secret engine model helpers files

* add TODO; remove unnecessary exports

* rename secret-engine-model-helpers to secret-engine-helpers

* update unknown engine metadata from var to fn to handle a methodType param

* remove unnecessary test

* update changelog; return methodType for unknown engine metadata, simplify code for readability

* add optional chaining for fail-safe

* address kvv1 edge case - on exit configuration, kvv1 should redirect to list-root while kvv2 should redirect to the engineRoute defined in all-engines-metadata

* add ibm header

* fix test failure after updating unknown engine type

Co-authored-by: Shannon Roberts (Beagin) <beagins@users.noreply.github.com>
2025-12-18 18:29:20 +00:00

35 lines
1 KiB
TypeScript

/**
* Copyright IBM Corp. 2016, 2025
* SPDX-License-Identifier: BUSL-1.1
*/
import Route from '@ember/routing/route';
import { getEffectiveEngineType } from 'vault/utils/external-plugin-helpers';
/**
* Utility functions for backend-related route operations.
* Replaces the deprecated backend-helpers mixin.
*/
/**
* Get the effective engine type for a given route's backend.
* This handles external plugin mapping to builtin types.
*
* @param route - The Ember route instance
* @returns The effective engine type
*/
export function getBackendEffectiveType(route: Route): string {
const backendModel = route.modelFor('vault.cluster.secrets.backend') as { engineType: string };
return getEffectiveEngineType(backendModel?.engineType);
}
/**
* Get the current backend path parameter from a route.
*
* @param route - The Ember route instance
* @returns The backend path
*/
export function getEnginePathParam(route: Route): string {
const params = route.paramsFor('vault.cluster.secrets.backend') as { backend: string };
return params?.backend;
}