import { useCallback } from "react"; import { subject } from "@casl/ability"; import { faAsterisk, faBuilding, faCheck, faCopy, faEdit, faEllipsisV, faInfoCircle, faTable, faTrash } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { Link } from "@tanstack/react-router"; import { ServerIcon } from "lucide-react"; import { twMerge } from "tailwind-merge"; import { createNotification } from "@app/components/notifications"; import { VariablePermissionCan } from "@app/components/permissions"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, IconButton, Td, Tooltip, Tr } from "@app/components/v2"; import { Badge } from "@app/components/v3"; import { OrgPermissionSubjects, ProjectPermissionSub } from "@app/context"; import { OrgPermissionAppConnectionActions } from "@app/context/OrgPermissionContext/types"; import { ProjectPermissionAppConnectionActions } from "@app/context/ProjectPermissionContext/types"; import { APP_CONNECTION_MAP, getAppConnectionMethodDetails } from "@app/helpers/appConnections"; import { getProjectBaseURL } from "@app/helpers/project"; import { useToggle } from "@app/hooks"; import { TAppConnection } from "@app/hooks/api/appConnections"; type Props = { appConnection: TAppConnection; onDelete: (appConnection: TAppConnection) => void; onEditCredentials: (appConnection: TAppConnection) => void; onEditDetails: (appConnection: TAppConnection) => void; isProjectView: boolean; }; export const AppConnectionRow = ({ appConnection, onDelete, onEditCredentials, onEditDetails, isProjectView }: Props) => { const { id, name, method, app, description, isPlatformManagedCredentials, project } = appConnection; const [isIdCopied, setIsIdCopied] = useToggle(false); const handleCopyId = useCallback(() => { setIsIdCopied.on(); navigator.clipboard.writeText(id); createNotification({ text: "Connection ID copied to clipboard", type: "info" }); const timer = setTimeout(() => setIsIdCopied.off(), 2000); // eslint-disable-next-line consistent-return return () => clearTimeout(timer); }, [isIdCopied]); const methodDetails = getAppConnectionMethodDetails(method); const connectionDetails = APP_CONNECTION_MAP[app]; return (
{name}
{description && (