1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-20 13:59:40 +02:00
portainer/app/react/sidebar/KubernetesSidebar/KubectlShell/KubectlShellButton.tsx
Ali d78b762f7b
refactor(icons): replace fa icons [EE-4459] (#7907)
refactor(icons): remove fontawesome EE-4459

refactor(icon) replace feather with lucide EE-4472
2022-11-28 15:00:28 +13:00

51 lines
1.3 KiB
TypeScript

import clsx from 'clsx';
import { useState } from 'react';
import { createPortal } from 'react-dom';
import { Terminal } from 'lucide-react';
import { EnvironmentId } from '@/react/portainer/environments/types';
import { useAnalytics } from '@/angulartics.matomo/analytics-services';
import { Button } from '@@/buttons';
import { Icon } from '@@/Icon';
import { KubeCtlShell } from './KubectlShell';
import styles from './KubectlShellButton.module.css';
interface Props {
environmentId: EnvironmentId;
}
export function KubectlShellButton({ environmentId }: Props) {
const [open, setOpen] = useState(false);
const { trackEvent } = useAnalytics();
return (
<>
<Button
color="primary"
size="small"
disabled={open}
data-cy="k8sSidebar-shellButton"
onClick={() => handleOpen()}
className={clsx(styles.root, '!flex')}
>
<Icon icon={Terminal} className="vertical-center" size="md" /> kubectl
shell
</Button>
{open &&
createPortal(
<KubeCtlShell
environmentId={environmentId}
onClose={() => setOpen(false)}
/>,
document.body
)}
</>
);
function handleOpen() {
setOpen(true);
trackEvent('kubernetes-kubectl-shell', { category: 'kubernetes' });
}
}