import { Field, Form, Formik } from 'formik'; import { useCurrentStateAndParams, useRouter } from '@uirouter/react'; import { ContainerInstanceFormValues } from '@/azure/types'; import * as notifications from '@/portainer/services/notifications'; import { useUser } from '@/portainer/hooks/useUser'; import { AccessControlForm } from '@/portainer/access-control/AccessControlForm'; 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 { InputListError } from '@@/form-components/InputList/InputList'; import { validationSchema } from './CreateContainerInstanceForm.validation'; import { PortMapping, PortsMappingField } from './PortsMappingField'; import { useLoadFormState } from './useLoadFormState'; import { getSubscriptionLocations, getSubscriptionResourceGroups, } from './utils'; import { useCreateInstance } from './useCreateInstanceMutation'; export function CreateContainerInstanceForm() { const { params: { endpointId: environmentId }, } = useCurrentStateAndParams(); if (!environmentId) { throw new Error('endpointId url param is required'); } const { isAdmin } = useUser(); const { initialValues, isLoading, providers, subscriptions, resourceGroups } = useLoadFormState(environmentId, isAdmin); const router = useRouter(); const { mutateAsync } = useCreateInstance(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 as InputListError[]} />
This will automatically deploy a container with a public IP address
Container Resources setFieldValue('accessControl', values)} values={values.accessControl} errors={errors.accessControl} />