ActionsCell.tsx 727 B

12345678910111213141516171819202122232425
  1. import React from 'react';
  2. import { TopicMessage } from 'generated-sources';
  3. import { CellContext } from '@tanstack/react-table';
  4. import { Dropdown, DropdownItem } from 'components/common/Dropdown';
  5. import useDataSaver from 'lib/hooks/useDataSaver';
  6. const ActionsCell: React.FC<CellContext<TopicMessage, unknown>> = ({ row }) => {
  7. const { content } = row.original;
  8. const { copyToClipboard, saveFile } = useDataSaver(
  9. 'topic-message',
  10. content || ''
  11. );
  12. return (
  13. <Dropdown>
  14. <DropdownItem onClick={copyToClipboard}>
  15. Copy content to clipboard
  16. </DropdownItem>
  17. <DropdownItem onClick={saveFile}>Save content as a file</DropdownItem>
  18. </Dropdown>
  19. );
  20. };
  21. export default ActionsCell;