mergedList.tsx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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} from 'sentry/types/group';
  9. import type {Organization} from 'sentry/types/organization';
  10. import type {Project} from 'sentry/types/project';
  11. import {useLocation} from 'sentry/utils/useLocation';
  12. import MergedItem from './mergedItem';
  13. import {MergedToolbar} from './mergedToolbar';
  14. type Props = {
  15. groupId: Group['id'];
  16. /**
  17. * From GroupingStore.onToggleCollapseFingerprints
  18. */
  19. onToggleCollapse: () => void;
  20. /**
  21. * From GroupMergedView -> handleUnmerge
  22. */
  23. onUnmerge: () => void;
  24. organization: Organization;
  25. project: Project;
  26. fingerprints?: Fingerprint[];
  27. pageLinks?: string;
  28. };
  29. function MergedList({
  30. fingerprints = [],
  31. pageLinks,
  32. onToggleCollapse,
  33. onUnmerge,
  34. organization,
  35. groupId,
  36. project,
  37. }: Props) {
  38. const fingerprintsWithLatestEvent = fingerprints.filter(
  39. ({latestEvent}) => !!latestEvent
  40. );
  41. const hasResults = fingerprintsWithLatestEvent.length > 0;
  42. const location = useLocation();
  43. if (!hasResults) {
  44. return (
  45. <Panel>
  46. <EmptyStateWarning>
  47. <p>{t("There don't seem to be any hashes for this issue.")}</p>
  48. </EmptyStateWarning>
  49. </Panel>
  50. );
  51. }
  52. return (
  53. <Fragment>
  54. <Panel>
  55. <MergedToolbar
  56. onToggleCollapse={onToggleCollapse}
  57. onUnmerge={onUnmerge}
  58. orgId={organization.slug}
  59. project={project}
  60. groupId={groupId}
  61. location={location}
  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 MergedList;