feedbackListBulkSelection.tsx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import Button from 'sentry/components/actions/button';
  2. import {DropdownMenu} from 'sentry/components/dropdownMenu';
  3. import ErrorBoundary from 'sentry/components/errorBoundary';
  4. import decodeMailbox from 'sentry/components/feedback/decodeMailbox';
  5. import useBulkEditFeedbacks from 'sentry/components/feedback/list/useBulkEditFeedbacks';
  6. import type useListItemCheckboxState from 'sentry/components/feedback/list/useListItemCheckboxState';
  7. import {Flex} from 'sentry/components/profiling/flex';
  8. import {IconEllipsis} from 'sentry/icons/iconEllipsis';
  9. import {t, tct} from 'sentry/locale';
  10. import {space} from 'sentry/styles/space';
  11. import {GroupStatus} from 'sentry/types';
  12. interface Props
  13. extends Pick<
  14. ReturnType<typeof useListItemCheckboxState>,
  15. 'countSelected' | 'deselectAll' | 'selectedIds'
  16. > {
  17. mailbox: ReturnType<typeof decodeMailbox>;
  18. }
  19. export default function FeedbackListBulkSelection({
  20. mailbox,
  21. countSelected,
  22. selectedIds,
  23. deselectAll,
  24. }: Props) {
  25. const {onToggleResovled, onMarkAsRead, onMarkUnread} = useBulkEditFeedbacks({
  26. selectedIds,
  27. deselectAll,
  28. });
  29. const newMailbox =
  30. mailbox === 'resolved' ? GroupStatus.UNRESOLVED : GroupStatus.RESOLVED;
  31. return (
  32. <Flex gap={space(1)} align="center" justify="space-between" flex="1 0 auto">
  33. <span>
  34. <strong>
  35. {tct('[countSelected] Selected', {
  36. countSelected,
  37. })}
  38. </strong>
  39. </span>
  40. <Flex gap={space(1)} justify="flex-end">
  41. <ErrorBoundary mini>
  42. <Button onClick={() => onToggleResovled(newMailbox)}>
  43. {mailbox === 'resolved' ? t('Unresolve') : t('Resolve')}
  44. </Button>
  45. </ErrorBoundary>
  46. <ErrorBoundary mini>
  47. <DropdownMenu
  48. position="bottom-end"
  49. triggerProps={{
  50. 'aria-label': t('Read Menu'),
  51. icon: <IconEllipsis size="xs" />,
  52. showChevron: false,
  53. size: 'xs',
  54. }}
  55. items={[
  56. {
  57. key: 'mark read',
  58. label: t('Mark Read'),
  59. onAction: onMarkAsRead,
  60. },
  61. {
  62. key: 'mark unread',
  63. label: t('Mark Unread'),
  64. onAction: onMarkUnread,
  65. },
  66. ]}
  67. />
  68. </ErrorBoundary>
  69. </Flex>
  70. </Flex>
  71. );
  72. }