import { useState } from 'react'; import { compact } from 'lodash'; import { NavTabs, Option } from '@@/NavTabs'; import { HelmRelease } from '../../types'; import { ManifestDetails } from './ManifestDetails'; import { NotesDetails } from './NotesDetails'; import { ValuesDetails } from './ValuesDetails'; import { ResourcesTable } from './ResourcesTable/ResourcesTable'; type Props = { release: HelmRelease; }; type Tab = 'values' | 'notes' | 'manifest' | 'resources'; function helmTabs( release: HelmRelease, isUserSupplied: boolean, setIsUserSupplied: (isUserSupplied: boolean) => void ): Option[] { return compact([ { label: 'Resources', id: 'resources', children: , }, { label: 'Values', id: 'values', children: ( ), }, { label: 'Manifest', id: 'manifest', children: , }, !!release.info?.notes && { label: 'Notes', id: 'notes', children: , }, ]); } export function ReleaseTabs({ release }: Props) { const [tab, setTab] = useState('resources'); // state is here so that the state isn't lost when the tab changes const [isUserSupplied, setIsUserSupplied] = useState(true); return ( onSelect={setTab} selectedId={tab} type="pills" justified options={helmTabs(release, isUserSupplied, setIsUserSupplied)} /> ); }