@@ -2,6 +2,7 @@ import {useCallback} from 'react';
2
2
import styled from '@emotion/styled' ;
3
3
4
4
import { Button } from 'sentry/components/core/button' ;
5
+ import { OurlogsDrawer } from 'sentry/components/events/ourlogs/ourlogsDrawer' ;
5
6
import useDrawer from 'sentry/components/globalDrawer' ;
6
7
import { IconChevron } from 'sentry/icons' ;
7
8
import { t } from 'sentry/locale' ;
@@ -14,36 +15,53 @@ import {LogsAnalyticsPageSource} from 'sentry/utils/analytics/logsAnalyticsEvent
14
15
import useOrganization from 'sentry/utils/useOrganization' ;
15
16
import {
16
17
LogsPageParamsProvider ,
17
- type LogsPageParamsProviderProps ,
18
+ useLogsSearch ,
18
19
} from 'sentry/views/explore/contexts/logs/logsPageParams' ;
19
20
import { TraceItemAttributeProvider } from 'sentry/views/explore/contexts/traceItemAttributeContext' ;
20
- import { LogsIssueDrawer } from 'sentry/views/explore/logs/logsIssueDrawer' ;
21
21
import { LogsTable } from 'sentry/views/explore/logs/logsTable' ;
22
- import {
23
- useExploreLogsTable ,
24
- type UseExploreLogsTableResult ,
25
- } from 'sentry/views/explore/logs/useLogsQuery' ;
22
+ import { useExploreLogsTable } from 'sentry/views/explore/logs/useLogsQuery' ;
26
23
import { TraceItemDataset } from 'sentry/views/explore/types' ;
27
24
import { SectionKey } from 'sentry/views/issueDetails/streamline/context' ;
28
25
import { InterimSection } from 'sentry/views/issueDetails/streamline/interimSection' ;
29
26
30
- export function LogsIssuesSection ( {
31
- initialCollapse,
32
- limitToTraceId,
27
+ export function OurlogsSection ( {
33
28
event,
34
29
project,
35
30
group,
36
31
} : {
37
32
event : Event ;
38
33
group : Group ;
39
- initialCollapse : boolean ;
40
34
project : Project ;
41
- } & Omit < LogsPageParamsProviderProps , 'children' | 'analyticsPageSource' > ) {
35
+ } ) {
36
+ return (
37
+ < LogsPageParamsProvider
38
+ analyticsPageSource = { LogsAnalyticsPageSource . ISSUE_DETAILS }
39
+ isTableFrozen
40
+ blockRowExpanding
41
+ limitToTraceId = { event . contexts ?. trace ?. trace_id }
42
+ >
43
+ < OurlogsSectionContent event = { event } group = { group } project = { project } />
44
+ </ LogsPageParamsProvider >
45
+ ) ;
46
+ }
47
+
48
+ function OurlogsSectionContent ( {
49
+ event,
50
+ project,
51
+ group,
52
+ } : {
53
+ event : Event ;
54
+ group : Group ;
55
+ project : Project ;
56
+ } ) {
42
57
const organization = useOrganization ( ) ;
43
58
const feature = organization . features . includes ( 'ourlogs-enabled' ) ;
44
59
const tableData = useExploreLogsTable ( { enabled : feature , limit : 10 } ) ;
60
+ const logsSearch = useLogsSearch ( ) ;
61
+ const abbreviatedTableData = { ...tableData , data : ( tableData . data ?? [ ] ) . slice ( 0 , 5 ) } ;
45
62
const { openDrawer} = useDrawer ( ) ;
46
63
64
+ const limitToTraceId = event . contexts ?. trace ?. trace_id ;
47
65
const onOpenLogsDrawer = useCallback ( ( ) => {
48
66
trackAnalytics ( 'logs.issue_details.drawer_opened' , {
49
67
organization,
@@ -56,7 +74,7 @@ export function LogsIssuesSection({
56
74
limitToTraceId = { limitToTraceId }
57
75
>
58
76
< TraceItemAttributeProvider traceItemType = { TraceItemDataset . LOGS } enabled >
59
- < LogsIssueDrawer group = { group } event = { event } project = { project } />
77
+ < OurlogsDrawer group = { group } event = { event } project = { project } />
60
78
</ TraceItemAttributeProvider >
61
79
</ LogsPageParamsProvider >
62
80
) ,
@@ -73,7 +91,7 @@ export function LogsIssuesSection({
73
91
// We may change this in the future if we have a trace-group or we generate trace sids for these issue types.
74
92
return null ;
75
93
}
76
- if ( tableData ? .data ?. length === 0 ) {
94
+ if ( ! tableData || ( tableData . data ?. length === 0 && logsSearch . isEmpty ( ) ) ) {
77
95
// Like breadcrumbs, we don't show the logs section if there are no logs.
78
96
return null ;
79
97
}
@@ -83,53 +101,40 @@ export function LogsIssuesSection({
83
101
type = { SectionKey . LOGS }
84
102
title = { t ( 'Logs' ) }
85
103
data-test-id = "logs-data-section"
86
- initialCollapse = { initialCollapse }
87
104
>
88
- < LogsPageParamsProvider
89
- analyticsPageSource = { LogsAnalyticsPageSource . ISSUE_DETAILS }
90
- isTableFrozen
91
- blockRowExpanding
92
- limitToTraceId = { limitToTraceId }
93
- >
94
- < LogsSectionContent tableData = { tableData } openDrawer = { onOpenLogsDrawer } />
95
- </ LogsPageParamsProvider >
105
+ < LogContentWrapper onClick = { ( ) => onOpenLogsDrawer ( ) } >
106
+ < LogsTable
107
+ showHeader = { false }
108
+ allowPagination = { false }
109
+ tableData = { abbreviatedTableData }
110
+ />
111
+ { tableData . data ?. length > 5 ? (
112
+ < div >
113
+ < Button
114
+ icon = { < IconChevron direction = "right" /> }
115
+ aria-label = { t ( 'View more' ) }
116
+ size = "md"
117
+ onClick = { ( ) => onOpenLogsDrawer ( ) }
118
+ >
119
+ { t ( 'View more' ) }
120
+ </ Button >
121
+ </ div >
122
+ ) : null }
123
+ </ LogContentWrapper >
96
124
</ InterimSection >
97
125
) ;
98
126
}
99
127
100
- function LogsSectionContent ( {
101
- tableData,
102
- openDrawer,
103
- } : {
104
- openDrawer : ( ) => void ;
105
- tableData : UseExploreLogsTableResult ;
106
- } ) {
107
- const abbreviatedTableData = { ...tableData , data : ( tableData . data ?? [ ] ) . slice ( 0 , 5 ) } ;
108
- return (
109
- < LogContentWrapper >
110
- < LogsTable
111
- showHeader = { false }
112
- allowPagination = { false }
113
- tableData = { abbreviatedTableData }
114
- />
115
- { tableData . data ?. length > 5 ? (
116
- < div >
117
- < Button
118
- icon = { < IconChevron direction = "right" /> }
119
- aria-label = { t ( 'View more' ) }
120
- size = "md"
121
- onClick = { ( ) => openDrawer ( ) }
122
- >
123
- { t ( 'View more' ) }
124
- </ Button >
125
- </ div >
126
- ) : null }
127
- </ LogContentWrapper >
128
- ) ;
129
- }
130
-
131
- const LogContentWrapper = styled ( 'div' ) `
128
+ const LogContentWrapper = styled ( 'button' ) `
129
+ all: unset;
132
130
display: flex;
133
131
flex-direction: column;
134
132
gap: ${ space ( 1 ) } ;
133
+ pointer-events: auto;
134
+ cursor: pointer;
135
+
136
+ * {
137
+ pointer-events: none !important;
138
+ cursor: inherit !important;
139
+ }
135
140
` ;
0 commit comments