mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-20 01:09:06 +08:00
feat: add expand/collapse button to the top in trace details (#5980)
* feat: add expand/collapse button to the top in trace details * fix: make the trace details collapsed sidebar match the design * fix: failing test by modifying the expand button class name
This commit is contained in:
parent
1411ae41c3
commit
266ed58908
@ -232,19 +232,16 @@ function AppLayout(props: AppLayoutProps): JSX.Element {
|
|||||||
const isDashboardListView = (): boolean => routeKey === 'ALL_DASHBOARD';
|
const isDashboardListView = (): boolean => routeKey === 'ALL_DASHBOARD';
|
||||||
const isAlertHistory = (): boolean => routeKey === 'ALERT_HISTORY';
|
const isAlertHistory = (): boolean => routeKey === 'ALERT_HISTORY';
|
||||||
const isAlertOverview = (): boolean => routeKey === 'ALERT_OVERVIEW';
|
const isAlertOverview = (): boolean => routeKey === 'ALERT_OVERVIEW';
|
||||||
const isDashboardView = (): boolean => {
|
const isPathMatch = (regex: RegExp): boolean => regex.test(pathname);
|
||||||
/**
|
|
||||||
* need to match using regex here as the getRoute function will not work for
|
|
||||||
* routes with id
|
|
||||||
*/
|
|
||||||
const regex = /^\/dashboard\/[a-zA-Z0-9_-]+$/;
|
|
||||||
return regex.test(pathname);
|
|
||||||
};
|
|
||||||
|
|
||||||
const isDashboardWidgetView = (): boolean => {
|
const isDashboardView = (): boolean =>
|
||||||
const regex = /^\/dashboard\/[a-zA-Z0-9_-]+\/new$/;
|
isPathMatch(/^\/dashboard\/[a-zA-Z0-9_-]+$/);
|
||||||
return regex.test(pathname);
|
|
||||||
};
|
const isDashboardWidgetView = (): boolean =>
|
||||||
|
isPathMatch(/^\/dashboard\/[a-zA-Z0-9_-]+\/new$/);
|
||||||
|
|
||||||
|
const isTraceDetailsView = (): boolean =>
|
||||||
|
isPathMatch(/^\/trace\/[a-zA-Z0-9]+(\?.*)?$/);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isDarkMode) {
|
if (isDarkMode) {
|
||||||
@ -304,6 +301,8 @@ function AppLayout(props: AppLayoutProps): JSX.Element {
|
|||||||
isMessagingQueues()
|
isMessagingQueues()
|
||||||
? 0
|
? 0
|
||||||
: '0 1rem',
|
: '0 1rem',
|
||||||
|
|
||||||
|
...(isTraceDetailsView() ? { marginRight: 0 } : {}),
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{isToDisplayLayout && !renderFullScreen && <TopNav />}
|
{isToDisplayLayout && !renderFullScreen && <TopNav />}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Button, Modal, Tabs, Tooltip, Typography } from 'antd';
|
import { Button, Modal, Row, Tabs, Tooltip, Typography } from 'antd';
|
||||||
import Editor from 'components/Editor';
|
import Editor from 'components/Editor';
|
||||||
import { StyledSpace } from 'components/Styled';
|
import { StyledSpace } from 'components/Styled';
|
||||||
import { QueryParams } from 'constants/query';
|
import { QueryParams } from 'constants/query';
|
||||||
@ -6,7 +6,8 @@ import ROUTES from 'constants/routes';
|
|||||||
import { useIsDarkMode } from 'hooks/useDarkMode';
|
import { useIsDarkMode } from 'hooks/useDarkMode';
|
||||||
import createQueryParams from 'lib/createQueryParams';
|
import createQueryParams from 'lib/createQueryParams';
|
||||||
import history from 'lib/history';
|
import history from 'lib/history';
|
||||||
import { useState } from 'react';
|
import { PanelRight } from 'lucide-react';
|
||||||
|
import { Dispatch, SetStateAction, useState } from 'react';
|
||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { AppState } from 'store/reducers';
|
import { AppState } from 'store/reducers';
|
||||||
@ -28,6 +29,7 @@ function SelectedSpanDetails(props: SelectedSpanDetailsProps): JSX.Element {
|
|||||||
firstSpanStartTime,
|
firstSpanStartTime,
|
||||||
traceStartTime = minTime,
|
traceStartTime = minTime,
|
||||||
traceEndTime = maxTime,
|
traceEndTime = maxTime,
|
||||||
|
setCollapsed,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const { id: traceId } = useParams<Params>();
|
const { id: traceId } = useParams<Params>();
|
||||||
@ -96,14 +98,14 @@ function SelectedSpanDetails(props: SelectedSpanDetailsProps): JSX.Element {
|
|||||||
styledclass={[styles.selectedSpanDetailsContainer, styles.overflow]}
|
styledclass={[styles.selectedSpanDetailsContainer, styles.overflow]}
|
||||||
direction="vertical"
|
direction="vertical"
|
||||||
>
|
>
|
||||||
<Typography.Text
|
<Row align="middle" justify="space-between">
|
||||||
strong
|
<Typography.Text strong>Details for selected Span</Typography.Text>
|
||||||
style={{
|
<Button
|
||||||
marginTop: '16px',
|
className="periscope-btn nav-item-label expand-collapse-btn"
|
||||||
}}
|
icon={<PanelRight size={16} />}
|
||||||
>
|
onClick={(): void => setCollapsed((prev) => !prev)}
|
||||||
Details for selected Span
|
/>
|
||||||
</Typography.Text>
|
</Row>
|
||||||
|
|
||||||
<Typography.Text style={{ fontWeight: 700 }}>Service</Typography.Text>
|
<Typography.Text style={{ fontWeight: 700 }}>Service</Typography.Text>
|
||||||
|
|
||||||
@ -170,6 +172,7 @@ interface SelectedSpanDetailsProps {
|
|||||||
firstSpanStartTime: number;
|
firstSpanStartTime: number;
|
||||||
traceStartTime?: number;
|
traceStartTime?: number;
|
||||||
traceEndTime?: number;
|
traceEndTime?: number;
|
||||||
|
setCollapsed: Dispatch<SetStateAction<boolean>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectedSpanDetails.defaultProps = {
|
SelectedSpanDetails.defaultProps = {
|
||||||
|
@ -20,4 +20,10 @@
|
|||||||
background-color: white !important;
|
background-color: white !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.expand-collapse-btn {
|
||||||
|
padding: 4px;
|
||||||
|
height: auto;
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import useUrlQuery from 'hooks/useUrlQuery';
|
|||||||
import { spanServiceNameToColorMapping } from 'lib/getRandomColor';
|
import { spanServiceNameToColorMapping } from 'lib/getRandomColor';
|
||||||
import history from 'lib/history';
|
import history from 'lib/history';
|
||||||
import { map } from 'lodash-es';
|
import { map } from 'lodash-es';
|
||||||
|
import { PanelRight } from 'lucide-react';
|
||||||
import { SPAN_DETAILS_LEFT_COL_WIDTH } from 'pages/TraceDetail/constants';
|
import { SPAN_DETAILS_LEFT_COL_WIDTH } from 'pages/TraceDetail/constants';
|
||||||
import { useEffect, useMemo, useState } from 'react';
|
import { useEffect, useMemo, useState } from 'react';
|
||||||
import { ITraceForest, PayloadProps } from 'types/api/trace/getTraceItem';
|
import { ITraceForest, PayloadProps } from 'types/api/trace/getTraceItem';
|
||||||
@ -267,14 +268,21 @@ function TraceDetail({ response }: TraceDetailProps): JSX.Element {
|
|||||||
collapsed={collapsed}
|
collapsed={collapsed}
|
||||||
reverseArrow
|
reverseArrow
|
||||||
width={300}
|
width={300}
|
||||||
collapsedWidth={40}
|
collapsedWidth={48}
|
||||||
defaultCollapsed
|
defaultCollapsed
|
||||||
onCollapse={(value): void => setCollapsed(value)}
|
trigger={null}
|
||||||
data-testid="span-details-sider"
|
data-testid="span-details-sider"
|
||||||
>
|
>
|
||||||
{!collapsed && (
|
|
||||||
<StyledCol styledclass={[styles.selectedSpanDetailContainer]}>
|
<StyledCol styledclass={[styles.selectedSpanDetailContainer]}>
|
||||||
|
{collapsed ? (
|
||||||
|
<Button
|
||||||
|
className="periscope-btn nav-item-label expand-collapse-btn"
|
||||||
|
icon={<PanelRight size={16} />}
|
||||||
|
onClick={(): void => setCollapsed((prev) => !prev)}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
<SelectedSpanDetails
|
<SelectedSpanDetails
|
||||||
|
setCollapsed={setCollapsed}
|
||||||
firstSpanStartTime={firstSpanStartTime}
|
firstSpanStartTime={firstSpanStartTime}
|
||||||
traceStartTime={traceStartTime}
|
traceStartTime={traceStartTime}
|
||||||
traceEndTime={traceEndTime}
|
traceEndTime={traceEndTime}
|
||||||
@ -287,8 +295,8 @@ function TraceDetail({ response }: TraceDetailProps): JSX.Element {
|
|||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.find((tree) => tree)}
|
.find((tree) => tree)}
|
||||||
/>
|
/>
|
||||||
</StyledCol>
|
|
||||||
)}
|
)}
|
||||||
|
</StyledCol>
|
||||||
</Sider>
|
</Sider>
|
||||||
</StyledRow>
|
</StyledRow>
|
||||||
);
|
);
|
||||||
|
@ -59,6 +59,8 @@ export const selectedSpanDetailContainer = css`
|
|||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
padding-top: 12px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -139,9 +139,7 @@ describe('TraceDetail', () => {
|
|||||||
const slider = await findByTestId('span-details-sider');
|
const slider = await findByTestId('span-details-sider');
|
||||||
expect(slider).toBeInTheDocument();
|
expect(slider).toBeInTheDocument();
|
||||||
|
|
||||||
fireEvent.click(
|
fireEvent.click(slider.querySelector('.expand-collapse-btn') as HTMLElement);
|
||||||
slider.querySelector('.ant-layout-sider-trigger') as HTMLElement,
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(queryByText('Details for selected Span')).not.toBeInTheDocument();
|
expect(queryByText('Details for selected Span')).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user