Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add expand/collapse button to the top in trace details #5980

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions frontend/src/container/AppLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,19 +255,16 @@ function AppLayout(props: AppLayoutProps): JSX.Element {
const isDashboardListView = (): boolean => routeKey === 'ALL_DASHBOARD';
const isAlertHistory = (): boolean => routeKey === 'ALERT_HISTORY';
const isAlertOverview = (): boolean => routeKey === 'ALERT_OVERVIEW';
const isDashboardView = (): boolean => {
/**
* 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 isPathMatch = (regex: RegExp): boolean => regex.test(pathname);

const isDashboardWidgetView = (): boolean => {
const regex = /^\/dashboard\/[a-zA-Z0-9_-]+\/new$/;
return regex.test(pathname);
};
const isDashboardView = (): boolean =>
isPathMatch(/^\/dashboard\/[a-zA-Z0-9_-]+$/);

const isDashboardWidgetView = (): boolean =>
isPathMatch(/^\/dashboard\/[a-zA-Z0-9_-]+\/new$/);

const isTraceDetailsView = (): boolean =>
isPathMatch(/^\/trace\/[a-zA-Z0-9]+(\?.*)?$/);

useEffect(() => {
if (isDarkMode) {
Expand Down Expand Up @@ -356,6 +353,8 @@ function AppLayout(props: AppLayoutProps): JSX.Element {
isMessagingQueues()
? 0
: '0 1rem',

...(isTraceDetailsView() ? { marginRight: 0 } : {}),
}}
>
{isToDisplayLayout && !renderFullScreen && <TopNav />}
Expand Down
23 changes: 13 additions & 10 deletions frontend/src/container/TraceDetail/SelectedSpanDetails/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Button, Modal, Tabs, Tooltip, Typography } from 'antd';
import { Button, Modal, Row, Tabs, Tooltip, Typography } from 'antd';
import Editor from 'components/Editor';
import { StyledSpace } from 'components/Styled';
import { QueryParams } from 'constants/query';
import ROUTES from 'constants/routes';
import { useIsDarkMode } from 'hooks/useDarkMode';
import createQueryParams from 'lib/createQueryParams';
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 { useParams } from 'react-router-dom';
import { AppState } from 'store/reducers';
Expand All @@ -28,6 +29,7 @@ function SelectedSpanDetails(props: SelectedSpanDetailsProps): JSX.Element {
firstSpanStartTime,
traceStartTime = minTime,
traceEndTime = maxTime,
setCollapsed,
} = props;

const { id: traceId } = useParams<Params>();
Expand Down Expand Up @@ -96,14 +98,14 @@ function SelectedSpanDetails(props: SelectedSpanDetailsProps): JSX.Element {
styledclass={[styles.selectedSpanDetailsContainer, styles.overflow]}
direction="vertical"
>
<Typography.Text
strong
style={{
marginTop: '16px',
}}
>
Details for selected Span
</Typography.Text>
<Row align="middle" justify="space-between">
<Typography.Text strong>Details for selected Span</Typography.Text>
<Button
className="periscope-btn nav-item-label expand-collapse-btn"
icon={<PanelRight size={16} />}
onClick={(): void => setCollapsed((prev) => !prev)}
/>
</Row>

<Typography.Text style={{ fontWeight: 700 }}>Service</Typography.Text>

Expand Down Expand Up @@ -170,6 +172,7 @@ interface SelectedSpanDetailsProps {
firstSpanStartTime: number;
traceStartTime?: number;
traceEndTime?: number;
setCollapsed: Dispatch<SetStateAction<boolean>>;
}

SelectedSpanDetails.defaultProps = {
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/container/TraceDetail/TraceDetails.styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,10 @@
background-color: white !important;
}
}

.expand-collapse-btn {
padding: 4px;
height: auto;
width: auto;
}
}
20 changes: 14 additions & 6 deletions frontend/src/container/TraceDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import useUrlQuery from 'hooks/useUrlQuery';
import { spanServiceNameToColorMapping } from 'lib/getRandomColor';
import history from 'lib/history';
import { map } from 'lodash-es';
import { PanelRight } from 'lucide-react';
import { SPAN_DETAILS_LEFT_COL_WIDTH } from 'pages/TraceDetail/constants';
import { useEffect, useMemo, useState } from 'react';
import { ITraceForest, PayloadProps } from 'types/api/trace/getTraceItem';
Expand Down Expand Up @@ -267,14 +268,21 @@ function TraceDetail({ response }: TraceDetailProps): JSX.Element {
collapsed={collapsed}
reverseArrow
width={300}
collapsedWidth={40}
collapsedWidth={48}
defaultCollapsed
onCollapse={(value): void => setCollapsed(value)}
trigger={null}
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
setCollapsed={setCollapsed}
firstSpanStartTime={firstSpanStartTime}
traceStartTime={traceStartTime}
traceEndTime={traceEndTime}
Expand All @@ -287,8 +295,8 @@ function TraceDetail({ response }: TraceDetailProps): JSX.Element {
.filter(Boolean)
.find((tree) => tree)}
/>
</StyledCol>
)}
)}
</StyledCol>
</Sider>
</StyledRow>
);
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/container/TraceDetail/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ export const selectedSpanDetailContainer = css`
position: relative;
display: flex;
flex-direction: column;
align-items: center;
padding-top: 12px;
`;

/**
Expand Down
Loading