From 5d6eea304571011ebc11ae6fbe8d988ccc5c6d82 Mon Sep 17 00:00:00 2001 From: Palash Gupta Date: Mon, 20 Nov 2023 11:30:49 +0530 Subject: [PATCH] feat: copy to clipboard start and end time added (#3995) --- frontend/src/hooks/logs/useCopyLogLink.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/frontend/src/hooks/logs/useCopyLogLink.ts b/frontend/src/hooks/logs/useCopyLogLink.ts index 81c768618f..8401b6433f 100644 --- a/frontend/src/hooks/logs/useCopyLogLink.ts +++ b/frontend/src/hooks/logs/useCopyLogLink.ts @@ -10,8 +10,11 @@ import { useMemo, useState, } from 'react'; +import { useSelector } from 'react-redux'; import { useLocation } from 'react-router-dom'; import { useCopyToClipboard } from 'react-use'; +import { AppState } from 'store/reducers'; +import { GlobalReducer } from 'types/reducer/globalTime'; import { HIGHLIGHTED_DELAY } from './configs'; import { LogTimeRange, UseCopyLogLink } from './types'; @@ -21,6 +24,9 @@ export const useCopyLogLink = (logId?: string): UseCopyLogLink => { const { pathname } = useLocation(); const [, setCopy] = useCopyToClipboard(); const { notifications } = useNotifications(); + const { maxTime, minTime } = useSelector( + (state) => state.globalTime, + ); const { queryData: timeRange, @@ -52,6 +58,8 @@ export const useCopyLogLink = (logId?: string): UseCopyLogLink => { urlQuery.delete(QueryParams.timeRange); urlQuery.set(QueryParams.activeLogId, `"${logId}"`); urlQuery.set(QueryParams.timeRange, range); + urlQuery.set(QueryParams.startTime, minTime.toString()); + urlQuery.set(QueryParams.endTime, maxTime.toString()); const link = `${window.location.origin}${pathname}?${urlQuery.toString()}`; @@ -60,7 +68,16 @@ export const useCopyLogLink = (logId?: string): UseCopyLogLink => { message: 'Copied to clipboard', }); }, - [logId, notifications, timeRange, urlQuery, pathname, setCopy], + [ + logId, + timeRange, + urlQuery, + minTime, + maxTime, + pathname, + setCopy, + notifications, + ], ); useEffect(() => {