import { useState } from 'react'; import { useCurrentUser } from '@/react/hooks/useUser'; import { FormSection } from '@@/form-components/FormSection'; import { useHelmHTTPChartList } from '../helmChartSourceQueries/useHelmChartList'; import { Chart } from '../types'; import { HelmRegistrySelect, RepoValue, } from '../components/HelmRegistrySelect'; import { useHelmRepoOptions } from '../helmChartSourceQueries/useHelmRepositories'; import { HelmInstallForm } from './HelmInstallForm'; import { HelmTemplatesSelectedItem } from './HelmTemplatesSelectedItem'; import { HelmTemplatesList } from './HelmTemplatesList'; interface Props { onSelectHelmChart: (chartName: string) => void; namespace?: string; name?: string; } export function HelmTemplates({ onSelectHelmChart, namespace, name }: Props) { const [selectedChart, setSelectedChart] = useState(null); const [selectedRepo, setSelectedRepo] = useState(null); const { user } = useCurrentUser(); const chartListQuery = useHelmHTTPChartList( user.Id, selectedRepo?.repoUrl ?? '', !!selectedRepo?.repoUrl ); const repoOptionsQuery = useHelmRepoOptions(); const isRepoAvailable = !!repoOptionsQuery.data && repoOptionsQuery.data.length > 0; return (
{selectedChart ? ( <> ) : ( <> {selectedRepo && ( )} )}
); function clearHelmChart() { setSelectedChart(null); onSelectHelmChart(''); } function handleChartSelection(chart: Chart) { setSelectedChart(chart); onSelectHelmChart(chart.name); } }