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

[Bug fix] Trace analytics scroll bar reset #1917

Merged
merged 3 commits into from
Jun 20, 2024
Merged
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
} from '@elastic/eui';
import debounce from 'lodash/debounce';
import isEmpty from 'lodash/isEmpty';
import React, { useEffect, useMemo, useState } from 'react';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { HttpSetup } from '../../../../../../../src/core/public';
import { Plt } from '../../../visualizations/plotly/plot';
import { TraceAnalyticsMode } from '../../home';
Expand All @@ -27,22 +27,22 @@
export function SpanDetailPanel(props: {
http: HttpSetup;
traceId: string;
colorMap: any;

Check warning on line 30 in public/components/trace_analytics/components/traces/span_detail_panel.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
mode: TraceAnalyticsMode;
dataSourceMDSId: string;
page?: string;
openSpanFlyout?: any;

Check warning on line 34 in public/components/trace_analytics/components/traces/span_detail_panel.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
data?: { gantt: any[]; table: any[]; ganttMaxX: number };

Check warning on line 35 in public/components/trace_analytics/components/traces/span_detail_panel.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type

Check warning on line 35 in public/components/trace_analytics/components/traces/span_detail_panel.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
setData?: (data: { gantt: any[]; table: any[]; ganttMaxX: number }) => void;

Check warning on line 36 in public/components/trace_analytics/components/traces/span_detail_panel.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type

Check warning on line 36 in public/components/trace_analytics/components/traces/span_detail_panel.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
}) {
const { mode } = props;
const storedFilters = sessionStorage.getItem('TraceAnalyticsSpanFilters');
const fromApp = props.page === 'app';
const [spanFilters, setSpanFilters] = useState<Array<{ field: string; value: any }>>(

Check warning on line 41 in public/components/trace_analytics/components/traces/span_detail_panel.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
storedFilters ? JSON.parse(storedFilters) : []
);
const [DSL, setDSL] = useState<any>({});

Check warning on line 44 in public/components/trace_analytics/components/traces/span_detail_panel.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
let data: { gantt: any[]; table: any[]; ganttMaxX: number };

Check warning on line 45 in public/components/trace_analytics/components/traces/span_detail_panel.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type

Check warning on line 45 in public/components/trace_analytics/components/traces/span_detail_panel.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
let setData: (data: { gantt: any[]; table: any[]; ganttMaxX: number }) => void;
const [localData, localSetData] = useState<{ gantt: any[]; table: any[]; ganttMaxX: number }>({
gantt: [],
Expand Down Expand Up @@ -187,15 +187,18 @@

const [currentSpan, setCurrentSpan] = useState('');

const onClick = (event: any) => {
if (!event?.points) return;
const point = event.points[0];
if (fromApp) {
props.openSpanFlyout(point.data.spanId);
} else {
setCurrentSpan(point.data.spanId);
}
};
const onClick = useCallback(
(event: any) => {
if (!event?.points) return;
const point = event.points[0];
if (fromApp) {
props.openSpanFlyout(point.data.spanId);
} else {
setCurrentSpan(point.data.spanId);
}
},
[props.openSpanFlyout, setCurrentSpan, fromApp]
);

const renderFilters = useMemo(() => {
return spanFilters.map(({ field, value }) => (
Expand All @@ -212,15 +215,15 @@
));
}, [spanFilters]);

const onHover = () => {
const onHover = useCallback(() => {
const dragLayer = document.getElementsByClassName('nsewdrag')?.[0];
dragLayer.style.cursor = 'pointer';
};
}, []);

const onUnhover = () => {
const onUnhover = useCallback(() => {
const dragLayer = document.getElementsByClassName('nsewdrag')?.[0];
dragLayer.style.cursor = '';
};
}, []);

const toggleOptions = [
{
Expand Down Expand Up @@ -254,6 +257,19 @@
[DSL, setCurrentSpan]
);

const ganttChart = useMemo(
() => (
<Plt
data={data.gantt}
layout={layout}
onClickHandler={onClick}
onHoverHandler={onHover}
onUnhoverHandler={onUnhover}
/>
),
[data.gantt, layout, onClick, onHover, onUnhover]
);

return (
<>
<EuiPanel data-test-subj="span-gantt-chart-panel">
Expand All @@ -280,17 +296,7 @@
)}
<EuiHorizontalRule margin="m" />
<div style={{ overflowY: 'auto', maxHeight: 500 }}>
{toggleIdSelected === 'timeline' ? (
<Plt
data={data.gantt}
layout={layout}
onClickHandler={onClick}
onHoverHandler={onHover}
onUnhoverHandler={onUnhover}
/>
) : (
spanDetailTable
)}
{toggleIdSelected === 'timeline' ? ganttChart : spanDetailTable}
</div>
</EuiPanel>
{!!currentSpan && (
Expand Down
Loading