import React from 'react' ; import { i18n } from '@kbn/i18n' ; import { EuiLink , EuiText , EuiToolTip } from '@elastic/eui' ; import { EnrichedDeprecationInfo } from '../../../../common/types' ; import { DEPRECATION_TYPE_MAP } from '../constants' ; import { DeprecationTableColumns } from '../types' ; import { DeprecationBadge } from '../shared' ; interface Props { resolutionTableCell ? : React . ReactNode ; fieldName : DeprecationTableColumns ; deprecation : EnrichedDeprecationInfo ; openFlyout : ( ) => void ; } const i18nTexts = { manualCellLabel : i18n . translate ( 'xpack.upgradeAssistant.esDeprecations.defaultDeprecation.manualCellLabel' , { defaultMessage : 'Manual' , } ) , manualCellTooltipLabel : i18n . translate ( 'xpack.upgradeAssistant.esDeprecations.reindex.manualCellTooltipLabel' , { defaultMessage : 'This issue needs to be resolved manually.' , } ) , } ; export const EsDeprecationsTableCells = ( { resolutionTableCell , fieldName , deprecation , openFlyout , } ) => { if ( fieldName === 'isCritical' ) { return < DeprecationBadge isCritical = { deprecation . isCritical } />; } if ( fieldName === 'message' ) { return ( < EuiLink data - test - subj = { `deprecation-${ deprecation . correctiveAction ?. type ?? 'default' }` } onClick = { openFlyout } > { deprecation . message } < /EuiLink>); } if ( fieldName === 'type' ) { return < > { DEPRECATION_TYPE_MAP [ deprecation . type as EnrichedDeprecationInfo [ 'type' ] ] } < />; } if ( fieldName === 'correctiveAction' ) { if ( resolutionTableCell ) { return < > { resolutionTableCell } < />; } return ( < EuiToolTip position = "top" content = { i18nTexts . manualCellTooltipLabel } > < EuiText size = "s" color = "subdued" > { i18nTexts . manualCellLabel } < /EuiText> < /EuiToolTip>); } return < > { deprecation [ fieldName ] ?? '' } < />; } ;