import React from 'react' ; import { i18n } from '@kbn/i18n' ; import { getMappedNonEcsValue } from './render_cell_value' ; import FilterForValueButton from './filter_for_value' ; import { TimelineNonEcsData } from '../../../../../timelines/common/search_strategy' ; import { TGridCellAction } from '../../../../../timelines/common/types/timeline' ; import { getPageRowIndex } from '../../../../../timelines/public' ; export const FILTER_FOR_VALUE = i18n . translate ( 'xpack.observability.hoverActions.filterForValue' , { defaultMessage : 'Filter for value' , } ) ; /** actions for adding filters to the search bar */ const buildFilterCellActions = ( addToQuery ) : TGridCellAction [ ] => [ ( { data , pageSize } ) => ( { rowIndex , columnId , Component } ) => { const value = getMappedNonEcsValue ( { data : data [ getPageRowIndex ( rowIndex , pageSize ) ] , fieldName : columnId , } ) ; return ( < FilterForValueButton Component = { Component } field = { columnId } value = { value } addToQuery = { addToQuery } / > ) ; } , ] ; /** returns the default actions shown in `EuiDataGrid` cells */ export const getDefaultCellActions = ( { addToQuery } ) => buildFilterCellActions ( addToQuery ) ;