import { Field, Form, Formik } from 'formik'; import { useRouter } from '@uirouter/react'; import { ContainerInstanceFormValues } from '@/react/azure/types'; import * as notifications from '@/portainer/services/notifications'; import { useUser } from '@/portainer/hooks/useUser'; import { AccessControlForm } from '@/portainer/access-control/AccessControlForm'; import { useEnvironmentId } from '@/portainer/hooks/useEnvironmentId'; import { FormControl } from '@@/form-components/FormControl'; import { Input, Select } from '@@/form-components/Input'; import { FormSectionTitle } from '@@/form-components/FormSectionTitle'; import { LoadingButton } from '@@/buttons/LoadingButton'; import { validationSchema } from './CreateContainerInstanceForm.validation'; import { PortsMappingField } from './PortsMappingField'; import { useFormState, useLoadFormState } from './useLoadFormState'; import { getSubscriptionLocations, getSubscriptionResourceGroups, } from './utils'; import { useCreateInstanceMutation } from './useCreateInstanceMutation'; export function CreateContainerInstanceForm() { const environmentId = useEnvironmentId(); const { isAdmin } = useUser(); const { providers, subscriptions, resourceGroups, isLoading } = useLoadFormState(environmentId); const { initialValues, subscriptionOptions } = useFormState( subscriptions, resourceGroups, providers ); const router = useRouter(); const { mutateAsync } = useCreateInstanceMutation( resourceGroups, environmentId ); if (isLoading) { return null; } return ( initialValues={initialValues} validationSchema={() => validationSchema(isAdmin)} onSubmit={onSubmit} validateOnMount validateOnChange enableReinitialize > {({ errors, handleSubmit, isSubmitting, isValid, values, setFieldValue, }) => (
Azure settings Container configuration setFieldValue('ports', value)} errors={errors.ports} />
This will automatically deploy a container with a public IP address
Container Resources setFieldValue('accessControl', values)} values={values.accessControl} errors={errors.accessControl} />