mergedList.tsx 2.0 KB

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