mergedList.tsx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import {Fragment} from 'react';
  2. import EmptyStateWarning from 'sentry/components/emptyStateWarning';
  3. import Pagination from 'sentry/components/pagination';
  4. import {Panel, PanelBody} from 'sentry/components/panels';
  5. import QueryCount from 'sentry/components/queryCount';
  6. import {t} from 'sentry/locale';
  7. import {Fingerprint} from 'sentry/stores/groupingStore';
  8. import {Group, Organization, Project} from 'sentry/types';
  9. import withOrganization from 'sentry/utils/withOrganization';
  10. import MergedItem from './mergedItem';
  11. import MergedToolbar from './mergedToolbar';
  12. type Props = {
  13. groupId: Group['id'];
  14. /*
  15. * From GroupingActions.toggleCollapseFingerprints
  16. */
  17. onToggleCollapse: () => void;
  18. /**
  19. * From GroupMergedView -> handleUnmerge
  20. */
  21. onUnmerge: () => void;
  22. organization: Organization;
  23. project: Project;
  24. fingerprints?: Fingerprint[];
  25. pageLinks?: string;
  26. };
  27. function MergedList({
  28. fingerprints = [],
  29. pageLinks,
  30. onToggleCollapse,
  31. onUnmerge,
  32. organization,
  33. groupId,
  34. project,
  35. }: Props) {
  36. const fingerprintsWithLatestEvent = fingerprints.filter(
  37. ({latestEvent}) => !!latestEvent
  38. );
  39. const hasResults = fingerprintsWithLatestEvent.length > 0;
  40. if (!hasResults) {
  41. return (
  42. <Panel>
  43. <EmptyStateWarning>
  44. <p>{t("There don't seem to be any hashes for this issue.")}</p>
  45. </EmptyStateWarning>
  46. </Panel>
  47. );
  48. }
  49. return (
  50. <Fragment>
  51. <h4>
  52. <span>{t('Merged fingerprints with latest event')}</span>{' '}
  53. <QueryCount count={fingerprintsWithLatestEvent.length} />
  54. </h4>
  55. <Panel>
  56. <MergedToolbar
  57. onToggleCollapse={onToggleCollapse}
  58. onUnmerge={onUnmerge}
  59. orgId={organization.slug}
  60. project={project}
  61. groupId={groupId}
  62. />
  63. <PanelBody>
  64. {fingerprintsWithLatestEvent.map(fingerprint => (
  65. <MergedItem
  66. key={fingerprint.id}
  67. organization={organization}
  68. fingerprint={fingerprint}
  69. />
  70. ))}
  71. </PanelBody>
  72. </Panel>
  73. {pageLinks && <Pagination pageLinks={pageLinks} />}
  74. </Fragment>
  75. );
  76. }
  77. export default withOrganization(MergedList);