deadRageSelectorCards.tsx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import {Location} from 'history';
  4. import {IconCursorArrow} from 'sentry/icons';
  5. import {t} from 'sentry/locale';
  6. import {space} from 'sentry/styles/space';
  7. import useDeadRageSelectors from 'sentry/utils/replays/hooks/useDeadRageSelectors';
  8. import {useLocation} from 'sentry/utils/useLocation';
  9. import SelectorTable from 'sentry/views/replays/deadRageClick/selectorTable';
  10. function DeadRageSelectorCards() {
  11. const location = useLocation();
  12. return (
  13. <SplitCardContainer>
  14. <DeadClickTable location={location} />
  15. <RageClickTable location={location} />
  16. </SplitCardContainer>
  17. );
  18. }
  19. function DeadClickTable({location}: {location: Location<any>}) {
  20. const {isLoading, isError, data} = useDeadRageSelectors({
  21. per_page: 4,
  22. sort: '-count_dead_clicks',
  23. cursor: undefined,
  24. prefix: 'selector_',
  25. isWidgetData: true,
  26. });
  27. return (
  28. <SelectorTable
  29. data={data.filter(d => (d.count_dead_clicks ?? 0) > 0)}
  30. isError={isError}
  31. isLoading={isLoading}
  32. location={location}
  33. clickCountColumns={[{key: 'count_dead_clicks', name: 'dead clicks'}]}
  34. title={
  35. <Fragment>
  36. <IconContainer>
  37. <IconCursorArrow size="xs" color="yellow300" />
  38. </IconContainer>
  39. {t('Most Dead Clicks')}
  40. </Fragment>
  41. }
  42. customHandleResize={() => {}}
  43. clickCountSortable={false}
  44. />
  45. );
  46. }
  47. function RageClickTable({location}: {location: Location<any>}) {
  48. const {isLoading, isError, data} = useDeadRageSelectors({
  49. per_page: 4,
  50. sort: '-count_rage_clicks',
  51. cursor: undefined,
  52. prefix: 'selector_',
  53. isWidgetData: true,
  54. });
  55. return (
  56. <SelectorTable
  57. data={data.filter(d => (d.count_rage_clicks ?? 0) > 0)}
  58. isError={isError}
  59. isLoading={isLoading}
  60. location={location}
  61. clickCountColumns={[{key: 'count_rage_clicks', name: 'rage clicks'}]}
  62. title={
  63. <Fragment>
  64. <IconContainer>
  65. <IconCursorArrow size="xs" color="red300" />
  66. </IconContainer>
  67. {t('Most Rage Clicks')}
  68. </Fragment>
  69. }
  70. customHandleResize={() => {}}
  71. clickCountSortable={false}
  72. />
  73. );
  74. }
  75. const SplitCardContainer = styled('div')`
  76. display: grid;
  77. grid-template-columns: 1fr 1fr;
  78. grid-template-rows: max-content max-content;
  79. grid-auto-flow: column;
  80. gap: 0 ${space(2)};
  81. align-items: stretch;
  82. padding-top: ${space(1)};
  83. `;
  84. const IconContainer = styled('span')`
  85. margin-right: ${space(1)};
  86. `;
  87. export default DeadRageSelectorCards;