eventsTable.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import {Component} from 'react';
  2. import EventsTableRow from 'sentry/components/eventsTable/eventsTableRow';
  3. import {t} from 'sentry/locale';
  4. import {Tag} from 'sentry/types';
  5. import {Event} from 'sentry/types/event';
  6. type Props = {
  7. events: Event[];
  8. groupId: string;
  9. orgFeatures: string[];
  10. orgId: string;
  11. projectId: string;
  12. tagList: Tag[];
  13. };
  14. class EventsTable extends Component<Props> {
  15. render() {
  16. const {events, tagList, orgId, projectId, groupId, orgFeatures} = this.props;
  17. const hasUser = !!events.find(event => event.user);
  18. const isReplayEnabled = orgFeatures.includes('session-replay-ui');
  19. const filteredTagList = tagList.filter(tag =>
  20. tag.key === 'replayId' ? isReplayEnabled : true
  21. );
  22. return (
  23. <table className="table events-table" data-test-id="events-table">
  24. <thead>
  25. <tr>
  26. <th>{t('ID')}</th>
  27. {hasUser && <th>{t('User')}</th>}
  28. {filteredTagList.map(tag => {
  29. if (tag.key === 'replayId') {
  30. return <th key={tag.key}>{t('Replay')}</th>;
  31. }
  32. return <th key={tag.key}>{tag.name}</th>;
  33. })}
  34. </tr>
  35. </thead>
  36. <tbody>
  37. {events.map(event => (
  38. <EventsTableRow
  39. key={event.id}
  40. event={event}
  41. orgId={orgId}
  42. projectId={projectId}
  43. groupId={groupId}
  44. tagList={filteredTagList}
  45. hasUser={hasUser}
  46. />
  47. ))}
  48. </tbody>
  49. </table>
  50. );
  51. }
  52. }
  53. export default EventsTable;