mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-05 23:26:42 +00:00
Small fix on templates v2 form
This commit is contained in:
@@ -159,8 +159,8 @@ export type TCreateCertificateDTO = {
|
|||||||
ttl: string; // string compatible with ms
|
ttl: string; // string compatible with ms
|
||||||
notBefore?: string;
|
notBefore?: string;
|
||||||
notAfter?: string;
|
notAfter?: string;
|
||||||
keyUsages: CertKeyUsage[];
|
keyUsages: string[];
|
||||||
extendedKeyUsages: CertExtendedKeyUsage[];
|
extendedKeyUsages: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TCreateCertificateResponse = {
|
export type TCreateCertificateResponse = {
|
||||||
|
|||||||
+9
-9
@@ -94,9 +94,9 @@ const createSchema = (shouldShowSubjectSection: boolean) => {
|
|||||||
export type FormData = z.infer<ReturnType<typeof createSchema>>;
|
export type FormData = z.infer<ReturnType<typeof createSchema>>;
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
popUp: UsePopUpState<["certificateIssuance"]>;
|
popUp: UsePopUpState<["issueCertificate"]>;
|
||||||
handlePopUpToggle: (
|
handlePopUpToggle: (
|
||||||
popUpName: keyof UsePopUpState<["certificateIssuance"]>,
|
popUpName: keyof UsePopUpState<["issueCertificate"]>,
|
||||||
state?: boolean
|
state?: boolean
|
||||||
) => void;
|
) => void;
|
||||||
profileId?: string;
|
profileId?: string;
|
||||||
@@ -115,7 +115,7 @@ export const CertificateIssuanceModal = ({ popUp, handlePopUpToggle, profileId }
|
|||||||
const { currentProject } = useProject();
|
const { currentProject } = useProject();
|
||||||
|
|
||||||
const inputSerialNumber =
|
const inputSerialNumber =
|
||||||
(popUp?.certificateIssuance?.data as { serialNumber: string })?.serialNumber || "";
|
(popUp?.issueCertificate?.data as { serialNumber: string })?.serialNumber || "";
|
||||||
const sanitizedSerialNumber = inputSerialNumber.replace(/[^a-fA-F0-9:]/g, "");
|
const sanitizedSerialNumber = inputSerialNumber.replace(/[^a-fA-F0-9:]/g, "");
|
||||||
|
|
||||||
const { data: cert } = useGetCert(sanitizedSerialNumber);
|
const { data: cert } = useGetCert(sanitizedSerialNumber);
|
||||||
@@ -181,7 +181,7 @@ export const CertificateIssuanceModal = ({ popUp, handlePopUpToggle, profileId }
|
|||||||
} = useCertificateTemplate(
|
} = useCertificateTemplate(
|
||||||
templateData,
|
templateData,
|
||||||
actualSelectedProfile,
|
actualSelectedProfile,
|
||||||
popUp?.certificateIssuance?.isOpen || false,
|
popUp?.issueCertificate?.isOpen || false,
|
||||||
setValue,
|
setValue,
|
||||||
watch
|
watch
|
||||||
);
|
);
|
||||||
@@ -227,10 +227,10 @@ export const CertificateIssuanceModal = ({ popUp, handlePopUpToggle, profileId }
|
|||||||
}, [cert, reset]);
|
}, [cert, reset]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (popUp?.certificateIssuance?.isOpen && profileId && !cert) {
|
if (popUp?.issueCertificate?.isOpen && profileId && !cert) {
|
||||||
setValue("profileId", profileId);
|
setValue("profileId", profileId);
|
||||||
}
|
}
|
||||||
}, [popUp?.certificateIssuance?.isOpen, profileId, cert, setValue]);
|
}, [popUp?.issueCertificate?.isOpen, profileId, cert, setValue]);
|
||||||
|
|
||||||
const onFormSubmit = useCallback(
|
const onFormSubmit = useCallback(
|
||||||
async ({
|
async ({
|
||||||
@@ -332,9 +332,9 @@ export const CertificateIssuanceModal = ({ popUp, handlePopUpToggle, profileId }
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
isOpen={popUp?.certificateIssuance?.isOpen}
|
isOpen={popUp?.issueCertificate?.isOpen}
|
||||||
onOpenChange={(isOpen) => {
|
onOpenChange={(isOpen) => {
|
||||||
handlePopUpToggle("certificateIssuance", isOpen);
|
handlePopUpToggle("issueCertificate", isOpen);
|
||||||
if (!isOpen) {
|
if (!isOpen) {
|
||||||
resetAllState();
|
resetAllState();
|
||||||
}
|
}
|
||||||
@@ -503,7 +503,7 @@ export const CertificateIssuanceModal = ({ popUp, handlePopUpToggle, profileId }
|
|||||||
colorSchema="secondary"
|
colorSchema="secondary"
|
||||||
variant="plain"
|
variant="plain"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
handlePopUpToggle("certificateIssuance", false);
|
handlePopUpToggle("issueCertificate", false);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Cancel
|
Cancel
|
||||||
|
|||||||
@@ -201,10 +201,14 @@ export const CertificateModal = ({ popUp, handlePopUpToggle, preselectedTemplate
|
|||||||
ttl,
|
ttl,
|
||||||
keyUsages: Object.entries(keyUsages)
|
keyUsages: Object.entries(keyUsages)
|
||||||
.filter(([, value]) => value)
|
.filter(([, value]) => value)
|
||||||
.map(([key]) => key as CertKeyUsage),
|
.map(([key]) =>
|
||||||
|
key === CertKeyUsage.CRL_SIGN
|
||||||
|
? "cRLSign"
|
||||||
|
: key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase())
|
||||||
|
),
|
||||||
extendedKeyUsages: Object.entries(extendedKeyUsages)
|
extendedKeyUsages: Object.entries(extendedKeyUsages)
|
||||||
.filter(([, value]) => value)
|
.filter(([, value]) => value)
|
||||||
.map(([key]) => key as CertExtendedKeyUsage)
|
.map(([key]) => key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase()))
|
||||||
});
|
});
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export const CertificatesSection = () => {
|
|||||||
const { mutateAsync: deleteCert } = useDeleteCert();
|
const { mutateAsync: deleteCert } = useDeleteCert();
|
||||||
|
|
||||||
const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
|
const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
|
||||||
"certificateIssuance",
|
"issueCertificate",
|
||||||
"certificateImport",
|
"certificateImport",
|
||||||
"certificateCert",
|
"certificateCert",
|
||||||
"deleteCertificate",
|
"deleteCertificate",
|
||||||
@@ -71,7 +71,7 @@ export const CertificatesSection = () => {
|
|||||||
colorSchema="primary"
|
colorSchema="primary"
|
||||||
type="submit"
|
type="submit"
|
||||||
leftIcon={<FontAwesomeIcon icon={faPlus} />}
|
leftIcon={<FontAwesomeIcon icon={faPlus} />}
|
||||||
onClick={() => handlePopUpOpen("certificateIssuance")}
|
onClick={() => handlePopUpOpen("issueCertificate")}
|
||||||
isDisabled={!isAllowed}
|
isDisabled={!isAllowed}
|
||||||
>
|
>
|
||||||
Issue
|
Issue
|
||||||
|
|||||||
+2
-2
@@ -44,7 +44,7 @@ export const ProfileRow = ({ profile, onEditProfile, onDeleteProfile }: Props) =
|
|||||||
|
|
||||||
const { data: caData } = useGetCaById(profile.caId);
|
const { data: caData } = useGetCaById(profile.caId);
|
||||||
|
|
||||||
const { popUp, handlePopUpToggle } = usePopUp(["certificateIssuance"] as const);
|
const { popUp, handlePopUpToggle } = usePopUp(["issueCertificate"] as const);
|
||||||
|
|
||||||
const [isIdCopied, setIsIdCopied] = useToggle(false);
|
const [isIdCopied, setIsIdCopied] = useToggle(false);
|
||||||
|
|
||||||
@@ -147,7 +147,7 @@ export const ProfileRow = ({ profile, onEditProfile, onDeleteProfile }: Props) =
|
|||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
handlePopUpToggle("certificateIssuance");
|
handlePopUpToggle("issueCertificate");
|
||||||
}}
|
}}
|
||||||
icon={<FontAwesomeIcon icon={faPlus} />}
|
icon={<FontAwesomeIcon icon={faPlus} />}
|
||||||
>
|
>
|
||||||
|
|||||||
+4
-1
@@ -251,7 +251,10 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"
|
|||||||
|
|
||||||
const { control, handleSubmit, reset, watch, setValue, formState } = useForm<FormData>({
|
const { control, handleSubmit, reset, watch, setValue, formState } = useForm<FormData>({
|
||||||
resolver: zodResolver(templateSchema),
|
resolver: zodResolver(templateSchema),
|
||||||
defaultValues: getDefaultValues()
|
defaultValues: getDefaultValues(),
|
||||||
|
mode: "onChange",
|
||||||
|
reValidateMode: "onChange",
|
||||||
|
criteriaMode: "all"
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user