mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-06-04 11:25:52 +08:00
fix: fixed view trace or logs button on graph not disappearing on outside click (#7177)
* fix: fixed view trace or logs button on graph not disappearing on outside click * fix: removed older function
This commit is contained in:
parent
b4a1d72123
commit
fe73ca63a0
@ -8,7 +8,7 @@ import { ViewMenuAction } from 'container/GridCardLayout/config';
|
|||||||
import GridCard from 'container/GridCardLayout/GridCard';
|
import GridCard from 'container/GridCardLayout/GridCard';
|
||||||
import { Card } from 'container/GridCardLayout/styles';
|
import { Card } from 'container/GridCardLayout/styles';
|
||||||
import { Button } from 'container/MetricsApplication/Tabs/styles';
|
import { Button } from 'container/MetricsApplication/Tabs/styles';
|
||||||
import { onGraphClickHandler } from 'container/MetricsApplication/Tabs/util';
|
import { useGraphClickHandler } from 'container/MetricsApplication/Tabs/util';
|
||||||
import { useIsDarkMode } from 'hooks/useDarkMode';
|
import { useIsDarkMode } from 'hooks/useDarkMode';
|
||||||
import useUrlQuery from 'hooks/useUrlQuery';
|
import useUrlQuery from 'hooks/useUrlQuery';
|
||||||
import { OnClickPluginOpts } from 'lib/uPlotLib/plugins/onClickPlugin';
|
import { OnClickPluginOpts } from 'lib/uPlotLib/plugins/onClickPlugin';
|
||||||
@ -122,6 +122,8 @@ function CeleryTaskLatencyGraph({
|
|||||||
setSelectedTimeStamp(selectTime);
|
setSelectedTimeStamp(selectTime);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const onGraphClickHandler = useGraphClickHandler(handleSetTimeStamp);
|
||||||
|
|
||||||
const onGraphClick = useCallback(
|
const onGraphClick = useCallback(
|
||||||
(type: string): OnClickPluginOpts['onClick'] => (
|
(type: string): OnClickPluginOpts['onClick'] => (
|
||||||
xValue,
|
xValue,
|
||||||
@ -137,14 +139,9 @@ function CeleryTaskLatencyGraph({
|
|||||||
value,
|
value,
|
||||||
});
|
});
|
||||||
|
|
||||||
return onGraphClickHandler(handleSetTimeStamp)(
|
return onGraphClickHandler(xValue, yValue, mouseX, mouseY, type);
|
||||||
xValue,
|
|
||||||
yValue,
|
|
||||||
mouseX,
|
|
||||||
mouseY,
|
|
||||||
type,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
[handleSetTimeStamp],
|
[handleSetTimeStamp],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -34,9 +34,9 @@ import { IServiceName } from './types';
|
|||||||
import {
|
import {
|
||||||
dbSystemTags,
|
dbSystemTags,
|
||||||
handleNonInQueryRange,
|
handleNonInQueryRange,
|
||||||
onGraphClickHandler,
|
|
||||||
onViewTracePopupClick,
|
onViewTracePopupClick,
|
||||||
useGetAPMToTracesQueries,
|
useGetAPMToTracesQueries,
|
||||||
|
useGraphClickHandler,
|
||||||
} from './util';
|
} from './util';
|
||||||
|
|
||||||
function DBCall(): JSX.Element {
|
function DBCall(): JSX.Element {
|
||||||
@ -160,6 +160,8 @@ function DBCall(): JSX.Element {
|
|||||||
});
|
});
|
||||||
const { safeNavigate } = useSafeNavigate();
|
const { safeNavigate } = useSafeNavigate();
|
||||||
|
|
||||||
|
const onGraphClickHandler = useGraphClickHandler(setSelectedTimeStamp);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Row gutter={24}>
|
<Row gutter={24}>
|
||||||
<Col span={12}>
|
<Col span={12}>
|
||||||
@ -183,7 +185,7 @@ function DBCall(): JSX.Element {
|
|||||||
<Graph
|
<Graph
|
||||||
widget={databaseCallsRPSWidget}
|
widget={databaseCallsRPSWidget}
|
||||||
onClickHandler={(xValue, yValue, mouseX, mouseY): void => {
|
onClickHandler={(xValue, yValue, mouseX, mouseY): void => {
|
||||||
onGraphClickHandler(setSelectedTimeStamp)(
|
onGraphClickHandler(
|
||||||
xValue,
|
xValue,
|
||||||
yValue,
|
yValue,
|
||||||
mouseX,
|
mouseX,
|
||||||
@ -221,7 +223,7 @@ function DBCall(): JSX.Element {
|
|||||||
widget={databaseCallsAverageDurationWidget}
|
widget={databaseCallsAverageDurationWidget}
|
||||||
headerMenuList={MENU_ITEMS}
|
headerMenuList={MENU_ITEMS}
|
||||||
onClickHandler={(xValue, yValue, mouseX, mouseY): void => {
|
onClickHandler={(xValue, yValue, mouseX, mouseY): void => {
|
||||||
onGraphClickHandler(setSelectedTimeStamp)(
|
onGraphClickHandler(
|
||||||
xValue,
|
xValue,
|
||||||
yValue,
|
yValue,
|
||||||
mouseX,
|
mouseX,
|
||||||
|
@ -35,9 +35,9 @@ import { Button } from './styles';
|
|||||||
import { IServiceName } from './types';
|
import { IServiceName } from './types';
|
||||||
import {
|
import {
|
||||||
handleNonInQueryRange,
|
handleNonInQueryRange,
|
||||||
onGraphClickHandler,
|
|
||||||
onViewTracePopupClick,
|
onViewTracePopupClick,
|
||||||
useGetAPMToTracesQueries,
|
useGetAPMToTracesQueries,
|
||||||
|
useGraphClickHandler,
|
||||||
} from './util';
|
} from './util';
|
||||||
|
|
||||||
function External(): JSX.Element {
|
function External(): JSX.Element {
|
||||||
@ -223,6 +223,8 @@ function External(): JSX.Element {
|
|||||||
|
|
||||||
const { safeNavigate } = useSafeNavigate();
|
const { safeNavigate } = useSafeNavigate();
|
||||||
|
|
||||||
|
const onGraphClickHandler = useGraphClickHandler(setSelectedTimeStamp);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Row gutter={24}>
|
<Row gutter={24}>
|
||||||
@ -248,7 +250,7 @@ function External(): JSX.Element {
|
|||||||
headerMenuList={MENU_ITEMS}
|
headerMenuList={MENU_ITEMS}
|
||||||
widget={externalCallErrorWidget}
|
widget={externalCallErrorWidget}
|
||||||
onClickHandler={(xValue, yValue, mouseX, mouseY): void => {
|
onClickHandler={(xValue, yValue, mouseX, mouseY): void => {
|
||||||
onGraphClickHandler(setSelectedTimeStamp)(
|
onGraphClickHandler(
|
||||||
xValue,
|
xValue,
|
||||||
yValue,
|
yValue,
|
||||||
mouseX,
|
mouseX,
|
||||||
@ -286,7 +288,7 @@ function External(): JSX.Element {
|
|||||||
headerMenuList={MENU_ITEMS}
|
headerMenuList={MENU_ITEMS}
|
||||||
widget={externalCallDurationWidget}
|
widget={externalCallDurationWidget}
|
||||||
onClickHandler={(xValue, yValue, mouseX, mouseY): void => {
|
onClickHandler={(xValue, yValue, mouseX, mouseY): void => {
|
||||||
onGraphClickHandler(setSelectedTimeStamp)(
|
onGraphClickHandler(
|
||||||
xValue,
|
xValue,
|
||||||
yValue,
|
yValue,
|
||||||
mouseX,
|
mouseX,
|
||||||
@ -325,7 +327,7 @@ function External(): JSX.Element {
|
|||||||
widget={externalCallRPSWidget}
|
widget={externalCallRPSWidget}
|
||||||
headerMenuList={MENU_ITEMS}
|
headerMenuList={MENU_ITEMS}
|
||||||
onClickHandler={(xValue, yValue, mouseX, mouseY): Promise<void> =>
|
onClickHandler={(xValue, yValue, mouseX, mouseY): Promise<void> =>
|
||||||
onGraphClickHandler(setSelectedTimeStamp)(
|
onGraphClickHandler(
|
||||||
xValue,
|
xValue,
|
||||||
yValue,
|
yValue,
|
||||||
mouseX,
|
mouseX,
|
||||||
@ -363,7 +365,7 @@ function External(): JSX.Element {
|
|||||||
widget={externalCallDurationAddressWidget}
|
widget={externalCallDurationAddressWidget}
|
||||||
headerMenuList={MENU_ITEMS}
|
headerMenuList={MENU_ITEMS}
|
||||||
onClickHandler={(xValue, yValue, mouseX, mouseY): void => {
|
onClickHandler={(xValue, yValue, mouseX, mouseY): void => {
|
||||||
onGraphClickHandler(setSelectedTimeStamp)(
|
onGraphClickHandler(
|
||||||
xValue,
|
xValue,
|
||||||
yValue,
|
yValue,
|
||||||
mouseX,
|
mouseX,
|
||||||
|
@ -51,10 +51,10 @@ import { IServiceName } from './types';
|
|||||||
import {
|
import {
|
||||||
generateExplorerPath,
|
generateExplorerPath,
|
||||||
handleNonInQueryRange,
|
handleNonInQueryRange,
|
||||||
onGraphClickHandler,
|
|
||||||
onViewTracePopupClick,
|
onViewTracePopupClick,
|
||||||
useGetAPMToLogsQueries,
|
useGetAPMToLogsQueries,
|
||||||
useGetAPMToTracesQueries,
|
useGetAPMToTracesQueries,
|
||||||
|
useGraphClickHandler,
|
||||||
} from './util';
|
} from './util';
|
||||||
|
|
||||||
function Application(): JSX.Element {
|
function Application(): JSX.Element {
|
||||||
@ -79,6 +79,8 @@ function Application(): JSX.Element {
|
|||||||
setSelectedTimeStamp(selectTime);
|
setSelectedTimeStamp(selectTime);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const onGraphClickHandler = useGraphClickHandler(handleSetTimeStamp);
|
||||||
|
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const handleGraphClick = useCallback(
|
const handleGraphClick = useCallback(
|
||||||
(type: string): OnClickPluginOpts['onClick'] => (
|
(type: string): OnClickPluginOpts['onClick'] => (
|
||||||
@ -86,14 +88,8 @@ function Application(): JSX.Element {
|
|||||||
yValue,
|
yValue,
|
||||||
mouseX,
|
mouseX,
|
||||||
mouseY,
|
mouseY,
|
||||||
): Promise<void> =>
|
): Promise<void> => onGraphClickHandler(xValue, yValue, mouseX, mouseY, type),
|
||||||
onGraphClickHandler(handleSetTimeStamp)(
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
xValue,
|
|
||||||
yValue,
|
|
||||||
mouseX,
|
|
||||||
mouseY,
|
|
||||||
type,
|
|
||||||
),
|
|
||||||
[handleSetTimeStamp],
|
[handleSetTimeStamp],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -4,11 +4,12 @@ import ROUTES from 'constants/routes';
|
|||||||
import { routeConfig } from 'container/SideNav/config';
|
import { routeConfig } from 'container/SideNav/config';
|
||||||
import { getQueryString } from 'container/SideNav/helper';
|
import { getQueryString } from 'container/SideNav/helper';
|
||||||
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
||||||
|
import useClickOutside from 'hooks/useClickOutside';
|
||||||
import useResourceAttribute from 'hooks/useResourceAttribute';
|
import useResourceAttribute from 'hooks/useResourceAttribute';
|
||||||
import { resourceAttributesToTracesFilterItems } from 'hooks/useResourceAttribute/utils';
|
import { resourceAttributesToTracesFilterItems } from 'hooks/useResourceAttribute/utils';
|
||||||
import { prepareQueryWithDefaultTimestamp } from 'pages/LogsExplorer/utils';
|
import { prepareQueryWithDefaultTimestamp } from 'pages/LogsExplorer/utils';
|
||||||
import { traceFilterKeys } from 'pages/TracesExplorer/Filter/filterUtils';
|
import { traceFilterKeys } from 'pages/TracesExplorer/Filter/filterUtils';
|
||||||
import { Dispatch, SetStateAction, useMemo } from 'react';
|
import { Dispatch, SetStateAction, useMemo, useRef } from 'react';
|
||||||
import {
|
import {
|
||||||
BaseAutocompleteData,
|
BaseAutocompleteData,
|
||||||
DataTypes,
|
DataTypes,
|
||||||
@ -106,9 +107,27 @@ export function onViewTracePopupClick({
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function onGraphClickHandler(
|
export function useGraphClickHandler(
|
||||||
setSelectedTimeStamp: (n: number) => void | Dispatch<SetStateAction<number>>,
|
setSelectedTimeStamp: (n: number) => void | Dispatch<SetStateAction<number>>,
|
||||||
) {
|
): (
|
||||||
|
xValue: number,
|
||||||
|
yValue: number,
|
||||||
|
mouseX: number,
|
||||||
|
mouseY: number,
|
||||||
|
type: string,
|
||||||
|
) => Promise<void> {
|
||||||
|
const buttonRef = useRef<HTMLElement | null>(null);
|
||||||
|
|
||||||
|
useClickOutside({
|
||||||
|
ref: buttonRef,
|
||||||
|
onClickOutside: () => {
|
||||||
|
if (buttonRef.current) {
|
||||||
|
buttonRef.current.style.display = 'none';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
eventType: 'mousedown',
|
||||||
|
});
|
||||||
|
|
||||||
return async (
|
return async (
|
||||||
xValue: number,
|
xValue: number,
|
||||||
yValue: number,
|
yValue: number,
|
||||||
@ -117,8 +136,8 @@ export function onGraphClickHandler(
|
|||||||
type: string,
|
type: string,
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
const id = `${type}_button`;
|
const id = `${type}_button`;
|
||||||
|
|
||||||
const buttonElement = document.getElementById(id);
|
const buttonElement = document.getElementById(id);
|
||||||
|
buttonRef.current = buttonElement;
|
||||||
|
|
||||||
if (xValue) {
|
if (xValue) {
|
||||||
if (buttonElement) {
|
if (buttonElement) {
|
||||||
|
@ -3,11 +3,13 @@ import { useEffect } from 'react';
|
|||||||
type UseClickOutsideProps = {
|
type UseClickOutsideProps = {
|
||||||
ref: React.RefObject<HTMLElement>;
|
ref: React.RefObject<HTMLElement>;
|
||||||
onClickOutside: () => void;
|
onClickOutside: () => void;
|
||||||
|
eventType?: 'mousedown' | 'mouseup' | 'click' | 'dblclick';
|
||||||
};
|
};
|
||||||
|
|
||||||
const useClickOutside = ({
|
const useClickOutside = ({
|
||||||
ref,
|
ref,
|
||||||
onClickOutside,
|
onClickOutside,
|
||||||
|
eventType,
|
||||||
}: UseClickOutsideProps): void => {
|
}: UseClickOutsideProps): void => {
|
||||||
const handleClickOutside = (event: MouseEvent): void => {
|
const handleClickOutside = (event: MouseEvent): void => {
|
||||||
if (ref.current && !ref.current.contains(event.target as Node)) {
|
if (ref.current && !ref.current.contains(event.target as Node)) {
|
||||||
@ -16,10 +18,10 @@ const useClickOutside = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
document.addEventListener('click', handleClickOutside);
|
document.addEventListener(eventType ?? 'click', handleClickOutside);
|
||||||
|
|
||||||
return (): void => {
|
return (): void => {
|
||||||
document.removeEventListener('click', handleClickOutside);
|
document.removeEventListener(eventType ?? 'click', handleClickOutside);
|
||||||
};
|
};
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [ref, onClickOutside]);
|
}, [ref, onClickOutside]);
|
||||||
|
@ -7,7 +7,7 @@ import { QueryParams } from 'constants/query';
|
|||||||
import { ViewMenuAction } from 'container/GridCardLayout/config';
|
import { ViewMenuAction } from 'container/GridCardLayout/config';
|
||||||
import GridCard from 'container/GridCardLayout/GridCard';
|
import GridCard from 'container/GridCardLayout/GridCard';
|
||||||
import { Button } from 'container/MetricsApplication/Tabs/styles';
|
import { Button } from 'container/MetricsApplication/Tabs/styles';
|
||||||
import { onGraphClickHandler } from 'container/MetricsApplication/Tabs/util';
|
import { useGraphClickHandler } from 'container/MetricsApplication/Tabs/util';
|
||||||
import useUrlQuery from 'hooks/useUrlQuery';
|
import useUrlQuery from 'hooks/useUrlQuery';
|
||||||
import { OnClickPluginOpts } from 'lib/uPlotLib/plugins/onClickPlugin';
|
import { OnClickPluginOpts } from 'lib/uPlotLib/plugins/onClickPlugin';
|
||||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
@ -84,20 +84,16 @@ export default function OverviewRightPanelGraph({
|
|||||||
|
|
||||||
const navigateToTraces = useNavigateToTraces();
|
const navigateToTraces = useNavigateToTraces();
|
||||||
|
|
||||||
|
const onGraphClickHandler = useGraphClickHandler(handleSetTimeStamp);
|
||||||
|
|
||||||
const handleGraphClick = useCallback(
|
const handleGraphClick = useCallback(
|
||||||
(type: string): OnClickPluginOpts['onClick'] => (
|
(type: string): OnClickPluginOpts['onClick'] => (
|
||||||
xValue,
|
xValue,
|
||||||
yValue,
|
yValue,
|
||||||
mouseX,
|
mouseX,
|
||||||
mouseY,
|
mouseY,
|
||||||
): Promise<void> =>
|
): Promise<void> => onGraphClickHandler(xValue, yValue, mouseX, mouseY, type),
|
||||||
onGraphClickHandler(handleSetTimeStamp)(
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
xValue,
|
|
||||||
yValue,
|
|
||||||
mouseX,
|
|
||||||
mouseY,
|
|
||||||
type,
|
|
||||||
),
|
|
||||||
[handleSetTimeStamp],
|
[handleSetTimeStamp],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user