import { FC, useState } from 'react'; import CrudList from '../CrudList'; import { DialogScrollBox } from '../Dialog'; import FormSummary from '../FormSummary'; import HostListItem from './HostListItem'; import IconButton from '../IconButton'; import PrepareHostForm from './PrepareHostForm'; import TestAccessForm from './TestAccessForm'; import { BodyText } from '../Text'; const ManageHost: FC = () => { const [inquireHostResponse, setInquireHostResponse] = useState< InquireHostResponse | undefined >(); return ( formDialogProps={{ common: { onClose: ({ handlers: { base } }, ...args) => { base?.call(null, ...args); setInquireHostResponse(undefined); }, }, }} addHeader="Initialize host" editHeader="" entriesUrl="/host?types=dr,node" entryUrlPrefix="/host" getDeleteErrorMessage={(children, ...rest) => ({ ...rest, children: <>Failed to delete host(s). {children}, })} getDeleteHeader={(count) => `Delete the following ${count} host(s)?`} getDeleteSuccessMessage={() => ({ children: <>Successfully deleted host(s), })} listEmpty="No host(s) found" listProps={{ allowAddItem: true, allowEdit: false, // There's no edit mode for host list right now, use the edit dialog to // display the details of a host. allowItemButton: true, }} renderAddForm={(tools) => ( <> {inquireHostResponse && ( )} )} renderDeleteItem={(hosts, { key }) => { const host = hosts?.[key]; return {host?.shortHostName}; }} renderEditForm={(tools, detail) => detail && ( { const { 0: { entry, key }, } = args; if (key === 'command') return ( navigator.clipboard.writeText(String(entry)) } size="small" /> ); return base(...args); }} hasPassword /> ) } renderListItem={(uuid, host) => } /> ); }; export default ManageHost;