Skip to content

Commit 7caa1f5

Browse files
committed
improvement(preview): staging changes integrated
1 parent c8e9c61 commit 7caa1f5

File tree

2 files changed

+61
-33
lines changed
  • apps
    • docs/app
    • sim/app/workspace/[workspaceId]/w/components/preview/components/preview-workflow/components/block

2 files changed

+61
-33
lines changed

apps/docs/app/global.css

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,16 @@ aside[data-sidebar] > *:not([data-sidebar-viewport]) {
377377
button[aria-label="Toggle Sidebar"],
378378
button[aria-label="Collapse Sidebar"],
379379
/* Hide nav title/logo in sidebar on desktop - target all possible locations */
380+
/* Lower specificity selectors first (attribute selectors) */
381+
[data-sidebar-header],
382+
[data-sidebar] [data-title],
383+
aside[data-sidebar] a[href="/"],
384+
aside[data-sidebar] a[href="/"] img,
385+
aside[data-sidebar] > a:first-child,
386+
aside[data-sidebar] > div > a:first-child,
387+
aside[data-sidebar] img[alt="Sim"],
388+
aside[data-sidebar] svg[aria-label="Sim"],
389+
/* Higher specificity selectors (ID selectors) */
380390
#nd-sidebar
381391
a[href="/"],
382392
#nd-sidebar a[href="/"] img,
@@ -385,14 +395,6 @@ aside[data-sidebar] > *:not([data-sidebar-viewport]) {
385395
#nd-sidebar > div:first-child > a:first-child,
386396
#nd-sidebar img[alt="Sim"],
387397
#nd-sidebar svg[aria-label="Sim"],
388-
aside[data-sidebar] a[href="/"],
389-
aside[data-sidebar] a[href="/"] img,
390-
aside[data-sidebar] > a:first-child,
391-
aside[data-sidebar] > div > a:first-child,
392-
aside[data-sidebar] img[alt="Sim"],
393-
aside[data-sidebar] svg[aria-label="Sim"],
394-
[data-sidebar-header],
395-
[data-sidebar] [data-title],
396398
/* Hide theme toggle at bottom of sidebar on desktop */
397399
#nd-sidebar
398400
> footer,

apps/sim/app/workspace/[workspaceId]/w/components/preview/components/preview-workflow/components/block/block.tsx

Lines changed: 51 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,8 @@ function WorkflowPreviewBlockInner({ data }: NodeProps<WorkflowPreviewBlockData>
278278
const blockConfig = getBlock(type)
279279

280280
const canonicalIndex = useMemo(
281-
() =>
282-
lightweight
283-
? { groupsById: {}, canonicalIdBySubBlockId: {} }
284-
: buildCanonicalIndex(blockConfig?.subBlocks || []),
285-
[blockConfig?.subBlocks, lightweight]
281+
() => buildCanonicalIndex(blockConfig?.subBlocks || []),
282+
[blockConfig?.subBlocks]
286283
)
287284

288285
const rawValues = useMemo(() => {
@@ -294,37 +291,59 @@ function WorkflowPreviewBlockInner({ data }: NodeProps<WorkflowPreviewBlockData>
294291
}, [subBlockValues, lightweight])
295292

296293
const visibleSubBlocks = useMemo(() => {
297-
if (lightweight || !blockConfig?.subBlocks) return []
294+
if (!blockConfig?.subBlocks) return []
298295

299-
const isStarterOrTrigger =
300-
blockConfig.category === 'triggers' || type === 'starter' || isTrigger
296+
const isPureTriggerBlock = blockConfig.triggers?.enabled && blockConfig.category === 'triggers'
297+
const effectiveTrigger = isTrigger || type === 'starter'
301298

302299
return blockConfig.subBlocks.filter((subBlock) => {
303300
if (subBlock.hidden) return false
304301
if (subBlock.hideFromPreview) return false
305302
if (!isSubBlockFeatureEnabled(subBlock)) return false
306-
if (subBlock.mode === 'trigger' && !isStarterOrTrigger) return false
303+
304+
if (effectiveTrigger) {
305+
const isValidTriggerSubblock = isPureTriggerBlock
306+
? subBlock.mode === 'trigger' || !subBlock.mode
307+
: subBlock.mode === 'trigger'
308+
if (!isValidTriggerSubblock) return false
309+
} else {
310+
if (subBlock.mode === 'trigger') return false
311+
}
312+
313+
/** Skip value-dependent visibility checks in lightweight mode */
314+
if (lightweight) return !subBlock.condition
315+
307316
if (!isSubBlockVisibleForMode(subBlock, false, canonicalIndex, rawValues, undefined)) {
308317
return false
309318
}
310319
if (!subBlock.condition) return true
311320
return evaluateSubBlockCondition(subBlock.condition, rawValues)
312321
})
313322
}, [
323+
lightweight,
314324
blockConfig?.subBlocks,
325+
blockConfig?.triggers?.enabled,
315326
blockConfig?.category,
316327
type,
317328
isTrigger,
318329
canonicalIndex,
319330
rawValues,
320-
lightweight,
321331
])
322332

323333
/**
324-
* Compute condition rows for condition blocks
334+
* Compute condition rows for condition blocks.
335+
* In lightweight mode, returns default structure without parsing values.
325336
*/
326337
const conditionRows = useMemo(() => {
327-
if (lightweight || type !== 'condition') return []
338+
if (type !== 'condition') return []
339+
340+
/** Default structure for lightweight mode or when no values */
341+
const defaultRows = [
342+
{ id: 'if', title: 'if', value: '' },
343+
{ id: 'else', title: 'else', value: '' },
344+
]
345+
346+
if (lightweight) return defaultRows
328347

329348
const conditionsValue = rawValues.conditions
330349
const raw = typeof conditionsValue === 'string' ? conditionsValue : undefined
@@ -348,17 +367,20 @@ function WorkflowPreviewBlockInner({ data }: NodeProps<WorkflowPreviewBlockData>
348367
/* empty */
349368
}
350369

351-
return [
352-
{ id: 'if', title: 'if', value: '' },
353-
{ id: 'else', title: 'else', value: '' },
354-
]
370+
return defaultRows
355371
}, [type, rawValues, lightweight])
356372

357373
/**
358-
* Compute router rows for router_v2 blocks
374+
* Compute router rows for router_v2 blocks.
375+
* In lightweight mode, returns default structure without parsing values.
359376
*/
360377
const routerRows = useMemo(() => {
361-
if (lightweight || type !== 'router_v2') return []
378+
if (type !== 'router_v2') return []
379+
380+
/** Default structure for lightweight mode or when no values */
381+
const defaultRows = [{ id: 'route1', value: '' }]
382+
383+
if (lightweight) return defaultRows
362384

363385
const routesValue = rawValues.routes
364386
const raw = typeof routesValue === 'string' ? routesValue : undefined
@@ -380,7 +402,7 @@ function WorkflowPreviewBlockInner({ data }: NodeProps<WorkflowPreviewBlockData>
380402
/* empty */
381403
}
382404

383-
return [{ id: 'route1', value: '' }]
405+
return defaultRows
384406
}, [type, rawValues, lightweight])
385407

386408
if (!blockConfig) {
@@ -457,32 +479,36 @@ function WorkflowPreviewBlockInner({ data }: NodeProps<WorkflowPreviewBlockData>
457479
<div className='flex flex-col gap-[8px] p-[8px]'>
458480
{type === 'condition' ? (
459481
conditionRows.map((cond) => (
460-
<SubBlockRow key={cond.id} title={cond.title} value={getDisplayValue(cond.value)} />
482+
<SubBlockRow
483+
key={cond.id}
484+
title={cond.title}
485+
value={lightweight ? undefined : getDisplayValue(cond.value)}
486+
/>
461487
))
462488
) : type === 'router_v2' ? (
463489
<>
464490
<SubBlockRow
465491
key='context'
466492
title='Context'
467-
value={getDisplayValue(rawValues.context)}
493+
value={lightweight ? undefined : getDisplayValue(rawValues.context)}
468494
/>
469495
{routerRows.map((route, index) => (
470496
<SubBlockRow
471497
key={route.id}
472498
title={`Route ${index + 1}`}
473-
value={getDisplayValue(route.value)}
499+
value={lightweight ? undefined : getDisplayValue(route.value)}
474500
/>
475501
))}
476502
</>
477503
) : (
478504
visibleSubBlocks.map((subBlock) => {
479-
const rawValue = rawValues[subBlock.id]
505+
const rawValue = lightweight ? undefined : rawValues[subBlock.id]
480506
return (
481507
<SubBlockRow
482508
key={subBlock.id}
483509
title={subBlock.title ?? subBlock.id}
484-
value={getDisplayValue(rawValue)}
485-
subBlock={subBlock}
510+
value={lightweight ? undefined : getDisplayValue(rawValue)}
511+
subBlock={lightweight ? undefined : subBlock}
486512
rawValue={rawValue}
487513
/>
488514
)

0 commit comments

Comments
 (0)