2025-06-05 13:13:45 +12:00
|
|
|
import { Form, useFormikContext } from 'formik';
|
|
|
|
import { useMemo } from 'react';
|
|
|
|
|
|
|
|
import { FormActions } from '@@/form-components/FormActions';
|
|
|
|
import { FormControl } from '@@/form-components/FormControl';
|
|
|
|
import { Option, PortainerSelect } from '@@/form-components/PortainerSelect';
|
|
|
|
import { FormSection } from '@@/form-components/FormSection';
|
|
|
|
|
|
|
|
import { Chart } from '../types';
|
|
|
|
import { useHelmChartValues } from '../queries/useHelmChartValues';
|
|
|
|
import { HelmValuesInput } from '../components/HelmValuesInput';
|
|
|
|
|
|
|
|
import { HelmInstallFormValues } from './types';
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
selectedChart: Chart;
|
|
|
|
namespace?: string;
|
|
|
|
name?: string;
|
2025-06-09 20:08:50 +12:00
|
|
|
versionOptions: Option<string>[];
|
2025-06-05 13:13:45 +12:00
|
|
|
};
|
|
|
|
|
|
|
|
export function HelmInstallInnerForm({
|
|
|
|
selectedChart,
|
|
|
|
namespace,
|
|
|
|
name,
|
|
|
|
versionOptions,
|
|
|
|
}: Props) {
|
|
|
|
const { values, setFieldValue, isSubmitting } =
|
|
|
|
useFormikContext<HelmInstallFormValues>();
|
|
|
|
|
|
|
|
const chartValuesRefQuery = useHelmChartValues({
|
|
|
|
chart: selectedChart.name,
|
|
|
|
repo: selectedChart.repo,
|
|
|
|
version: values?.version,
|
|
|
|
});
|
|
|
|
|
|
|
|
const selectedVersion = useMemo(
|
|
|
|
() =>
|
2025-06-09 20:08:50 +12:00
|
|
|
versionOptions.find((v) => v.value === values.version)?.value ??
|
2025-06-05 13:13:45 +12:00
|
|
|
versionOptions[0]?.value,
|
|
|
|
[versionOptions, values.version]
|
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Form className="form-horizontal">
|
|
|
|
<div className="form-group !m-0">
|
|
|
|
<FormSection title="Configuration" className="mt-4">
|
|
|
|
<FormControl
|
|
|
|
label="Version"
|
|
|
|
inputId="version-input"
|
|
|
|
loadingText="Loading versions..."
|
|
|
|
>
|
2025-06-09 20:08:50 +12:00
|
|
|
<PortainerSelect<string>
|
2025-06-05 13:13:45 +12:00
|
|
|
value={selectedVersion}
|
|
|
|
options={versionOptions}
|
|
|
|
onChange={(version) => {
|
|
|
|
if (version) {
|
2025-06-09 20:08:50 +12:00
|
|
|
setFieldValue('version', version);
|
2025-06-05 13:13:45 +12:00
|
|
|
}
|
|
|
|
}}
|
|
|
|
data-cy="helm-version-input"
|
|
|
|
/>
|
|
|
|
</FormControl>
|
|
|
|
<HelmValuesInput
|
|
|
|
values={values.values}
|
|
|
|
setValues={(values) => setFieldValue('values', values)}
|
|
|
|
valuesRef={chartValuesRefQuery.data?.values ?? ''}
|
|
|
|
isValuesRefLoading={chartValuesRefQuery.isInitialLoading}
|
|
|
|
/>
|
|
|
|
</FormSection>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<FormActions
|
|
|
|
submitLabel="Install"
|
|
|
|
loadingText="Installing Helm chart"
|
|
|
|
isLoading={isSubmitting}
|
|
|
|
isValid={!!namespace && !!name}
|
|
|
|
data-cy="helm-install"
|
|
|
|
/>
|
|
|
|
</Form>
|
|
|
|
);
|
|
|
|
}
|