import React from 'react'; import { Tabs, Typography } from 'antd'; import { CodeOutlined, WindowsOutlined } from '@ant-design/icons'; import { useStore } from '../../store'; import { SshTab } from './SshTab'; import { RdpTab } from './RdpTab'; import { Session } from '../../types'; function tabLabel(session: Session) { const icon = session.connection.protocol === 'rdp' ? ( ) : ( ); return ( {icon} {session.connection.name} ); } export const SessionTabs: React.FC = () => { const sessions = useStore((s) => s.sessions); const activeSessionId = useStore((s) => s.activeSessionId); const closeSession = useStore((s) => s.closeSession); const setActiveSession = useStore((s) => s.setActiveSession); if (sessions.length === 0) { return (
No open sessions Double-click a connection in the sidebar to start a session.
); } return ( { if (action === 'remove') closeSession(key as string); }} style={{ height: '100%', display: 'flex', flexDirection: 'column' }} tabBarStyle={{ margin: 0, flexShrink: 0 }} items={sessions.map((session) => ({ key: session.id, label: tabLabel(session), closable: true, style: { height: '100%', padding: 0 }, children: (
{session.connection.protocol === 'ssh' ? ( ) : ( )}
), }))} /> ); };