Skip to content

Commit b736c0b

Browse files
authored
fix(ourlogs): Make the issues section use a "tiny" version of the logs table (#92162)
Fixes LOGS-137
1 parent 9483d4d commit b736c0b

File tree

1 file changed

+36
-21
lines changed

1 file changed

+36
-21
lines changed

static/app/components/events/ourlogs/ourlogsSection.tsx

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
import {useCallback} from 'react';
1+
import {useCallback, useRef} from 'react';
22
import styled from '@emotion/styled';
33

44
import {Button} from 'sentry/components/core/button';
55
import {OurlogsDrawer} from 'sentry/components/events/ourlogs/ourlogsDrawer';
66
import useDrawer from 'sentry/components/globalDrawer';
77
import {IconChevron} from 'sentry/icons';
88
import {t} from 'sentry/locale';
9-
import {space} from 'sentry/styles/space';
109
import type {Event} from 'sentry/types/event';
1110
import type {Group} from 'sentry/types/group';
1211
import type {Project} from 'sentry/types/project';
1312
import {trackAnalytics} from 'sentry/utils/analytics';
1413
import {LogsAnalyticsPageSource} from 'sentry/utils/analytics/logsAnalyticsEvent';
1514
import useOrganization from 'sentry/utils/useOrganization';
15+
import {TableBody} from 'sentry/views/explore/components/table';
1616
import {
1717
LogsPageParamsProvider,
1818
useLogsSearch,
1919
} from 'sentry/views/explore/contexts/logs/logsPageParams';
2020
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';
2222
import {useExploreLogsTable} from 'sentry/views/explore/logs/useLogsQuery';
2323
import {TraceItemDataset} from 'sentry/views/explore/types';
2424
import {SectionKey} from 'sentry/views/issueDetails/streamline/context';
@@ -58,8 +58,10 @@ function OurlogsSectionContent({
5858
const feature = organization.features.includes('ourlogs-enabled');
5959
const tableData = useExploreLogsTable({enabled: feature, limit: 10});
6060
const logsSearch = useLogsSearch();
61-
const abbreviatedTableData = {...tableData, data: (tableData.data ?? []).slice(0, 5)};
61+
const abbreviatedTableData = (tableData.data ?? []).slice(0, 5);
6262
const {openDrawer} = useDrawer();
63+
const logsTableRef = useRef<HTMLButtonElement>(null);
64+
const sharedHoverTimeoutRef = useRef<NodeJS.Timeout | null>(null);
6365

6466
const limitToTraceId = event.contexts?.trace?.trace_id;
6567
const onOpenLogsDrawer = useCallback(() => {
@@ -81,6 +83,14 @@ function OurlogsSectionContent({
8183
{
8284
ariaLabel: 'logs drawer',
8385
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+
},
8494
}
8595
);
8696
}, [group, event, project, openDrawer, organization, limitToTraceId]);
@@ -103,39 +113,44 @@ function OurlogsSectionContent({
103113
title={t('Logs')}
104114
data-test-id="logs-data-section"
105115
>
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>
112130
{tableData.data?.length > 5 ? (
113131
<div>
114132
<Button
115133
icon={<IconChevron direction="right" />}
116134
aria-label={t('View more')}
117-
size="md"
135+
size="sm"
118136
onClick={() => onOpenLogsDrawer()}
119137
>
120138
{t('View more')}
121139
</Button>
122140
</div>
123141
) : null}
124-
</LogContentWrapper>
142+
</SmallTableContentWrapper>
125143
</InterimSection>
126144
);
127145
}
128146

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')`
130153
all: unset;
131154
display: flex;
132155
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-
}
141156
`;

0 commit comments

Comments
 (0)