Skip to content

Commit e321f88

Browse files
authored
improvement(preview): added trigger mode context for deploy preview (#3177)
* improvement(preview): added trigger mode context for deploy preview * use existing helper * enhance disabled mode for subblocks * update * update all subblocks to allow scrolling in read only mode * updated short and long input to match others, reverted triggerutils change
1 parent 8b4b3af commit e321f88

File tree

10 files changed

+52
-15
lines changed

10 files changed

+52
-15
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/document-tag-entry/document-tag-entry.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,10 @@ export function DocumentTagEntry({
324324
ref={(el) => {
325325
if (el) overlayRefs.current[cellKey] = el
326326
}}
327-
className='pointer-events-none absolute inset-0 flex items-center overflow-x-auto bg-transparent px-[8px] py-[6px] font-medium font-sans text-sm'
327+
className={cn(
328+
'absolute inset-0 flex items-center overflow-x-auto bg-transparent px-[8px] py-[6px] font-medium font-sans text-sm',
329+
!isReadOnly && 'pointer-events-none'
330+
)}
328331
>
329332
<div className='w-full whitespace-pre' style={{ minWidth: 'fit-content' }}>
330333
{formatDisplayText(

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/eval-input/eval-input.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,10 @@ export function EvalInput({
226226
ref={(el) => {
227227
if (el) descriptionOverlayRefs.current[metric.id] = el
228228
}}
229-
className='pointer-events-none absolute inset-0 overflow-auto bg-transparent px-[8px] py-[8px] font-medium font-sans text-[#eeeeee] text-sm'
229+
className={cn(
230+
'absolute inset-0 overflow-auto bg-transparent px-[8px] py-[8px] font-medium font-sans text-[#eeeeee] text-sm',
231+
!(isPreview || disabled) && 'pointer-events-none'
232+
)}
230233
>
231234
<div className='whitespace-pre-wrap'>
232235
{formatDisplayText(metric.description || '', {

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/input-mapping/input-mapping.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,10 @@ function InputMappingField({
273273
ref={(el) => {
274274
if (el) overlayRefs.current.set(fieldId, el)
275275
}}
276-
className='pointer-events-none absolute inset-0 flex items-center overflow-x-auto bg-transparent px-[8px] py-[6px] font-medium font-sans text-sm'
276+
className={cn(
277+
'absolute inset-0 flex items-center overflow-x-auto bg-transparent px-[8px] py-[6px] font-medium font-sans text-sm',
278+
!disabled && 'pointer-events-none'
279+
)}
277280
style={{ overflowX: 'auto' }}
278281
>
279282
<div

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/knowledge-tag-filters/knowledge-tag-filters.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,10 @@ export function KnowledgeTagFilters({
312312
ref={(el) => {
313313
if (el) overlayRefs.current[cellKey] = el
314314
}}
315-
className='pointer-events-none absolute inset-0 flex items-center overflow-x-auto bg-transparent px-[8px] py-[6px] font-medium font-sans text-sm'
315+
className={cn(
316+
'absolute inset-0 flex items-center overflow-x-auto bg-transparent px-[8px] py-[6px] font-medium font-sans text-sm',
317+
!isReadOnly && 'pointer-events-none'
318+
)}
316319
>
317320
<div className='w-full whitespace-pre' style={{ minWidth: 'fit-content' }}>
318321
{formatDisplayText(

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/long-input/long-input.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,9 @@ export function LongInput({
353353
<div
354354
ref={overlayRef}
355355
className={cn(
356-
'pointer-events-none absolute inset-0 box-border overflow-auto whitespace-pre-wrap break-words border border-transparent bg-transparent px-[8px] py-[8px] font-medium font-sans text-sm',
357-
(isPreview || disabled) && 'opacity-50'
356+
'absolute inset-0 box-border overflow-auto whitespace-pre-wrap break-words border border-transparent bg-transparent px-[8px] py-[8px] font-medium font-sans text-sm',
357+
(isPreview || disabled) && 'opacity-50',
358+
!(isPreview || disabled) && 'pointer-events-none'
358359
)}
359360
style={{
360361
fontFamily: 'inherit',

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/messages-input/messages-input.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,10 @@ export function MessagesInput({
719719
ref={(el) => {
720720
overlayRefs.current[fieldId] = el
721721
}}
722-
className='pointer-events-none absolute top-0 left-0 z-[1] m-0 box-border w-full overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words border-none bg-transparent px-[8px] py-[8px] font-medium font-sans text-[var(--text-primary)] text-sm leading-[1.5] [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden'
722+
className={cn(
723+
'absolute top-0 left-0 z-[1] m-0 box-border w-full overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words border-none bg-transparent px-[8px] py-[8px] font-medium font-sans text-[var(--text-primary)] text-sm leading-[1.5] [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden',
724+
!(isPreview || disabled) && 'pointer-events-none'
725+
)}
723726
>
724727
{formatDisplayText(message.content, {
725728
accessiblePrefixes,

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/short-input/short-input.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,9 @@ export const ShortInput = memo(function ShortInput({
372372
<div
373373
ref={overlayRef}
374374
className={cn(
375-
'pointer-events-none absolute inset-0 flex items-center overflow-x-auto bg-transparent px-[8px] py-[6px] pr-3 font-medium font-sans text-foreground text-sm [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden',
376-
(isPreview || disabled) && 'opacity-50'
375+
'absolute inset-0 flex items-center overflow-x-auto bg-transparent px-[8px] py-[6px] pr-3 font-medium font-sans text-foreground text-sm [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden',
376+
(isPreview || disabled) && 'opacity-50',
377+
!(isPreview || disabled) && 'pointer-events-none'
377378
)}
378379
>
379380
<div className='min-w-fit whitespace-pre'>{formattedText}</div>

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/starter/input-format.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,10 @@ export function FieldFormat({
269269
ref={(el) => {
270270
if (el) nameOverlayRefs.current[field.id] = el
271271
}}
272-
className='pointer-events-none absolute inset-0 flex items-center overflow-x-auto bg-transparent px-[8px] py-[6px] font-medium font-sans text-sm'
272+
className={cn(
273+
'absolute inset-0 flex items-center overflow-x-auto bg-transparent px-[8px] py-[6px] font-medium font-sans text-sm',
274+
!isReadOnly && 'pointer-events-none'
275+
)}
273276
style={{ scrollbarWidth: 'none' }}
274277
>
275278
<div
@@ -514,7 +517,10 @@ export function FieldFormat({
514517
ref={(el) => {
515518
if (el) overlayRefs.current[field.id] = el
516519
}}
517-
className='pointer-events-none absolute inset-0 flex items-center overflow-x-auto bg-transparent px-[8px] py-[6px] font-medium font-sans text-sm'
520+
className={cn(
521+
'absolute inset-0 flex items-center overflow-x-auto bg-transparent px-[8px] py-[6px] font-medium font-sans text-sm',
522+
!isReadOnly && 'pointer-events-none'
523+
)}
518524
style={{ scrollbarWidth: 'none' }}
519525
>
520526
<div

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/variables-input/variables-input.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,10 @@ export function VariablesInput({
452452
ref={(el) => {
453453
if (el) overlayRefs.current[assignment.id] = el
454454
}}
455-
className='pointer-events-none absolute inset-0 flex items-start overflow-auto bg-transparent px-3 py-2 font-mono text-sm'
455+
className={cn(
456+
'absolute inset-0 flex items-start overflow-auto bg-transparent px-3 py-2 font-mono text-sm',
457+
!isReadOnly && 'pointer-events-none'
458+
)}
456459
style={{ scrollbarWidth: 'none' }}
457460
>
458461
<div className='w-full whitespace-pre-wrap break-words'>
@@ -514,7 +517,10 @@ export function VariablesInput({
514517
ref={(el) => {
515518
if (el) overlayRefs.current[assignment.id] = el
516519
}}
517-
className='pointer-events-none absolute inset-0 flex items-center overflow-x-auto bg-transparent px-[8px] py-[6px] font-medium font-sans text-sm'
520+
className={cn(
521+
'absolute inset-0 flex items-center overflow-x-auto bg-transparent px-[8px] py-[6px] font-medium font-sans text-sm',
522+
!isReadOnly && 'pointer-events-none'
523+
)}
518524
style={{ scrollbarWidth: 'none' }}
519525
>
520526
<div

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import { PreviewContextMenu } from '@/app/workspace/[workspaceId]/w/components/p
4343
import { PreviewWorkflow } from '@/app/workspace/[workspaceId]/w/components/preview/components/preview-workflow'
4444
import { useContextMenu } from '@/app/workspace/[workspaceId]/w/components/sidebar/hooks'
4545
import { getBlock } from '@/blocks'
46-
import type { BlockConfig, BlockIcon, SubBlockConfig } from '@/blocks/types'
46+
import type { BlockConfig, BlockIcon, SubBlockConfig, SubBlockType } from '@/blocks/types'
4747
import { normalizeName } from '@/executor/constants'
4848
import { navigatePath } from '@/executor/variables/resolvers/reference'
4949
import { useWorkflowState } from '@/hooks/queries/workflows'
@@ -1140,9 +1140,17 @@ function PreviewEditorContent({
11401140
(block.advancedMode ?? false) ||
11411141
hasAdvancedValues(blockConfig.subBlocks, rawValues, canonicalIndex)
11421142

1143+
const isPureTriggerBlock = blockConfig.triggers?.enabled && blockConfig.category === 'triggers'
1144+
const effectiveTrigger = block.triggerMode === true
1145+
11431146
const visibleSubBlocks = blockConfig.subBlocks.filter((subBlock) => {
11441147
if (subBlock.hidden || subBlock.hideFromPreview) return false
1145-
if (subBlock.mode === 'trigger' && blockConfig.category !== 'triggers') return false
1148+
1149+
if (subBlock.type === ('trigger-config' as SubBlockType)) {
1150+
return effectiveTrigger || isPureTriggerBlock
1151+
}
1152+
if (subBlock.mode === 'trigger' && !effectiveTrigger) return false
1153+
if (effectiveTrigger && subBlock.mode !== 'trigger') return false
11461154
if (!isSubBlockFeatureEnabled(subBlock)) return false
11471155
if (
11481156
!isSubBlockVisibleForMode(

0 commit comments

Comments
 (0)