tableView.tsx 22 KB

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