Skip to content

Commit 879cdf1

Browse files
committed
cleanup dead sockets adv mode ops
1 parent 95f0f4e commit 879cdf1

File tree

6 files changed

+4
-120
lines changed

6 files changed

+4
-120
lines changed

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

Lines changed: 4 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
'use client'
22

33
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
4-
import { BookOpen, Check, ChevronDown, ChevronUp, Pencil } from 'lucide-react'
4+
import { BookOpen, Check, ChevronUp, Pencil } from 'lucide-react'
55
import { Button, Tooltip } from '@/components/emcn'
6-
import { cn } from '@/lib/core/utils/cn'
76
import {
87
buildCanonicalIndex,
98
hasAdvancedValues,
@@ -106,18 +105,7 @@ export function Editor() {
106105
blockSubBlockValues,
107106
canonicalIndex
108107
)
109-
const displayAdvancedOptions = userPermissions.canEdit
110-
? advancedMode
111-
: advancedMode || advancedValuesPresent
112-
const hasAdvancedOnlyFields = useMemo(() => {
113-
if (!blockConfig?.subBlocks) return false
114-
return blockConfig.subBlocks.some((subBlock) => {
115-
if (subBlock.mode !== 'advanced') return false
116-
const canonicalId = canonicalIndex.canonicalIdBySubBlockId[subBlock.id]
117-
const group = canonicalId ? canonicalIndex.groupsById[canonicalId] : undefined
118-
return !isCanonicalPair(group)
119-
})
120-
}, [blockConfig?.subBlocks, canonicalIndex])
108+
const displayAdvancedOptions = advancedMode || advancedValuesPresent
121109

122110
// Get subblock layout using custom hook
123111
const { subBlocks, stateToUse: subBlockState } = useEditorSubblockLayout(
@@ -139,24 +127,14 @@ export function Editor() {
139127
})
140128

141129
// Collaborative actions
142-
const {
143-
collaborativeToggleBlockAdvancedMode,
144-
collaborativeSetBlockCanonicalMode,
145-
collaborativeUpdateBlockName,
146-
} = useCollaborativeWorkflow()
130+
const { collaborativeSetBlockCanonicalMode, collaborativeUpdateBlockName } =
131+
useCollaborativeWorkflow()
147132

148133
// Rename state
149134
const [isRenaming, setIsRenaming] = useState(false)
150135
const [editedName, setEditedName] = useState('')
151136
const nameInputRef = useRef<HTMLInputElement>(null)
152137

153-
// Mode toggle handlers
154-
const handleToggleAdvancedMode = useCallback(() => {
155-
if (currentBlockId && userPermissions.canEdit) {
156-
collaborativeToggleBlockAdvancedMode(currentBlockId)
157-
}
158-
}, [currentBlockId, userPermissions.canEdit, collaborativeToggleBlockAdvancedMode])
159-
160138
/**
161139
* Handles starting the rename process.
162140
*/
@@ -216,26 +194,6 @@ export function Editor() {
216194
}
217195
}
218196

219-
const hasAdvancedMode = hasAdvancedOnlyFields
220-
221-
const autoExpandedBlocksRef = useRef<Set<string>>(new Set())
222-
223-
useEffect(() => {
224-
if (!currentBlockId || !userPermissions.canEdit) return
225-
if (!advancedValuesPresent) return
226-
if (advancedMode) return
227-
if (autoExpandedBlocksRef.current.has(currentBlockId)) return
228-
229-
autoExpandedBlocksRef.current.add(currentBlockId)
230-
collaborativeToggleBlockAdvancedMode(currentBlockId)
231-
}, [
232-
advancedMode,
233-
advancedValuesPresent,
234-
collaborativeToggleBlockAdvancedMode,
235-
currentBlockId,
236-
userPermissions.canEdit,
237-
])
238-
239197
// Determine if connections are at minimum height (collapsed state)
240198
const isConnectionsAtMinHeight = connectionsHeight <= 35
241199

@@ -448,33 +406,6 @@ export function Editor() {
448406
</div>
449407
</div>
450408

451-
{hasAdvancedMode && (
452-
<div className='flex flex-shrink-0 items-center border-[var(--border)] border-t px-[8px] py-[6px]'>
453-
<Button
454-
variant='ghost'
455-
className='flex h-[24px] w-full items-center justify-between px-[6px] text-[13px]'
456-
onClick={handleToggleAdvancedMode}
457-
disabled={!userPermissions.canEdit}
458-
aria-label='Toggle advanced options'
459-
>
460-
<div className='flex items-center gap-[6px]'>
461-
<span className='text-[var(--text-primary)]'>
462-
{displayAdvancedOptions ? 'Hide advanced options' : 'Show advanced options'}
463-
</span>
464-
{advancedValuesPresent && (
465-
<span className='h-[6px] w-[6px] rounded-full bg-[var(--brand-9)]' />
466-
)}
467-
</div>
468-
<ChevronDown
469-
className={cn(
470-
'h-[14px] w-[14px] transition-transform',
471-
displayAdvancedOptions && 'rotate-180'
472-
)}
473-
/>
474-
</Button>
475-
</div>
476-
)}
477-
478409
{/* Connections Section - Only show when there are connections */}
479410
{hasIncomingConnections && (
480411
<div

apps/sim/hooks/use-collaborative-workflow.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,6 @@ export function useCollaborativeWorkflow() {
200200
case BLOCK_OPERATIONS.UPDATE_NAME:
201201
workflowStore.updateBlockName(payload.id, payload.name)
202202
break
203-
case BLOCK_OPERATIONS.UPDATE_ADVANCED_MODE:
204-
workflowStore.setBlockAdvancedMode(payload.id, payload.advancedMode)
205-
break
206203
case BLOCK_OPERATIONS.UPDATE_CANONICAL_MODE:
207204
workflowStore.setBlockCanonicalMode(
208205
payload.id,
@@ -923,23 +920,6 @@ export function useCollaborativeWorkflow() {
923920
[isInActiveRoom, workflowStore, undoRedo, addToQueue, activeWorkflowId, session?.user?.id]
924921
)
925922

926-
const collaborativeToggleBlockAdvancedMode = useCallback(
927-
(id: string) => {
928-
const currentBlock = workflowStore.blocks[id]
929-
if (!currentBlock) return
930-
931-
const newAdvancedMode = !currentBlock.advancedMode
932-
933-
executeQueuedOperation(
934-
BLOCK_OPERATIONS.UPDATE_ADVANCED_MODE,
935-
OPERATION_TARGETS.BLOCK,
936-
{ id, advancedMode: newAdvancedMode },
937-
() => workflowStore.toggleBlockAdvancedMode(id)
938-
)
939-
},
940-
[executeQueuedOperation, workflowStore]
941-
)
942-
943923
const collaborativeSetBlockCanonicalMode = useCallback(
944924
(id: string, canonicalId: string, canonicalMode: 'basic' | 'advanced') => {
945925
executeQueuedOperation(
@@ -1625,7 +1605,6 @@ export function useCollaborativeWorkflow() {
16251605
collaborativeUpdateBlockName,
16261606
collaborativeBatchToggleBlockEnabled,
16271607
collaborativeBatchUpdateParent,
1628-
collaborativeToggleBlockAdvancedMode,
16291608
collaborativeSetBlockCanonicalMode,
16301609
collaborativeBatchToggleBlockHandles,
16311610
collaborativeBatchAddBlocks,

apps/sim/socket/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ export const BLOCK_OPERATIONS = {
33
UPDATE_NAME: 'update-name',
44
TOGGLE_ENABLED: 'toggle-enabled',
55
UPDATE_PARENT: 'update-parent',
6-
UPDATE_ADVANCED_MODE: 'update-advanced-mode',
76
UPDATE_CANONICAL_MODE: 'update-canonical-mode',
87
TOGGLE_HANDLES: 'toggle-handles',
98
} as const

apps/sim/socket/database/operations.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -376,28 +376,6 @@ async function handleBlockOperationTx(
376376
break
377377
}
378378

379-
case BLOCK_OPERATIONS.UPDATE_ADVANCED_MODE: {
380-
if (!payload.id || payload.advancedMode === undefined) {
381-
throw new Error('Missing required fields for update advanced mode operation')
382-
}
383-
384-
const updateResult = await tx
385-
.update(workflowBlocks)
386-
.set({
387-
advancedMode: payload.advancedMode,
388-
updatedAt: new Date(),
389-
})
390-
.where(and(eq(workflowBlocks.id, payload.id), eq(workflowBlocks.workflowId, workflowId)))
391-
.returning({ id: workflowBlocks.id })
392-
393-
if (updateResult.length === 0) {
394-
throw new Error(`Block ${payload.id} not found in workflow ${workflowId}`)
395-
}
396-
397-
logger.debug(`Updated block advanced mode: ${payload.id} -> ${payload.advancedMode}`)
398-
break
399-
}
400-
401379
case BLOCK_OPERATIONS.UPDATE_CANONICAL_MODE: {
402380
if (!payload.id || !payload.canonicalId || !payload.canonicalMode) {
403381
throw new Error('Missing required fields for update canonical mode operation')

apps/sim/socket/middleware/permissions.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const WRITE_OPERATIONS: string[] = [
2121
BLOCK_OPERATIONS.UPDATE_NAME,
2222
BLOCK_OPERATIONS.TOGGLE_ENABLED,
2323
BLOCK_OPERATIONS.UPDATE_PARENT,
24-
BLOCK_OPERATIONS.UPDATE_ADVANCED_MODE,
2524
BLOCK_OPERATIONS.UPDATE_CANONICAL_MODE,
2625
BLOCK_OPERATIONS.TOGGLE_HANDLES,
2726
// Batch block operations

apps/sim/socket/validation/schemas.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export const BlockOperationSchema = z.object({
3030
BLOCK_OPERATIONS.UPDATE_NAME,
3131
BLOCK_OPERATIONS.TOGGLE_ENABLED,
3232
BLOCK_OPERATIONS.UPDATE_PARENT,
33-
BLOCK_OPERATIONS.UPDATE_ADVANCED_MODE,
3433
BLOCK_OPERATIONS.UPDATE_CANONICAL_MODE,
3534
BLOCK_OPERATIONS.TOGGLE_HANDLES,
3635
]),
@@ -48,7 +47,6 @@ export const BlockOperationSchema = z.object({
4847
extent: z.enum(['parent']).nullable().optional(),
4948
enabled: z.boolean().optional(),
5049
horizontalHandles: z.boolean().optional(),
51-
advancedMode: z.boolean().optional(),
5250
canonicalId: z.string().optional(),
5351
canonicalMode: z.enum(['basic', 'advanced']).optional(),
5452
triggerMode: z.boolean().optional(),

0 commit comments

Comments
 (0)