tableView.tsx 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import * as Sentry from '@sentry/react';
  4. import type {Location, LocationDescriptorObject} from 'history';
  5. import {openModal} from 'sentry/actionCreators/modal';
  6. import GridEditable, {
  7. COL_WIDTH_MINIMUM,
  8. COL_WIDTH_UNDEFINED,
  9. } from 'sentry/components/gridEditable';
  10. import SortLink from 'sentry/components/gridEditable/sortLink';
  11. import Link from 'sentry/components/links/link';
  12. import {Tooltip} from 'sentry/components/tooltip';
  13. import Truncate from 'sentry/components/truncate';
  14. import {IconStack} from 'sentry/icons';
  15. import {t} from 'sentry/locale';
  16. import type {Organization} from 'sentry/types/organization';
  17. import {trackAnalytics} from 'sentry/utils/analytics';
  18. import {browserHistory} from 'sentry/utils/browserHistory';
  19. import type {CustomMeasurementCollection} from 'sentry/utils/customMeasurements/customMeasurements';
  20. import {getTimeStampFromTableDateField} from 'sentry/utils/dates';
  21. import type {TableData, TableDataRow} from 'sentry/utils/discover/discoverQuery';
  22. import type EventView from 'sentry/utils/discover/eventView';
  23. import {
  24. isFieldSortable,
  25. pickRelevantLocationQueryStrings,
  26. } from 'sentry/utils/discover/eventView';
  27. import {
  28. DURATION_UNITS,
  29. getFieldRenderer,
  30. SIZE_UNITS,
  31. } from 'sentry/utils/discover/fieldRenderers';
  32. import type {Column} from 'sentry/utils/discover/fields';
  33. import {
  34. fieldAlignment,
  35. getEquationAliasIndex,
  36. isEquationAlias,
  37. } from 'sentry/utils/discover/fields';
  38. import {
  39. type DiscoverDatasets,
  40. DisplayModes,
  41. SavedQueryDatasets,
  42. TOP_N,
  43. } from 'sentry/utils/discover/types';
  44. import {generateLinkToEventInTraceView} from 'sentry/utils/discover/urls';
  45. import ViewReplayLink from 'sentry/utils/discover/viewReplayLink';
  46. import {getShortEventId} from 'sentry/utils/events';
  47. import {generateProfileFlamechartRoute} from 'sentry/utils/profiling/routes';
  48. import {decodeList} from 'sentry/utils/queryString';
  49. import {MutableSearch} from 'sentry/utils/tokenizeSearch';
  50. import normalizeUrl from 'sentry/utils/url/normalizeUrl';
  51. import {useNavigate} from 'sentry/utils/useNavigate';
  52. import useProjects from 'sentry/utils/useProjects';
  53. import {useRoutes} from 'sentry/utils/useRoutes';
  54. import {appendQueryDatasetParam, hasDatasetSelector} from 'sentry/views/dashboards/utils';
  55. import {TraceViewSources} from 'sentry/views/performance/newTraceDetails/traceHeader/breadcrumbs';
  56. import {getTraceDetailsUrl} from 'sentry/views/performance/traceDetails/utils';
  57. import {generateReplayLink} from 'sentry/views/performance/transactionSummary/utils';
  58. import {
  59. getExpandedResults,
  60. getTargetForTransactionSummaryLink,
  61. pushEventViewToLocation,
  62. } from '../utils';
  63. import {QuickContextHoverWrapper} from './quickContext/quickContextWrapper';
  64. import {ContextType} from './quickContext/utils';
  65. import CellAction, {Actions, updateQuery} from './cellAction';
  66. import ColumnEditModal, {modalCss} from './columnEditModal';
  67. import TableActions from './tableActions';
  68. import TopResultsIndicator from './topResultsIndicator';
  69. import type {TableColumn} from './types';
  70. export type TableViewProps = {
  71. error: string | null;
  72. eventView: EventView;
  73. isFirstPage: boolean;
  74. isLoading: boolean;
  75. location: Location;
  76. measurementKeys: null | string[];
  77. onChangeShowTags: () => void;
  78. organization: Organization;
  79. showTags: boolean;
  80. tableData: TableData | null | undefined;
  81. title: string;
  82. customMeasurements?: CustomMeasurementCollection;
  83. dataset?: DiscoverDatasets;
  84. isHomepage?: boolean;
  85. queryDataset?: SavedQueryDatasets;
  86. spanOperationBreakdownKeys?: string[];
  87. };
  88. /**
  89. * The `TableView` is marked with leading _ in its method names. It consumes
  90. * the EventView object given in its props to generate new EventView objects
  91. * for actions like resizing column.
  92. *
  93. * The entire state of the table view (or event view) is co-located within
  94. * the EventView object. This object is fed from the props.
  95. *
  96. * Attempting to modify the state, and therefore, modifying the given EventView
  97. * object given from its props, will generate new instances of EventView objects.
  98. *
  99. * In most cases, the new EventView object differs from the previous EventView
  100. * object. The new EventView object is pushed to the location object.
  101. */
  102. function TableView(props: TableViewProps) {
  103. const {projects} = useProjects();
  104. const routes = useRoutes();
  105. const navigate = useNavigate();
  106. const replayLinkGenerator = generateReplayLink(routes);
  107. /**
  108. * Updates a column on resizing
  109. */
  110. function _resizeColumn(
  111. columnIndex: number,
  112. nextColumn: TableColumn<keyof TableDataRow>
  113. ) {
  114. const {location, eventView, organization, queryDataset} = props;
  115. const newWidth = nextColumn.width ? Number(nextColumn.width) : COL_WIDTH_UNDEFINED;
  116. const nextEventView = eventView.withResizedColumn(columnIndex, newWidth);
  117. pushEventViewToLocation({
  118. navigate,
  119. location,
  120. nextEventView,
  121. extraQuery: {
  122. ...pickRelevantLocationQueryStrings(location),
  123. ...appendQueryDatasetParam(organization, queryDataset),
  124. },
  125. });
  126. }
  127. function _renderPrependColumns(
  128. isHeader: boolean,
  129. dataRow?: any,
  130. rowIndex?: number
  131. ): React.ReactNode[] {
  132. const {organization, eventView, tableData, location, isHomepage, queryDataset} =
  133. props;
  134. const hasAggregates = eventView.hasAggregateField();
  135. const hasIdField = eventView.hasIdField();
  136. const isTransactionsDataset =
  137. hasDatasetSelector(organization) &&
  138. queryDataset === SavedQueryDatasets.TRANSACTIONS;
  139. if (isHeader) {
  140. if (hasAggregates) {
  141. return [
  142. <PrependHeader key="header-icon">
  143. <IconStack size="sm" />
  144. </PrependHeader>,
  145. ];
  146. }
  147. if (!hasIdField) {
  148. return [
  149. <PrependHeader key="header-event-id">
  150. <SortLink
  151. align="left"
  152. title={t('event id')}
  153. direction={undefined}
  154. canSort={false}
  155. generateSortLink={() => undefined}
  156. />
  157. </PrependHeader>,
  158. ];
  159. }
  160. return [];
  161. }
  162. if (hasAggregates) {
  163. const nextView = getExpandedResults(eventView, {}, dataRow);
  164. const target = {
  165. pathname: location.pathname,
  166. query: {
  167. ...nextView.generateQueryStringObject(),
  168. ...appendQueryDatasetParam(organization, queryDataset),
  169. },
  170. };
  171. return [
  172. <Tooltip key={`eventlink${rowIndex}`} title={t('Open Group')}>
  173. <Link
  174. to={target}
  175. data-test-id="open-group"
  176. onClick={() => {
  177. if (nextView.isEqualTo(eventView)) {
  178. Sentry.captureException(new Error('Failed to drilldown'));
  179. }
  180. }}
  181. >
  182. <StyledIcon size="sm" />
  183. </Link>
  184. </Tooltip>,
  185. ];
  186. }
  187. if (!hasIdField) {
  188. let value = dataRow.id;
  189. if (tableData?.meta) {
  190. const fieldRenderer = getFieldRenderer('id', tableData.meta);
  191. value = fieldRenderer(dataRow, {organization, location});
  192. }
  193. let target: any;
  194. if (dataRow['event.type'] !== 'transaction' && !isTransactionsDataset) {
  195. const project = dataRow.project || dataRow['project.name'];
  196. target = {
  197. // NOTE: This uses a legacy redirect for project event to the issue group event link
  198. // This only works with dev-server or production.
  199. pathname: normalizeUrl(
  200. `/${organization.slug}/${project}/events/${dataRow.id}/`
  201. ),
  202. query: {...location.query, referrer: 'discover-events-table'},
  203. };
  204. } else {
  205. if (!dataRow.trace) {
  206. throw new Error(
  207. 'Transaction event should always have a trace associated with it.'
  208. );
  209. }
  210. target = generateLinkToEventInTraceView({
  211. traceSlug: dataRow.trace,
  212. eventId: dataRow.id,
  213. projectSlug: dataRow.project || dataRow['project.name'],
  214. timestamp: dataRow.timestamp,
  215. organization,
  216. isHomepage,
  217. location,
  218. eventView,
  219. type: 'discover',
  220. source: TraceViewSources.DISCOVER,
  221. });
  222. }
  223. const eventIdLink = (
  224. <StyledLink data-test-id="view-event" to={target}>
  225. {value}
  226. </StyledLink>
  227. );
  228. return [
  229. <QuickContextHoverWrapper
  230. key={`quickContextEventHover${rowIndex}`}
  231. dataRow={dataRow}
  232. contextType={ContextType.EVENT}
  233. organization={organization}
  234. projects={projects}
  235. eventView={eventView}
  236. >
  237. {eventIdLink}
  238. </QuickContextHoverWrapper>,
  239. ];
  240. }
  241. return [];
  242. }
  243. function _renderGridHeaderCell(
  244. column: TableColumn<keyof TableDataRow>
  245. ): React.ReactNode {
  246. const {eventView, location, tableData, organization, queryDataset} = props;
  247. const tableMeta = tableData?.meta;
  248. const align = fieldAlignment(column.name, column.type, tableMeta);
  249. const field = {field: column.key as string, width: column.width};
  250. function generateSortLink(): LocationDescriptorObject | undefined {
  251. if (!tableMeta) {
  252. return undefined;
  253. }
  254. const nextEventView = eventView.sortOnField(field, tableMeta);
  255. const queryStringObject = nextEventView.generateQueryStringObject();
  256. // Need to pull yAxis from location since eventView only stores 1 yAxis field at time
  257. queryStringObject.yAxis = decodeList(location.query.yAxis);
  258. return {
  259. ...location,
  260. query: {
  261. ...queryStringObject,
  262. ...appendQueryDatasetParam(organization, queryDataset),
  263. },
  264. };
  265. }
  266. const currentSort = eventView.sortForField(field, tableMeta);
  267. const canSort = isFieldSortable(field, tableMeta);
  268. let titleText = isEquationAlias(column.name)
  269. ? eventView.getEquations()[getEquationAliasIndex(column.name)]!
  270. : column.name;
  271. if (column.name.toLowerCase() === 'replayid') {
  272. titleText = 'Replay';
  273. }
  274. const title = (
  275. <StyledTooltip title={titleText}>
  276. <Truncate value={titleText} maxLength={60} expandable={false} />
  277. </StyledTooltip>
  278. );
  279. return (
  280. <SortLink
  281. align={align}
  282. title={title}
  283. direction={currentSort ? currentSort.kind : undefined}
  284. canSort={canSort}
  285. generateSortLink={generateSortLink}
  286. />
  287. );
  288. }
  289. function _renderGridBodyCell(
  290. column: TableColumn<keyof TableDataRow>,
  291. dataRow: TableDataRow,
  292. rowIndex: number,
  293. columnIndex: number
  294. ): React.ReactNode {
  295. const {
  296. isFirstPage,
  297. eventView,
  298. location,
  299. organization,
  300. tableData,
  301. isHomepage,
  302. queryDataset,
  303. } = props;
  304. if (!tableData || !tableData.meta) {
  305. return dataRow[column.key];
  306. }
  307. const columnKey = String(column.key);
  308. const fieldRenderer = getFieldRenderer(columnKey, tableData.meta, false);
  309. const display = eventView.getDisplayMode();
  310. const isTopEvents =
  311. display === DisplayModes.TOP5 || display === DisplayModes.DAILYTOP5;
  312. const topEvents = eventView.topEvents ? parseInt(eventView.topEvents, 10) : TOP_N;
  313. const count = Math.min(tableData?.data?.length ?? topEvents, topEvents);
  314. const unit = tableData.meta.units?.[columnKey];
  315. let cell = fieldRenderer(dataRow, {organization, location, unit});
  316. const isTransactionsDataset =
  317. hasDatasetSelector(organization) &&
  318. queryDataset === SavedQueryDatasets.TRANSACTIONS;
  319. if (columnKey === 'id') {
  320. let target: any;
  321. if (dataRow['event.type'] !== 'transaction' && !isTransactionsDataset) {
  322. const project = dataRow.project || dataRow['project.name'];
  323. target = {
  324. // NOTE: This uses a legacy redirect for project event to the issue group event link.
  325. // This only works with dev-server or production.
  326. pathname: normalizeUrl(
  327. `/${organization.slug}/${project}/events/${dataRow.id}/`
  328. ),
  329. query: {...location.query, referrer: 'discover-events-table'},
  330. };
  331. } else {
  332. if (!dataRow.trace) {
  333. throw new Error(
  334. 'Transaction event should always have a trace associated with it.'
  335. );
  336. }
  337. target = generateLinkToEventInTraceView({
  338. traceSlug: dataRow.trace?.toString(),
  339. eventId: dataRow.id,
  340. projectSlug: (dataRow.project || dataRow['project.name']!).toString(),
  341. timestamp: dataRow.timestamp!,
  342. organization,
  343. isHomepage,
  344. location,
  345. eventView,
  346. type: 'discover',
  347. source: TraceViewSources.DISCOVER,
  348. });
  349. }
  350. const idLink = (
  351. <StyledLink data-test-id="view-event" to={target}>
  352. {cell}
  353. </StyledLink>
  354. );
  355. cell = (
  356. <QuickContextHoverWrapper
  357. organization={organization}
  358. dataRow={dataRow}
  359. contextType={ContextType.EVENT}
  360. projects={projects}
  361. eventView={eventView}
  362. >
  363. {idLink}
  364. </QuickContextHoverWrapper>
  365. );
  366. } else if (columnKey === 'transaction' && dataRow.transaction) {
  367. cell = (
  368. <TransactionLink
  369. data-test-id="tableView-transaction-link"
  370. to={getTargetForTransactionSummaryLink(
  371. dataRow,
  372. organization,
  373. projects,
  374. eventView,
  375. location
  376. )}
  377. >
  378. {cell}
  379. </TransactionLink>
  380. );
  381. } else if (columnKey === 'trace') {
  382. const timestamp = getTimeStampFromTableDateField(
  383. dataRow['max(timestamp)'] ?? dataRow.timestamp
  384. );
  385. const dateSelection = eventView.normalizeDateSelection(location);
  386. if (dataRow.trace) {
  387. const target = getTraceDetailsUrl({
  388. organization,
  389. traceSlug: String(dataRow.trace),
  390. dateSelection,
  391. timestamp,
  392. location,
  393. source: TraceViewSources.DISCOVER,
  394. });
  395. cell = (
  396. <Tooltip title={t('View Trace')}>
  397. <StyledLink data-test-id="view-trace" to={target}>
  398. {cell}
  399. </StyledLink>
  400. </Tooltip>
  401. );
  402. }
  403. } else if (columnKey === 'replayId') {
  404. if (dataRow.replayId) {
  405. if (!dataRow['project.name']) {
  406. return getShortEventId(String(dataRow.replayId));
  407. }
  408. const target = replayLinkGenerator(organization, dataRow, undefined);
  409. cell = (
  410. <ViewReplayLink replayId={dataRow.replayId} to={target}>
  411. {cell}
  412. </ViewReplayLink>
  413. );
  414. }
  415. } else if (columnKey === 'profile.id') {
  416. const projectSlug = dataRow.project || dataRow['project.name'];
  417. const profileId = dataRow['profile.id'];
  418. if (projectSlug && profileId) {
  419. const target = generateProfileFlamechartRoute({
  420. orgSlug: organization.slug,
  421. projectSlug: String(projectSlug),
  422. profileId: String(profileId),
  423. });
  424. cell = (
  425. <StyledTooltip title={t('View Profile')}>
  426. <StyledLink
  427. data-test-id="view-profile"
  428. to={target}
  429. onClick={() =>
  430. trackAnalytics('profiling_views.go_to_flamegraph', {
  431. organization,
  432. source: 'discover.table',
  433. })
  434. }
  435. >
  436. {cell}
  437. </StyledLink>
  438. </StyledTooltip>
  439. );
  440. }
  441. }
  442. const topResultsIndicator =
  443. isFirstPage && isTopEvents && rowIndex < topEvents && columnIndex === 0 ? (
  444. // Add one if we need to include Other in the series
  445. <TopResultsIndicator count={count} index={rowIndex} />
  446. ) : null;
  447. const fieldName = columnKey;
  448. const value = dataRow[fieldName];
  449. if (
  450. tableData.meta[fieldName] === 'integer' &&
  451. typeof value === 'number' &&
  452. value > 999
  453. ) {
  454. return (
  455. <Tooltip
  456. title={value.toLocaleString()}
  457. containerDisplayMode="block"
  458. position="right"
  459. >
  460. {topResultsIndicator}
  461. <CellAction
  462. column={column}
  463. dataRow={dataRow}
  464. handleCellAction={handleCellAction(dataRow, column)}
  465. >
  466. {cell}
  467. </CellAction>
  468. </Tooltip>
  469. );
  470. }
  471. return (
  472. <Fragment>
  473. {topResultsIndicator}
  474. <CellAction
  475. column={column}
  476. dataRow={dataRow}
  477. handleCellAction={handleCellAction(dataRow, column)}
  478. >
  479. {cell}
  480. </CellAction>
  481. </Fragment>
  482. );
  483. }
  484. function handleEditColumns() {
  485. const {
  486. organization,
  487. eventView,
  488. measurementKeys,
  489. spanOperationBreakdownKeys,
  490. customMeasurements,
  491. dataset,
  492. } = props;
  493. openModal(
  494. modalProps => (
  495. <ColumnEditModal
  496. {...modalProps}
  497. organization={organization}
  498. measurementKeys={measurementKeys}
  499. spanOperationBreakdownKeys={spanOperationBreakdownKeys}
  500. columns={eventView.getColumns().map(col => col.column)}
  501. onApply={handleUpdateColumns}
  502. customMeasurements={customMeasurements}
  503. dataset={dataset}
  504. />
  505. ),
  506. {modalCss, closeEvents: 'escape-key'}
  507. );
  508. }
  509. function handleCellAction(
  510. dataRow: TableDataRow,
  511. column: TableColumn<keyof TableDataRow>
  512. ) {
  513. return (action: Actions, value: React.ReactText) => {
  514. const {eventView, organization, location, tableData, isHomepage, queryDataset} =
  515. props;
  516. const query = new MutableSearch(eventView.query);
  517. let nextView = eventView.clone();
  518. trackAnalytics('discover_v2.results.cellaction', {
  519. organization,
  520. action,
  521. });
  522. switch (action) {
  523. case Actions.RELEASE: {
  524. const maybeProject = projects.find(project => {
  525. return project.slug === dataRow.project;
  526. });
  527. browserHistory.push(
  528. normalizeUrl({
  529. pathname: `/organizations/${
  530. organization.slug
  531. }/releases/${encodeURIComponent(value)}/`,
  532. query: {
  533. ...nextView.getPageFiltersQuery(),
  534. project: maybeProject ? maybeProject.id : undefined,
  535. },
  536. })
  537. );
  538. return;
  539. }
  540. case Actions.DRILLDOWN: {
  541. // count_unique(column) drilldown
  542. trackAnalytics('discover_v2.results.drilldown', {
  543. organization,
  544. });
  545. // Drilldown into each distinct value and get a count() for each value.
  546. nextView = getExpandedResults(nextView, {}, dataRow).withNewColumn({
  547. kind: 'function',
  548. function: ['count', '', undefined, undefined],
  549. });
  550. browserHistory.push(
  551. normalizeUrl(
  552. nextView.getResultsViewUrlTarget(
  553. organization.slug,
  554. isHomepage,
  555. hasDatasetSelector(organization) ? queryDataset : undefined
  556. )
  557. )
  558. );
  559. return;
  560. }
  561. default: {
  562. // Some custom perf metrics have units.
  563. // These custom perf metrics need to be adjusted to the correct value.
  564. let cellValue = value;
  565. const unit = tableData?.meta?.units?.[column.name];
  566. if (typeof cellValue === 'number' && unit) {
  567. if (Object.keys(SIZE_UNITS).includes(unit)) {
  568. // @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
  569. cellValue *= SIZE_UNITS[unit];
  570. } else if (Object.keys(DURATION_UNITS).includes(unit)) {
  571. // @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
  572. cellValue *= DURATION_UNITS[unit];
  573. }
  574. }
  575. updateQuery(query, action, column, cellValue);
  576. }
  577. }
  578. nextView.query = query.formatString();
  579. const target = nextView.getResultsViewUrlTarget(
  580. organization.slug,
  581. isHomepage,
  582. hasDatasetSelector(organization) ? queryDataset : undefined
  583. );
  584. // Get yAxis from location
  585. target.query.yAxis = decodeList(location.query.yAxis);
  586. browserHistory.push(normalizeUrl(target));
  587. };
  588. }
  589. function handleUpdateColumns(columns: Column[]): void {
  590. const {organization, eventView, location, isHomepage, queryDataset} = props;
  591. // metrics
  592. trackAnalytics('discover_v2.update_columns', {
  593. organization,
  594. });
  595. const nextView = eventView.withColumns(columns);
  596. const resultsViewUrlTarget = nextView.getResultsViewUrlTarget(
  597. organization.slug,
  598. isHomepage,
  599. hasDatasetSelector(organization) ? queryDataset : undefined
  600. );
  601. // Need to pull yAxis from location since eventView only stores 1 yAxis field at time
  602. const previousYAxis = decodeList(location.query.yAxis);
  603. resultsViewUrlTarget.query.yAxis = previousYAxis.filter(yAxis =>
  604. nextView.getYAxisOptions().find(({value}) => value === yAxis)
  605. );
  606. browserHistory.push(normalizeUrl(resultsViewUrlTarget));
  607. }
  608. function renderHeaderButtons() {
  609. const {
  610. organization,
  611. title,
  612. eventView,
  613. isLoading,
  614. error,
  615. tableData,
  616. location,
  617. onChangeShowTags,
  618. showTags,
  619. queryDataset,
  620. } = props;
  621. return (
  622. <TableActions
  623. title={title}
  624. isLoading={isLoading}
  625. error={error}
  626. organization={organization}
  627. eventView={eventView}
  628. onEdit={handleEditColumns}
  629. tableData={tableData}
  630. location={location}
  631. onChangeShowTags={onChangeShowTags}
  632. showTags={showTags}
  633. supportsInvestigationRule
  634. queryDataset={queryDataset}
  635. />
  636. );
  637. }
  638. const {error, eventView, isLoading, tableData} = props;
  639. const columnOrder = eventView.getColumns();
  640. const columnSortBy = eventView.getSorts();
  641. const prependColumnWidths = eventView.hasAggregateField()
  642. ? ['40px']
  643. : eventView.hasIdField()
  644. ? []
  645. : [`minmax(${COL_WIDTH_MINIMUM}px, max-content)`];
  646. return (
  647. <GridEditable
  648. isLoading={isLoading}
  649. error={error}
  650. data={tableData ? tableData.data : []}
  651. columnOrder={columnOrder}
  652. columnSortBy={columnSortBy}
  653. title={t('Results')}
  654. grid={{
  655. renderHeadCell: _renderGridHeaderCell as any,
  656. renderBodyCell: _renderGridBodyCell as any,
  657. onResizeColumn: _resizeColumn as any,
  658. renderPrependColumns: _renderPrependColumns as any,
  659. prependColumnWidths,
  660. }}
  661. headerButtons={renderHeaderButtons}
  662. />
  663. );
  664. }
  665. const PrependHeader = styled('span')`
  666. color: ${p => p.theme.subText};
  667. `;
  668. const StyledTooltip = styled(Tooltip)`
  669. display: initial;
  670. max-width: max-content;
  671. `;
  672. export const StyledLink = styled(Link)`
  673. & div {
  674. display: inline;
  675. }
  676. `;
  677. export const TransactionLink = styled(Link)`
  678. ${p => p.theme.overflowEllipsis}
  679. `;
  680. const StyledIcon = styled(IconStack)`
  681. vertical-align: middle;
  682. `;
  683. export default TableView;