vault/ui/app/helpers/tabs-for-auth-section.js
Chelsea Shaw 9efa76ac4c
UI: Add necessary params to links in Access & KV v2 (#26561)
* refactor tabs-for-auth-section helper

* Fill out route params in generated-item + list compoenents

* Add optional route params to ListView pagination

* Add backend to KV breadcrumb link route models

* fix links in kv v2 pages, update kv-breadcrumbs-test

* remove todo
2024-04-23 14:36:08 +00:00

137 lines
3.4 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { helper as buildHelper } from '@ember/component/helper';
import { pluralize } from 'ember-inflector';
import { capitalize } from '@ember/string';
const TABS_FOR_SETTINGS = {
aws: [
{
label: 'Client',
route: 'vault.cluster.settings.auth.configure.section',
routeParams: ['client'],
},
{
label: 'Identity Allow List Tidy',
route: 'vault.cluster.settings.auth.configure.section',
routeParams: ['identity-accesslist'],
},
{
label: 'Role Tag Deny List Tidy',
route: 'vault.cluster.settings.auth.configure.section',
routeParams: ['roletag-denylist'],
},
],
azure: [
{
label: 'Configuration',
route: 'vault.cluster.settings.auth.configure.section',
routeParams: ['configuration'],
},
],
github: [
{
label: 'Configuration',
route: 'vault.cluster.settings.auth.configure.section',
routeParams: ['configuration'],
},
],
gcp: [
{
label: 'Configuration',
route: 'vault.cluster.settings.auth.configure.section',
routeParams: ['configuration'],
},
],
jwt: [
{
label: 'Configuration',
route: 'vault.cluster.settings.auth.configure.section',
routeParams: ['configuration'],
},
],
oidc: [
{
label: 'Configuration',
route: 'vault.cluster.settings.auth.configure.section',
routeParams: ['configuration'],
},
],
kubernetes: [
{
label: 'Configuration',
route: 'vault.cluster.settings.auth.configure.section',
routeParams: ['configuration'],
},
],
ldap: [
{
label: 'Configuration',
route: 'vault.cluster.settings.auth.configure.section',
routeParams: ['configuration'],
},
],
okta: [
{
label: 'Configuration',
route: 'vault.cluster.settings.auth.configure.section',
routeParams: ['configuration'],
},
],
radius: [
{
label: 'Configuration',
route: 'vault.cluster.settings.auth.configure.section',
routeParams: ['configuration'],
},
],
};
const TABS_FOR_SHOW = {};
export function tabsForAuthSection([authMethodModel, sectionType = 'authSettings', paths]) {
let tabs;
if (sectionType === 'authSettings') {
tabs = (TABS_FOR_SETTINGS[authMethodModel.type] || []).slice();
tabs.push({
label: 'Method Options',
route: 'vault.cluster.settings.auth.configure.section',
routeParams: ['options'],
});
return tabs;
}
if (paths || authMethodModel.paths) {
if (authMethodModel.paths) {
paths = authMethodModel.paths.paths.filter((path) => path.navigation);
}
// TODO: we're unsure if we actually need compact here
// but are leaving it just in case OpenAPI ever returns an empty thing
tabs = paths.compact().map((path) => {
return {
label: capitalize(pluralize(path.itemName)),
route: 'vault.cluster.access.method.item.list',
routeParams: [path.itemType],
};
});
} else {
tabs = (TABS_FOR_SHOW[authMethodModel.type] || []).slice();
}
tabs.push({
label: 'Configuration',
route: 'vault.cluster.access.method.section',
routeParams: ['configuration'],
});
return tabs.map((tab) => ({
label: tab.label,
route: tab.route,
routeParams: [authMethodModel.id, ...tab.routeParams],
}));
}
export default buildHelper(tabsForAuthSection);