claire bontempo e8c196aa62
UI: Update template helpers and cleanup component args (#30580)
* 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
2025-05-12 11:13:24 -07:00

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]);
}
}