diff --git a/public/components/common/search/date_picker.tsx b/public/components/common/search/date_picker.tsx index d00fe4198..d8632b8ba 100644 --- a/public/components/common/search/date_picker.tsx +++ b/public/components/common/search/date_picker.tsx @@ -21,7 +21,6 @@ export function DatePicker(props: IDatePickerProps) { handleTimePickerChange, handleTimeRangePickerRefresh, isAppAnalytics, - includesTimestamp, } = props; const handleTimeChange = (e: any) => handleTimePickerChange([e.start, e.end]); @@ -31,27 +30,19 @@ export function DatePicker(props: IDatePickerProps) { let setDisabled; let toolTipMessage; - switch (true) { - case coreRefs.queryAssistEnabled && !isAppAnalytics: // is query assistant inside log explorer - setStartTime = QUERY_ASSIST_START_TIME; - setEndTime = QUERY_ASSIST_END_TIME; - setDisabled = true; - toolTipMessage = i18n.translate('discover.queryAssistant.timePickerDisabledMessage', { - defaultMessage: 'Date range has been disabled to accomodate timerange of all datasets', - }); - break; - case !includesTimestamp: // there is no timestamp - setStartTime = 'now'; - setDisabled = true; - toolTipMessage = i18n.translate('discover.events.timePickerNotFoundMessage', { - defaultMessage: 'There is no timestamp found in the index', - }); - break; - default: - setStartTime = startTime; - setEndTime = endTime; - setDisabled = false; - toolTipMessage = false; + if (coreRefs.queryAssistEnabled && !isAppAnalytics) { + // is query assistant inside log explorer + setStartTime = QUERY_ASSIST_START_TIME; + setEndTime = QUERY_ASSIST_END_TIME; + setDisabled = true; + toolTipMessage = i18n.translate('discover.queryAssistant.timePickerDisabledMessage', { + defaultMessage: 'Date range has been disabled to accomodate timerange of all datasets', + }); + } else { + setStartTime = startTime; + setEndTime = endTime; + setDisabled = false; + toolTipMessage = false; } return ( diff --git a/public/components/common/search/search.tsx b/public/components/common/search/search.tsx index 1e80fd5f1..1fff9b1c2 100644 --- a/public/components/common/search/search.tsx +++ b/public/components/common/search/search.tsx @@ -45,7 +45,7 @@ import { resetSummary, selectQueryAssistantSummarization, } from '../../event_analytics/redux/slices/query_assistant_summarization_slice'; -import { reset } from '../../event_analytics/redux/slices/query_result_slice'; +import { reset, selectQueryResult } from '../../event_analytics/redux/slices/query_result_slice'; import { changeData, changeQuery, @@ -78,7 +78,6 @@ export interface IDatePickerProps { handleTimePickerChange: (timeRange: string[]) => any; handleTimeRangePickerRefresh: () => any; isAppAnalytics: boolean; - includesTimestamp: boolean; } export const Search = (props: any) => { @@ -124,6 +123,7 @@ export const Search = (props: any) => { } = props; const queryRedux = useSelector(selectQueries)[tabId]; + const queryResults = useSelector(selectQueryResult)[tabId]; const queryAssistantSummarization = useSelector(selectQueryAssistantSummarization)[tabId]; const dispatch = useDispatch(); const appLogEvents = tabId.match(APP_ANALYTICS_TAB_ID_REGEX); @@ -410,34 +410,35 @@ export const Search = (props: any) => { )} - - {!isLiveTailOn && ( - { - // modifies run button to look like the update button, if there is a time change, disables timepicker setting update if timepicker is disabled - setNeedsUpdate( - !showQueryArea && // keeps statement false if using query assistant ui, timepicker shouldn't change run button - !(tRange[0] === startTime && tRange[1] === endTime) // checks to see if the time given is different from prev - ); - // keeps the time range change local, to be used when update pressed - setStartTime(tRange[0]); - setEndTime(tRange[1]); - }} - handleTimeRangePickerRefresh={() => { - onQuerySearch(queryLang); - }} - isAppAnalytics={isAppAnalytics} - includesTimestamp={queryRedux.selectedTimestamp !== ''} - /> - )} - + {!(queryRedux.selectedTimestamp === '' && queryResults?.datarows) && ( // index with no timestamp, dont show timepicker + + {!isLiveTailOn && ( + { + // modifies run button to look like the update button, if there is a time change, disables timepicker setting update if timepicker is disabled + setNeedsUpdate( + !showQueryArea && // keeps statement false if using query assistant ui, timepicker shouldn't change run button + !(tRange[0] === startTime && tRange[1] === endTime) // checks to see if the time given is different from prev + ); + // keeps the time range change local, to be used when update pressed + setStartTime(tRange[0]); + setEndTime(tRange[1]); + }} + handleTimeRangePickerRefresh={() => { + onQuerySearch(queryLang); + }} + isAppAnalytics={isAppAnalytics} + /> + )} + + )} {!showQueryArea && (