import { useState } from 'react'; import { createPortal } from 'react-dom'; import { Terminal } from 'lucide-react'; import clsx from 'clsx'; import { EnvironmentId } from '@/react/portainer/environments/types'; import { useAnalytics } from '@/react/hooks/useAnalytics'; import { Button } from '@@/buttons'; import { useSidebarState } from '../../useSidebarState'; import { SidebarTooltip } from '../../SidebarItem/SidebarTooltip'; import { KubeCtlShell } from './KubectlShell'; interface Props { environmentId: EnvironmentId; } export function KubectlShellButton({ environmentId }: Props) { const { isOpen: isSidebarOpen } = useSidebarState(); const [open, setOpen] = useState(false); const { trackEvent } = useAnalytics(); const button = ( ); return ( <> {!isSidebarOpen && ( Kubectl Shell } > {button} )} {isSidebarOpen && button} {open && createPortal( setOpen(false)} />, document.body )} ); function handleOpen() { setOpen(true); trackEvent('kubernetes-kubectl-shell', { category: 'kubernetes' }); } }