Merge pull request #2345 from Infisical/misc/finalize-certificate-template-and-est

finalized certificate template and EST
This commit is contained in:
Sheen
2024-08-29 12:47:13 +08:00
committed by GitHub
13 changed files with 155 additions and 63 deletions
@@ -41,4 +41,5 @@ export type SubscriptionPlan = {
caCrl: boolean;
instanceUserManagement: boolean;
externalKms: boolean;
pkiEst: boolean;
};
@@ -3,7 +3,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { createNotification } from "@app/components/notifications";
import { ProjectPermissionCan } from "@app/components/permissions";
import { Button, DeleteActionModal } from "@app/components/v2";
import { Button, DeleteActionModal, UpgradePlanModal } from "@app/components/v2";
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
import { usePopUp } from "@app/hooks";
import { useDeleteCertTemplate } from "@app/hooks/api";
@@ -16,7 +16,8 @@ export const CertificateTemplatesSection = () => {
const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
"certificateTemplate",
"deleteCertificateTemplate",
"enrollmentOptions"
"enrollmentOptions",
"upgradePlan"
] as const);
const { currentWorkspace } = useWorkspace();
@@ -85,6 +86,11 @@ export const CertificateTemplatesSection = () => {
)
}
/>
<UpgradePlanModal
isOpen={popUp.upgradePlan.isOpen}
onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
text="Managing template enrollment options for EST is only available on Infisical's Enterprise plan."
/>
</div>
);
};
@@ -19,14 +19,19 @@ import {
Tooltip,
Tr
} from "@app/components/v2";
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
import {
ProjectPermissionActions,
ProjectPermissionSub,
useSubscription,
useWorkspace
} from "@app/context";
import { useListWorkspaceCertificateTemplates } from "@app/hooks/api";
import { UsePopUpState } from "@app/hooks/usePopUp";
type Props = {
handlePopUpOpen: (
popUpName: keyof UsePopUpState<
["certificateTemplate", "deleteCertificateTemplate", "enrollmentOptions"]
["certificateTemplate", "deleteCertificateTemplate", "enrollmentOptions", "upgradePlan"]
>,
data?: {
id?: string;
@@ -37,6 +42,7 @@ type Props = {
export const CertificateTemplatesTable = ({ handlePopUpOpen }: Props) => {
const { currentWorkspace } = useWorkspace();
const { subscription } = useSubscription();
const { data, isLoading } = useListWorkspaceCertificateTemplates({
workspaceId: currentWorkspace?.id ?? ""
});
@@ -86,11 +92,16 @@ export const CertificateTemplatesTable = ({ handlePopUpOpen }: Props) => {
>
{(isAllowed) => (
<DropdownMenuItem
onClick={() =>
onClick={() => {
if (!subscription?.pkiEst) {
handlePopUpOpen("upgradePlan");
return;
}
handlePopUpOpen("enrollmentOptions", {
id: certificateTemplate.id
})
}
});
}}
className={twMerge(
!isAllowed && "pointer-events-none cursor-not-allowed opacity-50"
)}