import { isEmpty, values } from 'ramda'; import { DropdownItem, DropdownMenu, DropdownToggle, UncontrolledDropdown } from 'reactstrap'; import { Link } from 'react-router-dom'; import { faPlus as plusIcon, faFileDownload as exportIcon, faServer as serverIcon } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import ServersExporter from './services/ServersExporter'; import { isServerWithId, SelectedServer, ServersMap } from './data'; export interface ServersDropdownProps { servers: ServersMap; selectedServer: SelectedServer; } const ServersDropdown = (serversExporter: ServersExporter) => ({ servers, selectedServer }: ServersDropdownProps) => { const serversList = values(servers); const createServerItem = ( Add server ); const renderServers = () => { if (isEmpty(serversList)) { return createServerItem; } return ( <> {serversList.map(({ name, id }) => ( {name} ))} {createServerItem} serversExporter.exportServers()}> Export servers ); }; return ( Servers {renderServers()} ); }; export default ServersDropdown;