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
import { PlusIcon } from "lucide-react";
import { createNotification } from "@app/components/notifications";
import { Button, Checkbox, Field, FieldLabel, Spinner } from "@app/components/v3";
import { ConfirmationAlertDialog } from "@app/components/v3/platform";
import { useProject } from "@app/context";
import { usePopUp, useToggle } from "@app/hooks";
import {
useDeleteIntegration,
useGetCloudIntegrations,
useGetWorkspaceIntegrations
} from "@app/hooks/api";
import { TIntegration } from "@app/hooks/api/integrations/types";
import { IntegrationsTable } from "./IntegrationsTable";
import { NativeIntegrationsCreationBlockedModal } from "./NativeIntegrationsCreationBlockedModal";
import { NativeIntegrationsDeprecationAlert } from "./NativeIntegrationsDeprecationAlert";
export const NativeIntegrationsTab = () => {
const { currentProject } = useProject();
const { environments, id: workspaceId } = currentProject;
const { data: cloudIntegrations, isPending: isCloudIntegrationsLoading } =
useGetCloudIntegrations();
const { data: integrations, isPending: isIntegrationLoading } =
useGetWorkspaceIntegrations(workspaceId);
const { mutateAsync: deleteIntegration } = useDeleteIntegration();
const handleIntegrationDelete = async (
integrationId: string,
shouldDeleteIntegrationSecrets: boolean,
cb: () => void
) => {
await deleteIntegration({ id: integrationId, workspaceId, shouldDeleteIntegrationSecrets });
if (cb) cb();
createNotification({
type: "success",
text: "Deleted integration"
});
};
const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
"deleteConfirmation",
"deleteSecretsConfirmation",
"creationBlocked"
] as const);
const [shouldDeleteSecrets, setShouldDeleteSecrets] = useToggle(false);
if (isIntegrationLoading || isCloudIntegrationsLoading)
return (
<div className="flex h-[60vh] flex-col items-center justify-center gap-2">
<Spinner />
</div>
);
return (
<>
<NativeIntegrationsDeprecationAlert />
<div className="w-full rounded-lg border border-border-control bg-surface-base p-4">
<div className="mb-4 flex items-center justify-between">
<p className="text-xl font-medium text-foreground">Native Integrations</p>
<Button variant="outline" onClick={() => handlePopUpOpen("creationBlocked")}>
<PlusIcon />
Add Integration
</Button>
</div>
<IntegrationsTable
cloudIntegrations={cloudIntegrations}
integrations={integrations}
isLoading={isIntegrationLoading}
workspaceId={workspaceId}
environments={environments}
onDeleteIntegration={(integration) => {
setShouldDeleteSecrets.off();
handlePopUpOpen("deleteConfirmation", integration);
}}
/>
</div>
<NativeIntegrationsCreationBlockedModal
isOpen={popUp.creationBlocked.isOpen}
onOpenChange={(isOpen) => handlePopUpToggle("creationBlocked", isOpen)}
/>
<ConfirmationAlertDialog
isOpen={popUp.deleteConfirmation.isOpen}
title={`Are you sure you want to remove ${
(popUp?.deleteConfirmation.data as TIntegration)?.integration || " "
} integration for ${
(popUp?.deleteConfirmation.data as TIntegration)?.app || "this project"
}?`}
description="This action is irreversible."
onOpenChange={(isOpen) => handlePopUpToggle("deleteConfirmation", isOpen)}
confirmKey={
((popUp?.deleteConfirmation?.data as TIntegration)?.integration ===
"azure-app-configuration" &&
(popUp?.deleteConfirmation?.data as TIntegration)?.app
?.split("//")[1]
?.split(".")[0]) ||
(popUp?.deleteConfirmation?.data as TIntegration)?.app ||
(popUp?.deleteConfirmation?.data as TIntegration)?.owner ||
(popUp?.deleteConfirmation?.data as TIntegration)?.path ||
(popUp?.deleteConfirmation?.data as TIntegration)?.integration ||
""
}
onConfirm={async () => {
if (shouldDeleteSecrets) {
handlePopUpOpen("deleteSecretsConfirmation");
return;
}
await handleIntegrationDelete(
(popUp.deleteConfirmation.data as TIntegration).id,
false,
() => handlePopUpClose("deleteConfirmation")
);
}}
>
{(popUp?.deleteConfirmation?.data as TIntegration)?.integration === "github" && (
<Field orientation="horizontal">
<Checkbox
id="delete-integration-secrets"
variant="danger"
isChecked={shouldDeleteSecrets}
onCheckedChange={() => setShouldDeleteSecrets.toggle()}
/>
<FieldLabel htmlFor="delete-integration-secrets">
Delete previously synced secrets from the destination
</FieldLabel>
</Field>
)}
</ConfirmationAlertDialog>
<ConfirmationAlertDialog
isOpen={popUp.deleteSecretsConfirmation.isOpen}
title={`Are you sure you also want to delete secrets on ${
(popUp?.deleteConfirmation.data as TIntegration)?.integration
}?`}
description="By confirming, you acknowledge that all secrets managed by this integration will be removed from the destination. This action is irreversible."
onOpenChange={(isOpen) => handlePopUpToggle("deleteSecretsConfirmation", isOpen)}
confirmKey="confirm"
onConfirm={async () => {
await handleIntegrationDelete(
(popUp.deleteConfirmation.data as TIntegration).id,
true,
() => {
handlePopUpClose("deleteSecretsConfirmation");
handlePopUpClose("deleteConfirmation");
}
);
}}
/>
</>
);
};