Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
refactor: remove confirmation dialog from re-enroll, remove expired token state
bernie-g2d027bbcdf2e
diff --git a/frontend/src/hooks/api/gateways/queries.tsx b/frontend/src/hooks/api/gateways/queries.tsxindex 2e2f5dac4c..9015f2bb17 100644--- a/frontend/src/hooks/api/gateways/queries.tsx+++ b/frontend/src/hooks/api/gateways/queries.tsx@@ -48,20 +48,18 @@ export const gatewaysQueryKeys = {...g,isV1: true as const,isPending: false as const,- isExpired: false as const,hasReEnrollToken: false as const})),...dataV2.map((g) => {const hasHeartbeat = !!g.heartbeat;- const isPending = g.enrollmentTokenStatus === "pending" && !hasHeartbeat;+ const hasToken = g.enrollmentTokenStatus === "pending" || g.enrollmentTokenStatus === "expired";+ const isPending = hasToken && !hasHeartbeat;const hasReEnrollToken = g.enrollmentTokenStatus === "pending" && hasHeartbeat;- const isExpired = g.enrollmentTokenStatus === "expired" && !hasHeartbeat;return {...g,isV1: false as const,isPending,- isExpired,hasReEnrollToken};})diff --git a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/GatewayTab.tsx b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/GatewayTab.tsxindex 77f0bacb0d..b30d5c49c9 100644--- a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/GatewayTab.tsx+++ b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/GatewayTab.tsx@@ -59,24 +59,12 @@ import { ReEnrollGatewayModal } from "./components/ReEnrollGatewayModal";const GatewayHealthStatus = ({heartbeat,lastHealthCheckStatus,- isPending,- isExpired+ isPending}: {heartbeat?: string | null;lastHealthCheckStatus?: GatewayHealthCheckStatus | null;isPending?: boolean;- isExpired?: boolean;}) => {- if (isExpired) {- return (- <Tooltip content="Enrollment token has expired. Re-enroll to generate a new one.">- <span className="inline-flex cursor-default items-center gap-1.5 text-red-400">- Expired- </span>- </Tooltip>- );- }-if (isPending) {return (<Tooltip content="Waiting for gateway to enroll using the CLI command">@@ -267,13 +255,6 @@ export const GatewayTab = withPermission(<div className="flex items-center gap-2"><span>{el.name}</span>{(() => {- if ("isExpired" in el && el.isExpired) {- return (- <span className="rounded-sm bg-red-900/30 px-1.5 py-0.5 text-xs text-red-400">- Expired- </span>- );- }if (el.isPending) {return (<span className="rounded-sm bg-yellow-900/30 px-1.5 py-0.5 text-xs text-yellow-500">@@ -317,7 +298,6 @@ export const GatewayTab = withPermission("lastHealthCheckStatus" in el ? el.lastHealthCheckStatus : null}isPending={el.isPending}- isExpired={"isExpired" in el ? el.isExpired : false}/></Td><Td className="w-5">diff --git a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/ReEnrollGatewayModal.tsx b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/ReEnrollGatewayModal.tsxindex a37f98f0c8..6c10cc8d13 100644--- a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/ReEnrollGatewayModal.tsx+++ b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/ReEnrollGatewayModal.tsx@@ -1,11 +1,10 @@-import { useMemo, useState } from "react";+import { useEffect, useMemo, useState } from "react";import { faCopy } from "@fortawesome/free-solid-svg-icons";import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";import { createNotification } from "@app/components/notifications";import {Button,- FormControl,FormLabel,IconButton,Input,@@ -26,24 +25,27 @@ export const ReEnrollGatewayModal = ({ isOpen, onOpenChange, gatewayData }: Propconst portSuffix = port && port !== "80" ? `:${port}` : "";const siteURL = `${protocol}//${hostname}${portSuffix}`;- const [step, setStep] = useState<"confirm" | "command">("confirm");const [enrollmentToken, setEnrollmentToken] = useState("");- const [confirmText, setConfirmText] = useState("");+ const [isLoading, setIsLoading] = useState(false);- const { mutateAsync: configureTokenAuth, isPending: isReEnrolling } =- useConfigureGatewayTokenAuth();+ const { mutateAsync: configureTokenAuth } = useConfigureGatewayTokenAuth();- const handleReEnroll = async () => {- if (!gatewayData || confirmText !== "confirm") return;+ useEffect(() => {+ if (!isOpen || !gatewayData) return;- try {- const result = await configureTokenAuth({ gatewayId: gatewayData.id });- setEnrollmentToken(result.token);- setStep("command");- } catch {- createNotification({ type: "error", text: "Failed to re-enroll gateway" });- }- };+ setIsLoading(true);+ configureTokenAuth({ gatewayId: gatewayData.id })+ .then((result) => {+ setEnrollmentToken(result.token);+ })+ .catch(() => {+ createNotification({ type: "error", text: "Failed to generate enrollment token" });+ onOpenChange(false);+ })+ .finally(() => {+ setIsLoading(false);+ });+ }, [isOpen, gatewayData?.id]);const command = useMemo(() => {const gatewayName = gatewayData?.name ?? "";@@ -52,9 +54,7 @@ export const ReEnrollGatewayModal = ({ isOpen, onOpenChange, gatewayData }: Propconst handleClose = (open: boolean) => {if (!open) {- setStep("confirm");setEnrollmentToken("");- setConfirmText("");}onOpenChange(open);};@@ -63,83 +63,45 @@ export const ReEnrollGatewayModal = ({ isOpen, onOpenChange, gatewayData }: Propreturn (<Modal isOpen={isOpen} onOpenChange={handleClose}>- {step === "confirm" && (- <ModalContent- title={`Re-enroll ${gatewayData.name}`}- subTitle="This will create a new enrollment token. The existing gateway will keep running until the new machine enrolls."- footerContent={- <div className="mx-2 flex items-center">- <Button- className="mr-4"- colorSchema="danger"- isDisabled={confirmText !== "confirm" || isReEnrolling}- onClick={handleReEnroll}- isLoading={isReEnrolling}+ <ModalContent+ className="max-w-2xl"+ title={`Re-enroll ${gatewayData.name}`}+ subTitle="The existing gateway will keep running until the new machine enrolls."+ >+ {isLoading ? (+ <p className="text-sm text-mineshaft-300">Generating enrollment token...</p>+ ) : (+ <>+ <p className="mb-3 text-sm text-mineshaft-300">+ Run the following command on the machine where you want to deploy the gateway. The+ token expires in 1 hour and can only be used once.+ </p>+ <FormLabel label="CLI Command" />+ <div className="flex gap-2">+ <Input value={command} isDisabled />+ <IconButton+ ariaLabel="copy"+ variant="outline_bg"+ colorSchema="secondary"+ onClick={() => {+ navigator.clipboard.writeText(command);+ createNotification({ text: "Command copied to clipboard", type: "info" });+ }}+ className="w-10">- Re-enroll- </Button>+ <FontAwesomeIcon icon={faCopy} />+ </IconButton>+ </div>+ <div className="mt-6 flex items-center"><ModalClose asChild>- <Button variant="plain" colorSchema="secondary">- Cancel+ <Button className="mr-4" size="sm" colorSchema="secondary">+ Done</Button></ModalClose></div>- }- >- <form- onSubmit={(evt) => {- evt.preventDefault();- if (confirmText === "confirm") handleReEnroll();- }}- >- <FormControl- label={- <div className="pb-2 text-sm break-words">- Type <span className="font-bold">confirm</span> to perform this action- </div>- }- className="mb-0"- >- <Input- value={confirmText}- onChange={(e) => setConfirmText(e.target.value)}- placeholder="Type confirm here"- />- </FormControl>- </form>- </ModalContent>- )}- {step === "command" && (- <ModalContent className="max-w-2xl" title={`Re-enroll ${gatewayData.name}`}>- <p className="mb-3 text-sm text-mineshaft-300">- Run the following command on the machine where you want to deploy the gateway. The token- expires in 1 hour and can only be used once.- </p>- <FormLabel label="CLI Command" />- <div className="flex gap-2">- <Input value={command} isDisabled />- <IconButton- ariaLabel="copy"- variant="outline_bg"- colorSchema="secondary"- onClick={() => {- navigator.clipboard.writeText(command);- createNotification({ text: "Command copied to clipboard", type: "info" });- }}- className="w-10"- >- <FontAwesomeIcon icon={faCopy} />- </IconButton>- </div>- <div className="mt-6 flex items-center">- <ModalClose asChild>- <Button className="mr-4" size="sm" colorSchema="secondary">- Done- </Button>- </ModalClose>- </div>- </ModalContent>- )}+ </>+ )}+ </ModalContent></Modal>);};