Made required adjustments based on review

This commit is contained in:
Tuan Dang
2024-09-10 08:18:31 -07:00
parent a8fd83652d
commit 9ce6fd3f8e
6 changed files with 22 additions and 49 deletions
@@ -45,7 +45,7 @@ export const registerCaRouter = async (server: FastifyZodProvider) => {
.describe(CERTIFICATE_AUTHORITIES.CREATE.keyAlgorithm), .describe(CERTIFICATE_AUTHORITIES.CREATE.keyAlgorithm),
requireTemplateForIssuance: z requireTemplateForIssuance: z
.boolean() .boolean()
.default(true) .default(false)
.describe(CERTIFICATE_AUTHORITIES.CREATE.requireTemplateForIssuance) .describe(CERTIFICATE_AUTHORITIES.CREATE.requireTemplateForIssuance)
}) })
.refine( .refine(
@@ -101,7 +101,7 @@ export const registerCertRouter = async (server: FastifyZodProvider) => {
.refine( .refine(
(data) => (data) =>
(data.caId !== undefined && data.certificateTemplateId === undefined) || (data.caId !== undefined && data.certificateTemplateId === undefined) ||
(data.caId === undefined && data.pkiCollectionId === undefined && data.certificateTemplateId !== undefined), (data.caId === undefined && data.certificateTemplateId !== undefined),
{ {
message: "Either CA ID or Certificate Template ID must be present, but not both", message: "Either CA ID or Certificate Template ID must be present, but not both",
path: ["caId", "certificateTemplateId"] path: ["caId", "certificateTemplateId"]
@@ -192,7 +192,7 @@ export const registerCertRouter = async (server: FastifyZodProvider) => {
.refine( .refine(
(data) => (data) =>
(data.caId !== undefined && data.certificateTemplateId === undefined) || (data.caId !== undefined && data.certificateTemplateId === undefined) ||
(data.caId === undefined && data.pkiCollectionId === undefined && data.certificateTemplateId !== undefined), (data.caId === undefined && data.certificateTemplateId !== undefined),
{ {
message: "Either CA ID or Certificate Template ID must be present, but not both", message: "Either CA ID or Certificate Template ID must be present, but not both",
path: ["caId", "certificateTemplateId"] path: ["caId", "certificateTemplateId"]
@@ -36,7 +36,7 @@ export const CaDetailsSection = ({ caId, handlePopUpOpen }: Props) => {
<ProjectPermissionCan I={ProjectPermissionActions.Edit} a={ProjectPermissionSub.Identity}> <ProjectPermissionCan I={ProjectPermissionActions.Edit} a={ProjectPermissionSub.Identity}>
{(isAllowed) => { {(isAllowed) => {
return ( return (
<Tooltip content="Edit Identity"> <Tooltip content="Edit CA">
<IconButton <IconButton
isDisabled={!isAllowed} isDisabled={!isAllowed}
ariaLabel="copy icon" ariaLabel="copy icon"
@@ -446,26 +446,24 @@ export const CaModal = ({ popUp, handlePopUpToggle }: Props) => {
); );
}} }}
/> />
{/* {!ca && ( */} <div className="flex items-center">
<div className="flex items-center"> <Button
<Button className="mr-4"
className="mr-4" size="sm"
size="sm" type="submit"
type="submit" isLoading={isSubmitting}
isLoading={isSubmitting} isDisabled={isSubmitting}
isDisabled={isSubmitting} >
> {popUp?.ca?.data ? "Update" : "Create"}
{popUp?.ca?.data ? "Update" : "Create"} </Button>
</Button> <Button
<Button colorSchema="secondary"
colorSchema="secondary" variant="plain"
variant="plain" onClick={() => handlePopUpToggle("ca", false)}
onClick={() => handlePopUpToggle("ca", false)} >
> Cancel
Cancel </Button>
</Button> </div>
</div>
{/* )} */}
</form> </form>
</ModalContent> </ModalContent>
</Modal> </Modal>
@@ -59,25 +59,6 @@ export const CertificateTemplatesSection = ({ caId }: Props) => {
return ( return (
<div className="mt-4 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4"> <div className="mt-4 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
{/* <div className="mb-4 flex justify-between">
<p className="text-xl font-semibold text-mineshaft-100">Certificate Templates</p>
<ProjectPermissionCan
I={ProjectPermissionActions.Create}
a={ProjectPermissionSub.CertificateTemplates}
>
{(isAllowed) => (
<Button
colorSchema="primary"
type="submit"
leftIcon={<FontAwesomeIcon icon={faPlus} />}
onClick={() => handlePopUpOpen("certificateTemplate")}
isDisabled={!isAllowed}
>
Create
</Button>
)}
</ProjectPermissionCan>
</div> */}
<div className="flex items-center justify-between border-b border-mineshaft-400 pb-4"> <div className="flex items-center justify-between border-b border-mineshaft-400 pb-4">
<h3 className="text-lg font-semibold text-mineshaft-100">Certificate Templates</h3> <h3 className="text-lg font-semibold text-mineshaft-100">Certificate Templates</h3>
<ProjectPermissionCan <ProjectPermissionCan
@@ -47,10 +47,6 @@ export const CertificateTemplatesTable = ({ handlePopUpOpen, caId }: Props) => {
const { subscription } = useSubscription(); const { subscription } = useSubscription();
const { data, isLoading } = useGetCaCertTemplates(caId); const { data, isLoading } = useGetCaCertTemplates(caId);
// const { data, isLoading } = useListWorkspaceCertificateTemplates({
// workspaceId: currentWorkspace?.id ?? ""
// });
return ( return (
<div> <div>
@@ -59,7 +55,6 @@ export const CertificateTemplatesTable = ({ handlePopUpOpen, caId }: Props) => {
<THead> <THead>
<Tr> <Tr>
<Th>Name</Th> <Th>Name</Th>
{/* <Th>Certificate Authority</Th> */}
<Th /> <Th />
</Tr> </Tr>
</THead> </THead>
@@ -70,7 +65,6 @@ export const CertificateTemplatesTable = ({ handlePopUpOpen, caId }: Props) => {
return ( return (
<Tr className="h-10" key={`certificate-${certificateTemplate.id}`}> <Tr className="h-10" key={`certificate-${certificateTemplate.id}`}>
<Td>{certificateTemplate.name}</Td> <Td>{certificateTemplate.name}</Td>
{/* <Td>{certificateTemplate.caName}</Td> */}
<Td className="flex justify-end"> <Td className="flex justify-end">
<DropdownMenu> <DropdownMenu>
<DropdownMenuTrigger asChild className="rounded-lg"> <DropdownMenuTrigger asChild className="rounded-lg">