tracked-changes-actions.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { FC } from 'react'
  2. import { useTranslation } from 'react-i18next'
  3. import MaterialIcon from '@/shared/components/material-icon'
  4. import OLTooltip from '@/shared/components/ol/ol-tooltip'
  5. import { usePermissionsContext } from '@/features/ide-react/context/permissions-context'
  6. import { useTrackedChangesActions } from '@/features/review-panel/hooks/use-tracked-changes-actions'
  7. const TrackedChangesActions: FC = () => {
  8. const { t } = useTranslation()
  9. const permissions = usePermissionsContext()
  10. const { changesInSelection, acceptChangesHandler, rejectChangesHandler } =
  11. useTrackedChangesActions()
  12. if (!permissions.write || changesInSelection.length === 0) {
  13. return null
  14. }
  15. return (
  16. <>
  17. <div className="editor-floating-menu-divider" />
  18. <OLTooltip
  19. id="editor-floating-menu-accept-changes"
  20. description={t('accept_selected_changes')}
  21. overlayProps={{ placement: 'right' }}
  22. >
  23. <button
  24. className="editor-floating-menu-button"
  25. onClick={acceptChangesHandler}
  26. aria-label={t('accept_selected_changes')}
  27. >
  28. <MaterialIcon type="check" />
  29. </button>
  30. </OLTooltip>
  31. <OLTooltip
  32. id="editor-floating-menu-reject-changes"
  33. description={t('reject_selected_changes')}
  34. overlayProps={{ placement: 'right' }}
  35. >
  36. <button
  37. className="editor-floating-menu-button"
  38. onClick={rejectChangesHandler}
  39. aria-label={t('reject_selected_changes')}
  40. >
  41. <MaterialIcon type="clear" />
  42. </button>
  43. </OLTooltip>
  44. </>
  45. )
  46. }
  47. export default TrackedChangesActions