import { FunctionComponent, useEffect } from 'react'; import { useDispatch } from 'calypso/state'; import { recordTracksEvent } from 'calypso/state/analytics/actions'; import * as HostInfo from '../host-info'; interface Props { field: string; host: string; info: HostInfo.Info[] | HostInfo.InfoSplit; protocol: 'ftp' | 'ssh' | 'dynamic-ssh'; } const InlineInfo: FunctionComponent< Props > = ( { field, host, info, protocol } ) => { const dispatch = useDispatch(); const choseSplitInfo = ( splitInfo: HostInfo.InfoSplit ) => protocol === 'ftp' ? splitInfo.ftp : splitInfo.sftp; const infoToRender = HostInfo.infoIsSplit( info ) ? choseSplitInfo( info ) : info; useEffect( () => { dispatch( recordTracksEvent( 'calypso_jetpack_advanced_credentials_flow_inline_info_view', { field, host, protocol, } ) ); }, [ dispatch, field, host, protocol ] ); return (
{ infoToRender.map( ( infom, topLevelIndex ) => { if ( HostInfo.infoIsLink( infom ) ) { return ( { infom.text } ); } else if ( HostInfo.infoIsText( infom ) ) { return

{ infom.text }

; } else if ( HostInfo.infoIsOrderedList( infom ) ) { return (
    { infom.items.map( ( text, index ) => (
  1. { text }
  2. ) ) }
); } else if ( HostInfo.infoIsUnorderedList( infom ) ) { return ( ); } else if ( HostInfo.infoIsLine( infom ) ) { return
; } return null; } ) }
); }; export default InlineInfo;