diff --git a/frontend/src/components/Logs/AddToQueryHOC.tsx b/frontend/src/components/Logs/AddToQueryHOC.tsx index 3978ca5948..ea517fa003 100644 --- a/frontend/src/components/Logs/AddToQueryHOC.tsx +++ b/frontend/src/components/Logs/AddToQueryHOC.tsx @@ -1,46 +1,21 @@ import { Button, Popover } from 'antd'; -import getStep from 'lib/getStep'; import { generateFilterQuery } from 'lib/logs/generateFilterQuery'; import React, { memo, useCallback, useMemo } from 'react'; -import { connect, useDispatch, useSelector } from 'react-redux'; -import { bindActionCreators, Dispatch } from 'redux'; -import { ThunkDispatch } from 'redux-thunk'; -import { getLogs } from 'store/actions/logs/getLogs'; -import { getLogsAggregate } from 'store/actions/logs/getLogsAggregate'; +import { useDispatch, useSelector } from 'react-redux'; import { AppState } from 'store/reducers'; -import AppActions from 'types/actions'; -import { SET_SEARCH_QUERY_STRING, TOGGLE_LIVE_TAIL } from 'types/actions/logs'; -import { GlobalReducer } from 'types/reducer/globalTime'; +import { SET_SEARCH_QUERY_STRING } from 'types/actions/logs'; import { ILogsReducer } from 'types/reducer/logs'; -interface AddToQueryHOCProps { - fieldKey: string; - fieldValue: string; - children: React.ReactNode; - getLogs: (props: Parameters[0]) => ReturnType; - getLogsAggregate: ( - props: Parameters[0], - ) => ReturnType; -} function AddToQueryHOC({ fieldKey, fieldValue, children, - getLogs, - getLogsAggregate, }: AddToQueryHOCProps): JSX.Element { const { searchFilter: { queryString }, - logLinesPerPage, - idStart, - idEnd, - liveTail, } = useSelector((store) => store.logs); const dispatch = useDispatch(); - const { maxTime, minTime } = useSelector( - (state) => state.globalTime, - ); const generatedQuery = useMemo( () => generateFilterQuery({ fieldKey, fieldValue, type: 'IN' }), [fieldKey, fieldValue], @@ -58,69 +33,14 @@ function AddToQueryHOC({ type: SET_SEARCH_QUERY_STRING, payload: updatedQueryString, }); - if (liveTail === 'STOPPED') { - getLogs({ - q: updatedQueryString, - limit: logLinesPerPage, - orderBy: 'timestamp', - order: 'desc', - timestampStart: minTime, - timestampEnd: maxTime, - ...(idStart ? { idGt: idStart } : {}), - ...(idEnd ? { idLt: idEnd } : {}), - }); - getLogsAggregate({ - timestampStart: minTime, - timestampEnd: maxTime, - step: getStep({ - start: minTime, - end: maxTime, - inputFormat: 'ns', - }), - q: updatedQueryString, - ...(idStart ? { idGt: idStart } : {}), - ...(idEnd ? { idLt: idEnd } : {}), - }); - } else if (liveTail === 'PLAYING') { - dispatch({ - type: TOGGLE_LIVE_TAIL, - payload: 'PAUSED', - }); - setTimeout( - () => - dispatch({ - type: TOGGLE_LIVE_TAIL, - payload: liveTail, - }), - 0, - ); - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [ - dispatch, - generatedQuery, - getLogs, - idEnd, - idStart, - logLinesPerPage, - maxTime, - minTime, - queryString, + }, [dispatch, generatedQuery, queryString]); + + const popOverContent = useMemo(() => Add to query: {fieldKey}, [ + fieldKey, ]); - const popOverContent = ( - Add to query: {fieldKey} - ); return ( -