2024-02-15 07:01:01 +00:00
|
|
|
import { FormikErrors } from 'formik';
|
|
|
|
|
|
|
|
import { TemplateViewModel } from '@/react/portainer/templates/app-templates/view-model';
|
2024-05-06 05:08:03 +00:00
|
|
|
import { useAppTemplate } from '@/react/portainer/templates/app-templates/queries/useAppTemplates';
|
|
|
|
import { TemplateNote } from '@/react/portainer/templates/components/TemplateNote';
|
2024-04-11 06:29:30 +00:00
|
|
|
import {
|
|
|
|
EnvVarsFieldset,
|
|
|
|
EnvVarsValue,
|
|
|
|
} from '@/react/portainer/templates/app-templates/DeployFormWidget/EnvVarsFieldset';
|
2024-02-15 07:01:01 +00:00
|
|
|
|
|
|
|
export function AppTemplateFieldset({
|
2024-05-06 05:08:03 +00:00
|
|
|
templateId,
|
2024-02-15 07:01:01 +00:00
|
|
|
values,
|
|
|
|
onChange,
|
|
|
|
errors,
|
|
|
|
}: {
|
2024-05-06 05:08:03 +00:00
|
|
|
templateId: TemplateViewModel['Id'];
|
2024-04-11 06:29:30 +00:00
|
|
|
values: EnvVarsValue;
|
|
|
|
onChange: (value: EnvVarsValue) => void;
|
|
|
|
errors?: FormikErrors<EnvVarsValue>;
|
2024-02-15 07:01:01 +00:00
|
|
|
}) {
|
2024-05-06 05:08:03 +00:00
|
|
|
const templateQuery = useAppTemplate(templateId);
|
|
|
|
if (!templateQuery.data) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const template = templateQuery.data;
|
|
|
|
|
2024-02-15 07:01:01 +00:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<TemplateNote note={template.Note} />
|
|
|
|
<EnvVarsFieldset
|
|
|
|
options={template.Env || []}
|
2024-04-11 06:29:30 +00:00
|
|
|
values={values}
|
2024-02-15 07:01:01 +00:00
|
|
|
onChange={onChange}
|
|
|
|
errors={errors}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|