diff --git a/web/app/components/workflow/operator/index.tsx b/web/app/components/workflow/operator/index.tsx index 1100a7a905..544d088022 100644 --- a/web/app/components/workflow/operator/index.tsx +++ b/web/app/components/workflow/operator/index.tsx @@ -1,4 +1,4 @@ -import { memo, useEffect, useMemo, useRef } from 'react' +import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react' import { MiniMap } from 'reactflow' import UndoRedo from '../header/undo-redo' import ZoomInOut from './zoom-in-out' @@ -13,6 +13,12 @@ export type OperatorProps = { const Operator = ({ handleUndo, handleRedo }: OperatorProps) => { const bottomPanelRef = useRef(null) + const [showMiniMap, setShowMiniMap] = useState(true) + + const handleToggleMiniMap = useCallback(() => { + setShowMiniMap(prev => !prev) + }, []) + const workflowCanvasWidth = useStore(s => s.workflowCanvasWidth) const rightPanelWidth = useStore(s => s.rightPanelWidth) const setBottomPanelWidth = useStore(s => s.setBottomPanelWidth) @@ -57,18 +63,23 @@ const Operator = ({ handleUndo, handleRedo }: OperatorProps) => {
- + )} + -
diff --git a/web/app/components/workflow/operator/zoom-in-out.tsx b/web/app/components/workflow/operator/zoom-in-out.tsx index 19d8eef463..b1ad1065e9 100644 --- a/web/app/components/workflow/operator/zoom-in-out.tsx +++ b/web/app/components/workflow/operator/zoom-in-out.tsx @@ -6,6 +6,7 @@ import { useState, } from 'react' import { + RiCheckLine, RiZoomInLine, RiZoomOutLine, } from '@remixicon/react' @@ -38,9 +39,18 @@ enum ZoomType { zoomTo75 = 'zoomTo75', zoomTo100 = 'zoomTo100', zoomTo200 = 'zoomTo200', + toggleMiniMap = 'toggleMiniMap', } -const ZoomInOut: FC = () => { +type ZoomInOutProps = { + showMiniMap?: boolean + onToggleMiniMap?: () => void +} + +const ZoomInOut: FC = ({ + showMiniMap = true, + onToggleMiniMap, +}) => { const { t } = useTranslation() const { zoomIn, @@ -78,13 +88,17 @@ const ZoomInOut: FC = () => { key: ZoomType.zoomTo25, text: '25%', }, - ], - [ { key: ZoomType.zoomToFit, text: t('workflow.operator.zoomToFit'), }, ], + [ + { + key: ZoomType.toggleMiniMap, + text: t('workflow.operator.showMiniMap'), + }, + ], ] const handleZoom = (type: string) => { @@ -109,6 +123,11 @@ const ZoomInOut: FC = () => { if (type === ZoomType.zoomTo200) zoomTo(2) + if (type === ZoomType.toggleMiniMap) { + onToggleMiniMap?.() + return + } + handleSyncWorkflowDraft() } @@ -178,7 +197,7 @@ const ZoomInOut: FC = () => { -
+
{ ZOOM_IN_OUT_OPTIONS.map((options, i) => ( @@ -195,7 +214,15 @@ const ZoomInOut: FC = () => { className='system-md-regular flex h-8 cursor-pointer items-center justify-between space-x-1 rounded-lg py-1.5 pl-3 pr-2 text-text-secondary hover:bg-state-base-hover' onClick={() => handleZoom(option.key)} > - {option.text} +
+ {option.key === ZoomType.toggleMiniMap && showMiniMap && ( + + )} + {option.key === ZoomType.toggleMiniMap && !showMiniMap && ( +
+ )} + {option.text} +
{ option.key === ZoomType.zoomToFit && ( diff --git a/web/i18n/en-US/workflow.ts b/web/i18n/en-US/workflow.ts index 542f4a9a0d..35d6001969 100644 --- a/web/i18n/en-US/workflow.ts +++ b/web/i18n/en-US/workflow.ts @@ -326,6 +326,7 @@ const translation = { zoomTo50: 'Zoom to 50%', zoomTo100: 'Zoom to 100%', zoomToFit: 'Zoom to Fit', + showMiniMap: 'Minimap', alignNodes: 'Align Nodes', alignLeft: 'Left', alignCenter: 'Center',