mergedList.tsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 GroupingStore.onToggleCollapseFingerprints
  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. totalFingerprint={fingerprintsWithLatestEvent.length}
  70. />
  71. ))}
  72. </PanelBody>
  73. </Panel>
  74. {pageLinks && <Pagination pageLinks={pageLinks} />}
  75. </Fragment>
  76. );
  77. }
  78. export default withOrganization(MergedList);