import { Helmet } from "react-helmet"; import { useTranslation } from "react-i18next"; import { faRefresh, faTrash } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { useNavigate, useParams } from "@tanstack/react-router"; import { twMerge } from "tailwind-merge"; import { createNotification } from "@app/components/notifications"; import { OrgPermissionCan } from "@app/components/permissions"; import { Button, Checkbox, DeleteActionModal, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, EmptyState, PageHeader, Tooltip } from "@app/components/v2"; import { ROUTE_PATHS } from "@app/const/routes"; import { OrgPermissionActions, OrgPermissionSubjects, useProject } from "@app/context"; import { usePopUp, useToggle } from "@app/hooks"; import { useGetIntegration } from "@app/hooks/api"; import { useDeleteIntegration, useSyncIntegration } from "@app/hooks/api/integrations/queries"; import { ProjectType } from "@app/hooks/api/projects/types"; import { IntegrationAuditLogsSection } from "./components/IntegrationAuditLogsSection"; import { IntegrationConnectionSection } from "./components/IntegrationConnectionSection"; import { IntegrationDetailsSection } from "./components/IntegrationDetailsSection"; import { IntegrationSettingsSection } from "./components/IntegrationSettingsSection"; import { integrationSlugNameMapping } from "./IntegrationsDetailsByIDPage.utils"; export const IntegrationDetailsByIDPage = () => { const { t } = useTranslation(); const integrationId = useParams({ from: ROUTE_PATHS.SecretManager.IntegrationDetailsByIDPage.id, select: (el) => el.integrationId }); const { data: integration } = useGetIntegration(integrationId, { refetchInterval: 4000 }); const [shouldDeleteSecrets, setShouldDeleteSecrets] = useToggle(false); const { currentProject } = useProject(); const projectId = currentProject.id; const { mutateAsync: syncIntegration } = useSyncIntegration(); const { mutateAsync: deleteIntegration } = useDeleteIntegration(); const navigate = useNavigate(); const handleIntegrationDelete = async (shouldDeleteIntegrationSecrets: boolean) => { try { await deleteIntegration({ id: integrationId, workspaceId: currentProject.id, shouldDeleteIntegrationSecrets }); createNotification({ type: "success", text: "Deleted integration" }); await navigate({ to: `/${ProjectType.SecretManager}/${projectId}/integrations` }); } catch (err) { console.log(err); createNotification({ type: "error", text: "Failed to delete integration" }); } }; const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([ "deleteConfirmation", "deleteSecretsConfirmation" ] as const); return ( <> Integration Details | Infisical
{integration ? (
{ await syncIntegration({ id: integration.id, lastUsed: integration.lastUsed!, workspaceId: projectId! }); }} >
Manually Sync
{(isAllowed) => ( { setShouldDeleteSecrets.off(); handlePopUpOpen("deleteConfirmation", integration); }} disabled={!isAllowed} >
Delete Integration
)}
) : (
)}
handlePopUpToggle("deleteConfirmation", isOpen)} deleteKey={ (integration?.integration === "azure-app-configuration" && integration?.app?.split("//")[1]?.split(".")[0]) || integration?.app || integration?.owner || integration?.path || integration?.integration || "" } onDeleteApproved={async () => { if (shouldDeleteSecrets) { handlePopUpOpen("deleteSecretsConfirmation"); return; } await handleIntegrationDelete(false); handlePopUpClose("deleteConfirmation"); }} > {integration?.integration === "github" && (
setShouldDeleteSecrets.toggle()} > Delete previously synced secrets from the destination
)}
handlePopUpToggle("deleteSecretsConfirmation", isOpen)} deleteKey="confirm" onDeleteApproved={async () => { await handleIntegrationDelete(true); handlePopUpClose("deleteSecretsConfirmation"); handlePopUpClose("deleteConfirmation"); }} /> ); };