mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-25 08:31:09 +02:00
* make displayName a global helper * rename authTabTypes to visibleMountsByType * remove superfluous arg * move all of mount displaying to component * rename hasMountData to isVisibleMount, update comment
33 lines
835 B
TypeScript
33 lines
835 B
TypeScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Component from '@glimmer/component';
|
|
import { action } from '@ember/object';
|
|
|
|
import type { UnauthMountsByType } from 'vault/vault/auth/form';
|
|
|
|
interface Args {
|
|
authTabData: UnauthMountsByType;
|
|
handleTabClick: CallableFunction;
|
|
selectedAuthMethod: string;
|
|
}
|
|
|
|
export default class AuthTabs extends Component<Args> {
|
|
get tabTypes() {
|
|
return this.args.authTabData ? Object.keys(this.args.authTabData) : [];
|
|
}
|
|
|
|
get selectedTabIndex() {
|
|
const index = this.tabTypes.indexOf(this.args.selectedAuthMethod);
|
|
// negative index means the selected method isn't a tab, default to first tab
|
|
return index < 0 ? 0 : index;
|
|
}
|
|
|
|
@action
|
|
onClickTab(_event: Event, idx: number) {
|
|
this.args.handleTabClick(this.tabTypes[idx]);
|
|
}
|
|
}
|