1
- import { useCallback , useEffect , useMemo , useRef , useState } from 'react' ;
1
+ import { useCallback } from 'react' ;
2
2
import styled from '@emotion/styled' ;
3
3
4
4
import Feature from 'sentry/components/acl/feature' ;
5
5
import EventTagsTree from 'sentry/components/events/eventTags/eventTagsTree' ;
6
- import { IconGrabbable } from 'sentry/icons' ;
7
6
import { t } from 'sentry/locale' ;
8
7
import { space } from 'sentry/styles/space' ;
9
8
import type { EventTransaction } from 'sentry/types/event' ;
@@ -14,90 +13,13 @@ import {FoldSection} from 'sentry/views/issueDetails/streamline/foldSection';
14
13
import { TraceContextVitals } from 'sentry/views/performance/newTraceDetails/traceContextVitals' ;
15
14
import type { TraceTree } from 'sentry/views/performance/newTraceDetails/traceModels/traceTree' ;
16
15
import { TraceViewLogsSection } from 'sentry/views/performance/newTraceDetails/traceOurlogs' ;
17
- import {
18
- DEFAULT_TRACE_VIEW_PREFERENCES ,
19
- loadTraceViewPreferences ,
20
- } from 'sentry/views/performance/newTraceDetails/traceState/tracePreferences' ;
21
- import { useTraceStateDispatch } from 'sentry/views/performance/newTraceDetails/traceState/traceStateProvider' ;
22
-
23
- const MIN_HEIGHT = 0 ;
24
- const DEFAULT_HEIGHT = 150 ;
25
- const MAX_HEIGHT = 700 ;
26
16
27
17
type Props = {
28
18
rootEvent : UseApiQueryResult < EventTransaction , RequestError > ;
29
19
tree : TraceTree ;
30
20
} ;
31
21
32
22
export function TraceContextPanel ( { tree, rootEvent} : Props ) {
33
- const [ height , setHeight ] = useState ( DEFAULT_HEIGHT ) ;
34
- const containerRef = useRef < HTMLDivElement > ( null ) ;
35
- const traceDispatch = useTraceStateDispatch ( ) ;
36
-
37
- const preferences = useMemo (
38
- ( ) =>
39
- loadTraceViewPreferences ( 'trace-view-preferences' ) ||
40
- DEFAULT_TRACE_VIEW_PREFERENCES ,
41
- [ ]
42
- ) ;
43
-
44
- useEffect ( ( ) => {
45
- const loadedHeight = preferences . drawer . sizes [ 'trace context height' ] ;
46
-
47
- if ( containerRef . current && loadedHeight !== undefined ) {
48
- setHeight ( loadedHeight ) ;
49
- containerRef . current . style . setProperty ( '--panel-height' , `${ loadedHeight } px` ) ;
50
- }
51
- } , [ preferences . drawer . sizes , containerRef ] ) ;
52
-
53
- const handleMouseDown = useCallback (
54
- ( event : React . MouseEvent ) => {
55
- event . preventDefault ( ) ;
56
-
57
- if ( ! containerRef . current ) {
58
- return ;
59
- }
60
-
61
- const startY = event . clientY ;
62
- const startHeight = height ;
63
-
64
- function handleMouseMove ( moveEvent : MouseEvent ) {
65
- if ( ! containerRef . current ) {
66
- return ;
67
- }
68
-
69
- const deltaY = moveEvent . clientY - startY ;
70
- const newHeight = Math . max (
71
- MIN_HEIGHT ,
72
- Math . min ( startHeight - deltaY , MAX_HEIGHT )
73
- ) ;
74
-
75
- containerRef . current . style . setProperty ( '--panel-height' , `${ newHeight } px` ) ;
76
- }
77
-
78
- function handleMouseUp ( ) {
79
- if ( ! containerRef . current ) {
80
- return ;
81
- }
82
-
83
- const finalHeight = parseInt (
84
- getComputedStyle ( containerRef . current ) . getPropertyValue ( '--panel-height' ) ,
85
- 10
86
- ) ;
87
-
88
- setHeight ( finalHeight ) ;
89
- traceDispatch ( { type : 'set trace context height' , payload : finalHeight } ) ;
90
-
91
- window . removeEventListener ( 'mousemove' , handleMouseMove ) ;
92
- window . removeEventListener ( 'mouseup' , handleMouseUp ) ;
93
- }
94
-
95
- window . addEventListener ( 'mousemove' , handleMouseMove ) ;
96
- window . addEventListener ( 'mouseup' , handleMouseUp ) ;
97
- } ,
98
- [ height , traceDispatch ]
99
- ) ;
100
-
101
23
const renderTags = useCallback ( ( ) => {
102
24
if ( ! rootEvent . data ) {
103
25
return null ;
@@ -115,25 +37,19 @@ export function TraceContextPanel({tree, rootEvent}: Props) {
115
37
116
38
return (
117
39
< Container >
118
- < GrabberContainer onMouseDown = { handleMouseDown } >
119
- < IconGrabbable color = "gray500" />
120
- </ GrabberContainer >
121
-
122
- < TraceContextContainer ref = { containerRef } >
123
- < VitalMetersContainer >
124
- < TraceContextVitals tree = { tree } />
125
- </ VitalMetersContainer >
40
+ < VitalMetersContainer >
41
+ < TraceContextVitals tree = { tree } />
42
+ </ VitalMetersContainer >
43
+ < TraceTagsContainer >
44
+ < FoldSection sectionKey = { 'trace_tags' as SectionKey } title = { t ( 'Trace Tags' ) } >
45
+ { renderTags ( ) }
46
+ </ FoldSection >
47
+ </ TraceTagsContainer >
48
+ < Feature features = { [ 'ourlogs-enabled' ] } >
126
49
< TraceTagsContainer >
127
- < FoldSection sectionKey = { 'trace_tags' as SectionKey } title = { t ( 'Trace Tags' ) } >
128
- { renderTags ( ) }
129
- </ FoldSection >
50
+ < TraceViewLogsSection />
130
51
</ TraceTagsContainer >
131
- < Feature features = { [ 'ourlogs-enabled' ] } >
132
- < TraceTagsContainer >
133
- < TraceViewLogsSection />
134
- </ TraceTagsContainer >
135
- </ Feature >
136
- </ TraceContextContainer >
52
+ </ Feature >
137
53
</ Container >
138
54
) ;
139
55
}
@@ -146,35 +62,6 @@ const Container = styled('div')`
146
62
gap: ${ space ( 1 ) } ;
147
63
` ;
148
64
149
- const TraceContextContainer = styled ( 'div' ) `
150
- display: flex;
151
- flex-direction: column;
152
- align-items: center;
153
- width: 100%;
154
- --panel-height: ${ DEFAULT_HEIGHT } px;
155
- height: var(--panel-height);
156
-
157
- &[style*='--panel-height: 0px'] {
158
- display: none;
159
- }
160
- ` ;
161
-
162
- const GrabberContainer = styled ( Container ) `
163
- align-items: center;
164
- background: ${ p => p . theme . background } ;
165
- border: 1px solid ${ p => p . theme . border } ;
166
- border-radius: 0 0 ${ p => p . theme . borderRadius } ${ p => p . theme . borderRadius } ;
167
- display: flex;
168
-
169
- width: 100%;
170
- cursor: row-resize;
171
- padding: ${ space ( 0.5 ) } ;
172
-
173
- & > svg {
174
- transform: rotate(90deg);
175
- }
176
- ` ;
177
-
178
65
const VitalMetersContainer = styled ( 'div' ) `
179
66
display: flex;
180
67
flex-direction: row;
0 commit comments