feat: copy to clipboard start and end time added (#3995)

This commit is contained in:
Palash Gupta 2023-11-20 11:30:49 +05:30 committed by GitHub
parent 12029a6d90
commit 5d6eea3045
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,8 +10,11 @@ import {
useMemo, useMemo,
useState, useState,
} from 'react'; } from 'react';
import { useSelector } from 'react-redux';
import { useLocation } from 'react-router-dom'; import { useLocation } from 'react-router-dom';
import { useCopyToClipboard } from 'react-use'; import { useCopyToClipboard } from 'react-use';
import { AppState } from 'store/reducers';
import { GlobalReducer } from 'types/reducer/globalTime';
import { HIGHLIGHTED_DELAY } from './configs'; import { HIGHLIGHTED_DELAY } from './configs';
import { LogTimeRange, UseCopyLogLink } from './types'; import { LogTimeRange, UseCopyLogLink } from './types';
@ -21,6 +24,9 @@ export const useCopyLogLink = (logId?: string): UseCopyLogLink => {
const { pathname } = useLocation(); const { pathname } = useLocation();
const [, setCopy] = useCopyToClipboard(); const [, setCopy] = useCopyToClipboard();
const { notifications } = useNotifications(); const { notifications } = useNotifications();
const { maxTime, minTime } = useSelector<AppState, GlobalReducer>(
(state) => state.globalTime,
);
const { const {
queryData: timeRange, queryData: timeRange,
@ -52,6 +58,8 @@ export const useCopyLogLink = (logId?: string): UseCopyLogLink => {
urlQuery.delete(QueryParams.timeRange); urlQuery.delete(QueryParams.timeRange);
urlQuery.set(QueryParams.activeLogId, `"${logId}"`); urlQuery.set(QueryParams.activeLogId, `"${logId}"`);
urlQuery.set(QueryParams.timeRange, range); 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()}`; const link = `${window.location.origin}${pathname}?${urlQuery.toString()}`;
@ -60,7 +68,16 @@ export const useCopyLogLink = (logId?: string): UseCopyLogLink => {
message: 'Copied to clipboard', message: 'Copied to clipboard',
}); });
}, },
[logId, notifications, timeRange, urlQuery, pathname, setCopy], [
logId,
timeRange,
urlQuery,
minTime,
maxTime,
pathname,
setCopy,
notifications,
],
); );
useEffect(() => { useEffect(() => {