mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-02 04:50:38 +08:00
feat: add no found with no events are present (#1874)
* chore: not found component is updated * feat: no events handling is updated Co-authored-by: Ankit Nayan <ankit@signoz.io>
This commit is contained in:
parent
d1d2829d2b
commit
092c02762f
1
frontend/src/components/NotFound/constant.ts
Normal file
1
frontend/src/components/NotFound/constant.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export const defaultText = 'Ah, seems like we reached a dead end!';
|
@ -2,45 +2,52 @@ import getLocalStorageKey from 'api/browser/localstorage/get';
|
|||||||
import NotFoundImage from 'assets/NotFound';
|
import NotFoundImage from 'assets/NotFound';
|
||||||
import { LOCALSTORAGE } from 'constants/localStorage';
|
import { LOCALSTORAGE } from 'constants/localStorage';
|
||||||
import ROUTES from 'constants/routes';
|
import ROUTES from 'constants/routes';
|
||||||
import React from 'react';
|
import React, { useCallback } from 'react';
|
||||||
import { useDispatch } from 'react-redux';
|
import { useDispatch } from 'react-redux';
|
||||||
import { Dispatch } from 'redux';
|
import { Dispatch } from 'redux';
|
||||||
import AppActions from 'types/actions';
|
import AppActions from 'types/actions';
|
||||||
import { LOGGED_IN } from 'types/actions/app';
|
import { LOGGED_IN } from 'types/actions/app';
|
||||||
|
|
||||||
|
import { defaultText } from './constant';
|
||||||
import { Button, Container, Text, TextContainer } from './styles';
|
import { Button, Container, Text, TextContainer } from './styles';
|
||||||
|
|
||||||
function NotFound(): JSX.Element {
|
function NotFound({ text = defaultText }: Props): JSX.Element {
|
||||||
const dispatch = useDispatch<Dispatch<AppActions>>();
|
const dispatch = useDispatch<Dispatch<AppActions>>();
|
||||||
const isLoggedIn = getLocalStorageKey(LOCALSTORAGE.IS_LOGGED_IN);
|
const isLoggedIn = getLocalStorageKey(LOCALSTORAGE.IS_LOGGED_IN);
|
||||||
|
|
||||||
|
const onClickHandler = useCallback(() => {
|
||||||
|
if (isLoggedIn) {
|
||||||
|
dispatch({
|
||||||
|
type: LOGGED_IN,
|
||||||
|
payload: {
|
||||||
|
isLoggedIn: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [dispatch, isLoggedIn]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
<NotFoundImage />
|
<NotFoundImage />
|
||||||
|
|
||||||
<TextContainer>
|
<TextContainer>
|
||||||
<Text>Ah, seems like we reached a dead end!</Text>
|
<Text>{text}</Text>
|
||||||
<Text>Page Not Found</Text>
|
<Text>Page Not Found</Text>
|
||||||
</TextContainer>
|
</TextContainer>
|
||||||
|
|
||||||
<Button
|
<Button onClick={onClickHandler} to={ROUTES.APPLICATION} tabIndex={0}>
|
||||||
onClick={(): void => {
|
|
||||||
if (isLoggedIn) {
|
|
||||||
dispatch({
|
|
||||||
type: LOGGED_IN,
|
|
||||||
payload: {
|
|
||||||
isLoggedIn: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
to={ROUTES.APPLICATION}
|
|
||||||
tabIndex={0}
|
|
||||||
>
|
|
||||||
Return To Services Page
|
Return To Services Page
|
||||||
</Button>
|
</Button>
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
text?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
NotFound.defaultProps = {
|
||||||
|
text: defaultText,
|
||||||
|
};
|
||||||
|
|
||||||
export default NotFound;
|
export default NotFound;
|
||||||
|
@ -1 +1,4 @@
|
|||||||
export const SPAN_DETAILS_LEFT_COL_WIDTH = 350;
|
export const SPAN_DETAILS_LEFT_COL_WIDTH = 350;
|
||||||
|
|
||||||
|
export const noEventMessage =
|
||||||
|
'The requested trace id was not found. Sometimes this happens because of insertion delay in trace data. Please try again after some time';
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { Typography } from 'antd';
|
import { Typography } from 'antd';
|
||||||
import getTraceItem from 'api/trace/getTraceItem';
|
import getTraceItem from 'api/trace/getTraceItem';
|
||||||
|
import NotFound from 'components/NotFound';
|
||||||
import Spinner from 'components/Spinner';
|
import Spinner from 'components/Spinner';
|
||||||
import TraceDetailContainer from 'container/TraceDetail';
|
import TraceDetailContainer from 'container/TraceDetail';
|
||||||
import useUrlQuery from 'hooks/useUrlQuery';
|
import useUrlQuery from 'hooks/useUrlQuery';
|
||||||
@ -8,6 +9,8 @@ import { useQuery } from 'react-query';
|
|||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { Props as TraceDetailProps } from 'types/api/trace/getTraceItem';
|
import { Props as TraceDetailProps } from 'types/api/trace/getTraceItem';
|
||||||
|
|
||||||
|
import { noEventMessage } from './constants';
|
||||||
|
|
||||||
function TraceDetail(): JSX.Element {
|
function TraceDetail(): JSX.Element {
|
||||||
const { id } = useParams<TraceDetailProps>();
|
const { id } = useParams<TraceDetailProps>();
|
||||||
const urlQuery = useUrlQuery();
|
const urlQuery = useUrlQuery();
|
||||||
@ -19,6 +22,7 @@ function TraceDetail(): JSX.Element {
|
|||||||
}),
|
}),
|
||||||
[urlQuery],
|
[urlQuery],
|
||||||
);
|
);
|
||||||
|
|
||||||
const { data: traceDetailResponse, error, isLoading, isError } = useQuery(
|
const { data: traceDetailResponse, error, isLoading, isError } = useQuery(
|
||||||
`getTraceItem/${id}`,
|
`getTraceItem/${id}`,
|
||||||
() => getTraceItem({ id, spanId, levelUp, levelDown }),
|
() => getTraceItem({ id, spanId, levelUp, levelDown }),
|
||||||
@ -39,6 +43,10 @@ function TraceDetail(): JSX.Element {
|
|||||||
return <Spinner tip="Loading.." />;
|
return <Spinner tip="Loading.." />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (traceDetailResponse.payload[0].events.length === 0) {
|
||||||
|
return <NotFound text={noEventMessage} />;
|
||||||
|
}
|
||||||
|
|
||||||
return <TraceDetailContainer response={traceDetailResponse.payload} />;
|
return <TraceDetailContainer response={traceDetailResponse.payload} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user