import { Field, Form, Formik } from 'formik'; import { object, SchemaOf, string } from 'yup'; import { useUpgradeEditionMutation } from '@/react/portainer/system/useUpgradeEditionMutation'; import { notifySuccess } from '@/portainer/services/notifications'; import { useAnalytics } from '@/react/hooks/useAnalytics'; import { Button, LoadingButton } from '@@/buttons'; import { FormControl } from '@@/form-components/FormControl'; import { Input } from '@@/form-components/Input'; import { Modal } from '@@/modals/Modal'; import { Alert } from '@@/Alert'; interface FormValues { license: string; } const initialValues: FormValues = { license: '', }; export function UploadLicenseDialog({ onDismiss, goToLoading, goToGetLicense, isGetLicenseSubmitted, }: { onDismiss: () => void; goToLoading: () => void; goToGetLicense: () => void; isGetLicenseSubmitted: boolean; }) { const upgradeMutation = useUpgradeEditionMutation(); const { trackEvent } = useAnalytics(); return ( Upgrade Portainer} /> {({ errors }) => (
{!isGetLicenseSubmitted ? (

Please enter your Portainer License below

) : (
Please check your email and copy your license into the field below to upgrade Portainer.
)}
Start upgrade
)}
); function handleSubmit(values: FormValues) { upgradeMutation.mutate(values, { onSuccess() { trackEvent('portainer-upgrade-license-key-provided', { category: 'portainer', metadata: { Upgrade: 'true', }, }); notifySuccess('Starting upgrade', 'License validated successfully'); goToLoading(); }, }); } } function validation(): SchemaOf { return object().shape({ license: string() .required('License is required') .matches(/^\d-.+/, 'License is invalid'), }); }