Skip to content

Commit de65646

Browse files
waleedlatif1emir-karabeg
authored andcommitted
feat(workflow-controls): added action bar for picker/hand/undo/redo/zoom workflow controls, added general setting to disable
1 parent fca7751 commit de65646

File tree

3 files changed

+83
-1
lines changed

3 files changed

+83
-1
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/action-bar/action-bar.tsx

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
'use client'
22

33
import { useRef, useState } from 'react'
4+
<<<<<<< HEAD
45
import { createLogger } from '@sim/logger'
56
import { useReactFlow } from 'reactflow'
67
import {
78
Button,
89
ChevronDown,
10+
=======
11+
import { useReactFlow } from 'reactflow'
12+
import {
13+
Button,
14+
>>>>>>> 72ae3be5c (feat(workflow-controls): added action bar for picker/hand/undo/redo/zoom workflow controls, added general setting to disable)
915
Cursor,
1016
Expand,
1117
Hand,
1218
Popover,
1319
PopoverAnchor,
1420
PopoverContent,
1521
PopoverItem,
22+
<<<<<<< HEAD
1623
PopoverTrigger,
24+
=======
25+
>>>>>>> 72ae3be5c (feat(workflow-controls): added action bar for picker/hand/undo/redo/zoom workflow controls, added general setting to disable)
1726
Redo,
1827
Tooltip,
1928
Undo,
@@ -22,19 +31,27 @@ import {
2231
} from '@/components/emcn'
2332
import { useSession } from '@/lib/auth/auth-client'
2433
import { useUpdateGeneralSetting } from '@/hooks/queries/general-settings'
34+
<<<<<<< HEAD
2535
import { useCanvasViewport } from '@/hooks/use-canvas-viewport'
36+
=======
37+
>>>>>>> 72ae3be5c (feat(workflow-controls): added action bar for picker/hand/undo/redo/zoom workflow controls, added general setting to disable)
2638
import { useCollaborativeWorkflow } from '@/hooks/use-collaborative-workflow'
2739
import { useCanvasModeStore } from '@/stores/canvas-mode'
2840
import { useGeneralStore } from '@/stores/settings/general'
2941
import { useUndoRedoStore } from '@/stores/undo-redo'
3042
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
3143

44+
<<<<<<< HEAD
3245
const logger = createLogger('ActionBar')
3346

3447
export function ActionBar() {
3548
const reactFlowInstance = useReactFlow()
3649
const { zoomIn, zoomOut } = reactFlowInstance
3750
const { fitViewToBounds } = useCanvasViewport(reactFlowInstance)
51+
=======
52+
export function ActionBar() {
53+
const { zoomIn, zoomOut, fitView } = useReactFlow()
54+
>>>>>>> 72ae3be5c (feat(workflow-controls): added action bar for picker/hand/undo/redo/zoom workflow controls, added general setting to disable)
3855
const { mode, setMode } = useCanvasModeStore()
3956
const { undo, redo } = useCollaborativeWorkflow()
4057
const showActionBar = useGeneralStore((s) => s.showActionBar)
@@ -50,7 +67,10 @@ export function ActionBar() {
5067
const canRedo = stack.redo.length > 0
5168

5269
const [contextMenu, setContextMenu] = useState<{ x: number; y: number } | null>(null)
70+
<<<<<<< HEAD
5371
const [isCanvasModeOpen, setIsCanvasModeOpen] = useState(false)
72+
=======
73+
>>>>>>> 72ae3be5c (feat(workflow-controls): added action bar for picker/hand/undo/redo/zoom workflow controls, added general setting to disable)
5474
const menuRef = useRef<HTMLDivElement>(null)
5575

5676
const handleContextMenu = (e: React.MouseEvent) => {
@@ -59,13 +79,18 @@ export function ActionBar() {
5979
}
6080

6181
const handleHide = async () => {
82+
<<<<<<< HEAD
6283
try {
6384
await updateSetting.mutateAsync({ key: 'showActionBar', value: false })
6485
} catch (error) {
6586
logger.error('Failed to hide action bar', error)
6687
} finally {
6788
setContextMenu(null)
6889
}
90+
=======
91+
setContextMenu(null)
92+
await updateSetting.mutateAsync({ key: 'showActionBar', value: false })
93+
>>>>>>> 72ae3be5c (feat(workflow-controls): added action bar for picker/hand/undo/redo/zoom workflow controls, added general setting to disable)
6994
}
7095

7196
if (!showActionBar) {
@@ -75,6 +100,7 @@ export function ActionBar() {
75100
return (
76101
<>
77102
<div
103+
<<<<<<< HEAD
78104
className='-translate-x-1/2 fixed bottom-[calc(var(--terminal-height)+16px)] left-[calc((100vw+var(--sidebar-width)-var(--panel-width))/2)] z-10 flex h-[36px] items-center gap-[2px] rounded-[8px] border border-[var(--border)] bg-[var(--surface-1)] p-[4px] shadow-sm transition-[left,bottom] duration-100 ease-out'
79105
onContextMenu={handleContextMenu}
80106
>
@@ -120,14 +146,48 @@ export function ActionBar() {
120146
</PopoverItem>
121147
</PopoverContent>
122148
</Popover>
149+
=======
150+
className='fixed bottom-[calc(var(--terminal-height)+12px)] left-[calc(var(--sidebar-width)+12px)] z-10 flex h-[36px] items-center gap-[2px] rounded-[8px] border border-[var(--border)] bg-[var(--surface-1)] p-[4px] shadow-sm transition-[left,bottom] duration-100 ease-out'
151+
onContextMenu={handleContextMenu}
152+
>
153+
<Tooltip.Root>
154+
<Tooltip.Trigger asChild>
155+
<Button
156+
variant={mode === 'hand' ? 'secondary' : 'ghost'}
157+
className='h-[28px] w-[28px] p-0'
158+
onClick={() => setMode('hand')}
159+
>
160+
<Hand className='h-[16px] w-[16px]' />
161+
</Button>
162+
</Tooltip.Trigger>
163+
<Tooltip.Content side='top'>Hand tool</Tooltip.Content>
164+
</Tooltip.Root>
165+
166+
<Tooltip.Root>
167+
<Tooltip.Trigger asChild>
168+
<Button
169+
variant={mode === 'cursor' ? 'secondary' : 'ghost'}
170+
className='h-[28px] w-[28px] p-0'
171+
onClick={() => setMode('cursor')}
172+
>
173+
<Cursor className='h-[16px] w-[16px]' />
174+
</Button>
175+
</Tooltip.Trigger>
176+
<Tooltip.Content side='top'>Move</Tooltip.Content>
177+
</Tooltip.Root>
178+
>>>>>>> 72ae3be5c (feat(workflow-controls): added action bar for picker/hand/undo/redo/zoom workflow controls, added general setting to disable)
123179

124180
<div className='mx-[4px] h-[20px] w-[1px] bg-[var(--border)]' />
125181

126182
<Tooltip.Root>
127183
<Tooltip.Trigger asChild>
128184
<Button
129185
variant='ghost'
186+
<<<<<<< HEAD
130187
className='h-[28px] w-[28px] rounded-[6px] p-0 hover:bg-[var(--surface-5)]'
188+
=======
189+
className='h-[28px] w-[28px] p-0'
190+
>>>>>>> 72ae3be5c (feat(workflow-controls): added action bar for picker/hand/undo/redo/zoom workflow controls, added general setting to disable)
131191
onClick={undo}
132192
disabled={!canUndo}
133193
>
@@ -143,7 +203,11 @@ export function ActionBar() {
143203
<Tooltip.Trigger asChild>
144204
<Button
145205
variant='ghost'
206+
<<<<<<< HEAD
146207
className='h-[28px] w-[28px] rounded-[6px] p-0 hover:bg-[var(--surface-5)]'
208+
=======
209+
className='h-[28px] w-[28px] p-0'
210+
>>>>>>> 72ae3be5c (feat(workflow-controls): added action bar for picker/hand/undo/redo/zoom workflow controls, added general setting to disable)
147211
onClick={redo}
148212
disabled={!canRedo}
149213
>
@@ -159,11 +223,15 @@ export function ActionBar() {
159223

160224
<Tooltip.Root>
161225
<Tooltip.Trigger asChild>
226+
<<<<<<< HEAD
162227
<Button
163228
variant='ghost'
164229
className='h-[28px] w-[28px] rounded-[6px] p-0 hover:bg-[var(--surface-5)]'
165230
onClick={() => zoomOut()}
166231
>
232+
=======
233+
<Button variant='ghost' className='h-[28px] w-[28px] p-0' onClick={() => zoomOut()}>
234+
>>>>>>> 72ae3be5c (feat(workflow-controls): added action bar for picker/hand/undo/redo/zoom workflow controls, added general setting to disable)
167235
<ZoomOut className='h-[16px] w-[16px]' />
168236
</Button>
169237
</Tooltip.Trigger>
@@ -172,11 +240,15 @@ export function ActionBar() {
172240

173241
<Tooltip.Root>
174242
<Tooltip.Trigger asChild>
243+
<<<<<<< HEAD
175244
<Button
176245
variant='ghost'
177246
className='h-[28px] w-[28px] rounded-[6px] p-0 hover:bg-[var(--surface-5)]'
178247
onClick={() => zoomIn()}
179248
>
249+
=======
250+
<Button variant='ghost' className='h-[28px] w-[28px] p-0' onClick={() => zoomIn()}>
251+
>>>>>>> 72ae3be5c (feat(workflow-controls): added action bar for picker/hand/undo/redo/zoom workflow controls, added general setting to disable)
180252
<ZoomIn className='h-[16px] w-[16px]' />
181253
</Button>
182254
</Tooltip.Trigger>
@@ -187,8 +259,13 @@ export function ActionBar() {
187259
<Tooltip.Trigger asChild>
188260
<Button
189261
variant='ghost'
262+
<<<<<<< HEAD
190263
className='h-[28px] w-[28px] rounded-[6px] p-0 hover:bg-[var(--surface-5)]'
191264
onClick={() => fitViewToBounds({ padding: 0.1, duration: 300 })}
265+
=======
266+
className='h-[28px] w-[28px] p-0'
267+
onClick={() => fitView({ padding: 0.3, duration: 300 })}
268+
>>>>>>> 72ae3be5c (feat(workflow-controls): added action bar for picker/hand/undo/redo/zoom workflow controls, added general setting to disable)
192269
>
193270
<Expand className='h-[16px] w-[16px]' />
194271
</Button>

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/panel.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ export function Panel() {
503503
Editor
504504
</Button>
505505
</div>
506+
<<<<<<< HEAD
506507

507508
{/* Canvas Mode Selector */}
508509
<Popover
@@ -556,6 +557,8 @@ export function Panel() {
556557
</PopoverItem>
557558
</PopoverContent>
558559
</Popover>
560+
=======
561+
>>>>>>> 72ae3be5c (feat(workflow-controls): added action bar for picker/hand/undo/redo/zoom workflow controls, added general setting to disable)
559562
</div>
560563

561564
{/* Tab Content - Keep all tabs mounted but hidden to preserve state */}

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3357,9 +3357,11 @@ const WorkflowContent = React.memo(() => {
33573357
onPointerMove={handleCanvasPointerMove}
33583358
onPointerLeave={handleCanvasPointerLeave}
33593359
elementsSelectable={true}
3360-
selectionOnDrag={!isHandMode}
3360+
selectionOnDrag={!isHandMode || isSelectionDragActive}
33613361
selectionMode={SelectionMode.Partial}
33623362
panOnDrag={isHandMode ? [0, 1] : false}
3363+
onSelectionStart={onSelectionStart}
3364+
onSelectionEnd={onSelectionEnd}
33633365
multiSelectionKeyCode={['Meta', 'Control', 'Shift']}
33643366
nodesConnectable={effectivePermissions.canEdit}
33653367
nodesDraggable={effectivePermissions.canEdit}

0 commit comments

Comments
 (0)