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 (
{ infom.text }
; } else if ( HostInfo.infoIsOrderedList( infom ) ) { return (