index.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { memo } from 'react'
  2. import { useTranslation } from 'react-i18next'
  3. import { MiniMap } from 'reactflow'
  4. import {
  5. useNodesReadOnly,
  6. useWorkflow,
  7. } from '../hooks'
  8. import ZoomInOut from './zoom-in-out'
  9. import { OrganizeGrid } from '@/app/components/base/icons/src/vender/line/layout'
  10. import TooltipPlus from '@/app/components/base/tooltip-plus'
  11. const Operator = () => {
  12. const { t } = useTranslation()
  13. const { handleLayout } = useWorkflow()
  14. const {
  15. nodesReadOnly,
  16. getNodesReadOnly,
  17. } = useNodesReadOnly()
  18. const goLayout = () => {
  19. if (getNodesReadOnly())
  20. return
  21. handleLayout()
  22. }
  23. return (
  24. <div className={`
  25. absolute left-6 bottom-6 z-[9]
  26. `}>
  27. <MiniMap
  28. style={{
  29. width: 128,
  30. height: 80,
  31. }}
  32. className='!static !m-0 !w-[128px] !h-[80px] !border-[0.5px] !border-black/[0.08] !rounded-lg !shadow-lg'
  33. />
  34. <div className='flex items-center mt-1 p-0.5 rounded-lg border-[0.5px] border-gray-100 bg-white shadow-lg text-gray-500'>
  35. <ZoomInOut />
  36. <TooltipPlus popupContent={t('workflow.panel.organizeBlocks')}>
  37. <div
  38. className={`
  39. ml-[1px] flex items-center justify-center w-8 h-8 cursor-pointer hover:bg-black/5 rounded-lg
  40. ${nodesReadOnly && '!cursor-not-allowed opacity-50'}
  41. `}
  42. onClick={goLayout}
  43. >
  44. <OrganizeGrid className='w-4 h-4' />
  45. </div>
  46. </TooltipPlus>
  47. </div>
  48. </div>
  49. )
  50. }
  51. export default memo(Operator)