mergedList.tsx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 {useLocation} from 'sentry/utils/useLocation';
  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. const location = useLocation();
  41. if (!hasResults) {
  42. return (
  43. <Panel>
  44. <EmptyStateWarning>
  45. <p>{t("There don't seem to be any hashes for this issue.")}</p>
  46. </EmptyStateWarning>
  47. </Panel>
  48. );
  49. }
  50. return (
  51. <Fragment>
  52. <Panel>
  53. <MergedToolbar
  54. onToggleCollapse={onToggleCollapse}
  55. onUnmerge={onUnmerge}
  56. orgId={organization.slug}
  57. project={project}
  58. groupId={groupId}
  59. location={location}
  60. />
  61. <PanelBody>
  62. {fingerprintsWithLatestEvent.map(fingerprint => (
  63. <MergedItem
  64. key={fingerprint.id}
  65. organization={organization}
  66. fingerprint={fingerprint}
  67. totalFingerprint={fingerprintsWithLatestEvent.length}
  68. />
  69. ))}
  70. </PanelBody>
  71. </Panel>
  72. {pageLinks && <Pagination pageLinks={pageLinks} />}
  73. </Fragment>
  74. );
  75. }
  76. export default MergedList;