1
- import { useCallback } from 'react' ;
1
+ import { useCallback , useRef } from 'react' ;
2
2
import styled from '@emotion/styled' ;
3
3
4
4
import { Button } from 'sentry/components/core/button' ;
5
5
import { OurlogsDrawer } from 'sentry/components/events/ourlogs/ourlogsDrawer' ;
6
6
import useDrawer from 'sentry/components/globalDrawer' ;
7
7
import { IconChevron } from 'sentry/icons' ;
8
8
import { t } from 'sentry/locale' ;
9
- import { space } from 'sentry/styles/space' ;
10
9
import type { Event } from 'sentry/types/event' ;
11
10
import type { Group } from 'sentry/types/group' ;
12
11
import type { Project } from 'sentry/types/project' ;
13
12
import { trackAnalytics } from 'sentry/utils/analytics' ;
14
13
import { LogsAnalyticsPageSource } from 'sentry/utils/analytics/logsAnalyticsEvent' ;
15
14
import useOrganization from 'sentry/utils/useOrganization' ;
15
+ import { TableBody } from 'sentry/views/explore/components/table' ;
16
16
import {
17
17
LogsPageParamsProvider ,
18
18
useLogsSearch ,
19
19
} from 'sentry/views/explore/contexts/logs/logsPageParams' ;
20
20
import { TraceItemAttributeProvider } from 'sentry/views/explore/contexts/traceItemAttributeContext' ;
21
- import { LogsTable } from 'sentry/views/explore/logs/logsTable ' ;
21
+ import { LogRowContent } from 'sentry/views/explore/logs/logsTableRow ' ;
22
22
import { useExploreLogsTable } from 'sentry/views/explore/logs/useLogsQuery' ;
23
23
import { TraceItemDataset } from 'sentry/views/explore/types' ;
24
24
import { SectionKey } from 'sentry/views/issueDetails/streamline/context' ;
@@ -58,8 +58,10 @@ function OurlogsSectionContent({
58
58
const feature = organization . features . includes ( 'ourlogs-enabled' ) ;
59
59
const tableData = useExploreLogsTable ( { enabled : feature , limit : 10 } ) ;
60
60
const logsSearch = useLogsSearch ( ) ;
61
- const abbreviatedTableData = { ... tableData , data : ( tableData . data ?? [ ] ) . slice ( 0 , 5 ) } ;
61
+ const abbreviatedTableData = ( tableData . data ?? [ ] ) . slice ( 0 , 5 ) ;
62
62
const { openDrawer} = useDrawer ( ) ;
63
+ const logsTableRef = useRef < HTMLButtonElement > ( null ) ;
64
+ const sharedHoverTimeoutRef = useRef < NodeJS . Timeout | null > ( null ) ;
63
65
64
66
const limitToTraceId = event . contexts ?. trace ?. trace_id ;
65
67
const onOpenLogsDrawer = useCallback ( ( ) => {
@@ -81,6 +83,14 @@ function OurlogsSectionContent({
81
83
{
82
84
ariaLabel : 'logs drawer' ,
83
85
drawerKey : 'logs-issue-drawer' ,
86
+
87
+ shouldCloseOnInteractOutside : element => {
88
+ const viewAllButton = logsTableRef . current ;
89
+ if ( viewAllButton ?. contains ( element ) ) {
90
+ return false ;
91
+ }
92
+ return true ;
93
+ } ,
84
94
}
85
95
) ;
86
96
} , [ group , event , project , openDrawer , organization , limitToTraceId ] ) ;
@@ -103,39 +113,44 @@ function OurlogsSectionContent({
103
113
title = { t ( 'Logs' ) }
104
114
data-test-id = "logs-data-section"
105
115
>
106
- < LogContentWrapper onClick = { ( ) => onOpenLogsDrawer ( ) } >
107
- < LogsTable
108
- showHeader = { false }
109
- allowPagination = { false }
110
- tableData = { abbreviatedTableData }
111
- />
116
+ < SmallTableContentWrapper ref = { logsTableRef } onClick = { ( ) => onOpenLogsDrawer ( ) } >
117
+ < SmallTable >
118
+ < TableBody >
119
+ { abbreviatedTableData ?. map ( ( row , index ) => (
120
+ < LogRowContent
121
+ dataRow = { row }
122
+ meta = { tableData . meta }
123
+ highlightTerms = { [ ] }
124
+ sharedHoverTimeoutRef = { sharedHoverTimeoutRef }
125
+ key = { index }
126
+ />
127
+ ) ) }
128
+ </ TableBody >
129
+ </ SmallTable >
112
130
{ tableData . data ?. length > 5 ? (
113
131
< div >
114
132
< Button
115
133
icon = { < IconChevron direction = "right" /> }
116
134
aria-label = { t ( 'View more' ) }
117
- size = "md "
135
+ size = "sm "
118
136
onClick = { ( ) => onOpenLogsDrawer ( ) }
119
137
>
120
138
{ t ( 'View more' ) }
121
139
</ Button >
122
140
</ div >
123
141
) : null }
124
- </ LogContentWrapper >
142
+ </ SmallTableContentWrapper >
125
143
</ InterimSection >
126
144
) ;
127
145
}
128
146
129
- const LogContentWrapper = styled ( 'button' ) `
147
+ const SmallTable = styled ( 'table' ) `
148
+ display: grid;
149
+ grid-template-columns: 15px auto 1fr;
150
+ ` ;
151
+
152
+ const SmallTableContentWrapper = styled ( 'button' ) `
130
153
all: unset;
131
154
display: flex;
132
155
flex-direction: column;
133
- gap: ${ space ( 1 ) } ;
134
- pointer-events: auto;
135
- cursor: pointer;
136
-
137
- * {
138
- pointer-events: none !important;
139
- cursor: inherit !important;
140
- }
141
156
` ;
0 commit comments