mirror of
https://github.com/jc21/nginx-proxy-manager.git
synced 2024-08-30 18:22:48 +00:00
Basis for create certificate dialog
This commit is contained in:
parent
374447ccc7
commit
1b61176818
@ -1,5 +1,8 @@
|
|||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
|
ButtonGroup,
|
||||||
FormControl,
|
FormControl,
|
||||||
FormErrorMessage,
|
FormErrorMessage,
|
||||||
FormLabel,
|
FormLabel,
|
||||||
@ -29,9 +32,15 @@ function CertificateCreateModal({
|
|||||||
isOpen,
|
isOpen,
|
||||||
onClose,
|
onClose,
|
||||||
}: CertificateCreateModalProps) {
|
}: CertificateCreateModalProps) {
|
||||||
|
const [certType, setCertType] = useState("");
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
const { mutate: setCertificate } = useSetCertificate();
|
const { mutate: setCertificate } = useSetCertificate();
|
||||||
|
|
||||||
|
const onModalClose = () => {
|
||||||
|
onClose();
|
||||||
|
setCertType("");
|
||||||
|
};
|
||||||
|
|
||||||
const onSubmit = async (
|
const onSubmit = async (
|
||||||
payload: Certificate,
|
payload: Certificate,
|
||||||
{ setErrors, setSubmitting }: any,
|
{ setErrors, setSubmitting }: any,
|
||||||
@ -60,13 +69,13 @@ function CertificateCreateModal({
|
|||||||
showErr(err.message);
|
showErr(err.message);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onSuccess: () => onClose(),
|
onSuccess: () => onModalClose(),
|
||||||
onSettled: () => setSubmitting(false),
|
onSettled: () => setSubmitting(false),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal isOpen={isOpen} onClose={onClose} closeOnOverlayClick={false}>
|
<Modal isOpen={isOpen} onClose={onModalClose} closeOnOverlayClick={false}>
|
||||||
<ModalOverlay />
|
<ModalOverlay />
|
||||||
<ModalContent>
|
<ModalContent>
|
||||||
<Formik
|
<Formik
|
||||||
@ -87,6 +96,27 @@ function CertificateCreateModal({
|
|||||||
</ModalHeader>
|
</ModalHeader>
|
||||||
<ModalCloseButton />
|
<ModalCloseButton />
|
||||||
<ModalBody>
|
<ModalBody>
|
||||||
|
{certType === "" ? (
|
||||||
|
<FormControl>
|
||||||
|
<FormLabel htmlFor="type">
|
||||||
|
Select the Certificate Validation method
|
||||||
|
</FormLabel>
|
||||||
|
<ButtonGroup style={{ width: "100%" }}>
|
||||||
|
<Button
|
||||||
|
onClick={() => setCertType("http")}
|
||||||
|
style={{ width: "50%" }}>
|
||||||
|
HTTP
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
onClick={() => setCertType("dns")}
|
||||||
|
style={{ width: "50%" }}>
|
||||||
|
DNS
|
||||||
|
</Button>
|
||||||
|
</ButtonGroup>
|
||||||
|
</FormControl>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{certType !== "" ? (
|
||||||
<Stack spacing={4}>
|
<Stack spacing={4}>
|
||||||
<Field name="name" validate={validateString(1, 100)}>
|
<Field name="name" validate={validateString(1, 100)}>
|
||||||
{({ field, form }: any) => (
|
{({ field, form }: any) => (
|
||||||
@ -105,17 +135,22 @@ function CertificateCreateModal({
|
|||||||
id: "name",
|
id: "name",
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
<FormErrorMessage>{form.errors.name}</FormErrorMessage>
|
<FormErrorMessage>
|
||||||
|
{form.errors.name}
|
||||||
|
</FormErrorMessage>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
)}
|
)}
|
||||||
</Field>
|
</Field>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
) : null}
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
<ModalFooter>
|
<ModalFooter>
|
||||||
|
{certType !== "" ? (
|
||||||
<PrettyButton mr={3} isLoading={isSubmitting}>
|
<PrettyButton mr={3} isLoading={isSubmitting}>
|
||||||
{intl.formatMessage({ id: "form.save" })}
|
{intl.formatMessage({ id: "form.save" })}
|
||||||
</PrettyButton>
|
</PrettyButton>
|
||||||
<Button onClick={onClose} isLoading={isSubmitting}>
|
) : null}
|
||||||
|
<Button onClick={onModalClose} isLoading={isSubmitting}>
|
||||||
{intl.formatMessage({ id: "form.cancel" })}
|
{intl.formatMessage({ id: "form.cancel" })}
|
||||||
</Button>
|
</Button>
|
||||||
</ModalFooter>
|
</ModalFooter>
|
||||||
|
Loading…
Reference in New Issue
Block a user