import { FC, useMemo, useRef } from 'react'; import Divider from '../Divider'; import FlexBox from '../FlexBox'; import List, { ListForwardedRefContent } from '../List'; import MessageBox from '../MessageBox'; import { ExpandablePanel } from '../Panels'; import { BodyText } from '../Text'; import useProtect from '../../hooks/useProtect'; import useProtectedState from '../../hooks/useProtectedState'; type ChangedSSHKeys = { [hostUUID: string]: { hostName: string; hostUUID: string; ipAddress: string; isChecked?: boolean; }; }; const ManageChangedSSHKeysForm: FC = () => { const { protect } = useProtect(); const listRef = useRef({}); const [changedSSHKeys, setChangedSSHKeys] = useProtectedState( {}, protect, ); const isAllowCheckAll = useMemo( () => Object.keys(changedSSHKeys).length > 1, [changedSSHKeys], ); return ( Manage changed SSH keys}> The identity of the following targets have unexpectedly changed. If you haven't rebuilt the listed targets, then you could be experiencing a "Man In The Middle" attack. Please verify the targets have changed for a known reason before proceeding to remove the broken keys. :not(:last-child)': { display: { xs: 'none', sm: 'flex' }, }, '& > :last-child': { display: { xs: 'initial', sm: 'none' }, marginLeft: 0, }, }} > Host name IP address } allowCheckAll={isAllowCheckAll} allowCheckItem allowDelete allowEdit={false} edit listEmpty={ No conflicting keys found. } listItems={changedSSHKeys} onAllCheckboxChange={(event, isChecked) => { Object.keys(changedSSHKeys).forEach((key) => { changedSSHKeys[key].isChecked = isChecked; }); setChangedSSHKeys((previous) => ({ ...previous })); }} onItemCheckboxChange={(key, event, isChecked) => { changedSSHKeys[key].isChecked = isChecked; listRef.current.setCheckAll?.call( null, Object.values(changedSSHKeys).every( ({ isChecked: isItemChecked }) => isItemChecked, ), ); setChangedSSHKeys((previous) => ({ ...previous })); }} renderListItem={(hostUUID, { hostName, ipAddress }) => ( *': { flexBasis: '50%' } }} xs="column" > {hostName} {ipAddress} )} renderListItemCheckboxState={(key, { isChecked }) => isChecked === true } ref={listRef} /> ); }; export default ManageChangedSSHKeysForm;