Skip to content

Commit 57a9a3a

Browse files
author
aadamgough
committed
added larger live deployment preview
1 parent 400178a commit 57a9a3a

File tree

6 files changed

+410
-9
lines changed

6 files changed

+410
-9
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/components/deploy-modal/components/general/general.tsx

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
44
import { createLogger } from '@sim/logger'
5+
import { Maximize2 } from 'lucide-react'
56
import {
67
Button,
78
Label,
@@ -13,6 +14,7 @@ import {
1314
} from '@/components/emcn'
1415
import { Skeleton } from '@/components/ui'
1516
import type { WorkflowDeploymentVersionResponse } from '@/lib/workflows/persistence/utils'
17+
import { ExpandedWorkflowPreview } from '@/app/workspace/[workspaceId]/w/components/workflow-preview/components'
1618
import { WorkflowPreview } from '@/app/workspace/[workspaceId]/w/components/workflow-preview/workflow-preview'
1719
import type { WorkflowState } from '@/stores/workflows/workflow/types'
1820
import { Versions } from './components'
@@ -49,6 +51,7 @@ export function GeneralDeploy({
4951
const [previewMode, setPreviewMode] = useState<PreviewMode>('active')
5052
const [showLoadDialog, setShowLoadDialog] = useState(false)
5153
const [showPromoteDialog, setShowPromoteDialog] = useState(false)
54+
const [showExpandedPreview, setShowExpandedPreview] = useState(false)
5255
const [versionToLoad, setVersionToLoad] = useState<number | null>(null)
5356
const [versionToPromote, setVersionToPromote] = useState<number | null>(null)
5457

@@ -219,15 +222,25 @@ export function GeneralDeploy({
219222
}}
220223
>
221224
{workflowToShow ? (
222-
<WorkflowPreview
223-
workflowState={workflowToShow}
224-
showSubBlocks={true}
225-
height='100%'
226-
width='100%'
227-
isPannable={true}
228-
defaultPosition={{ x: 0, y: 0 }}
229-
defaultZoom={0.6}
230-
/>
225+
<>
226+
<WorkflowPreview
227+
workflowState={workflowToShow}
228+
showSubBlocks={true}
229+
height='100%'
230+
width='100%'
231+
isPannable={true}
232+
defaultPosition={{ x: 0, y: 0 }}
233+
defaultZoom={0.6}
234+
/>
235+
<button
236+
type='button'
237+
onClick={() => setShowExpandedPreview(true)}
238+
className='absolute top-[8px] right-[8px] z-10 rounded-[4px] bg-[var(--surface-1)] p-[6px] text-[var(--text-secondary)] shadow-sm transition-colors hover:bg-[var(--surface-3)] hover:text-[var(--text-primary)]'
239+
title='Expand preview'
240+
>
241+
<Maximize2 className='h-[14px] w-[14px]' />
242+
</button>
243+
</>
231244
) : (
232245
<div className='flex h-full items-center justify-center text-[#8D8D8D] text-[13px]'>
233246
Deploy your workflow to see a preview
@@ -304,6 +317,19 @@ export function GeneralDeploy({
304317
</ModalFooter>
305318
</ModalContent>
306319
</Modal>
320+
321+
{workflowToShow && (
322+
<ExpandedWorkflowPreview
323+
isOpen={showExpandedPreview}
324+
onClose={() => setShowExpandedPreview(false)}
325+
workflowState={workflowToShow}
326+
title={
327+
previewMode === 'selected' && selectedVersionInfo
328+
? selectedVersionInfo.name || `v${selectedVersion}`
329+
: 'Live Workflow'
330+
}
331+
/>
332+
)}
307333
</>
308334
)
309335
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
'use client'
2+
3+
import { useState } from 'react'
4+
import { Modal, ModalBody, ModalContent, ModalHeader } from '@/components/emcn'
5+
import { PinnedSubBlocks } from '@/app/workspace/[workspaceId]/w/components/workflow-preview/components/pinned-sub-blocks'
6+
import { WorkflowPreview } from '@/app/workspace/[workspaceId]/w/components/workflow-preview/workflow-preview'
7+
import type { WorkflowState } from '@/stores/workflows/workflow/types'
8+
9+
interface ExpandedWorkflowPreviewProps {
10+
/** Whether the modal is open */
11+
isOpen: boolean
12+
/** Callback when closing the modal */
13+
onClose: () => void
14+
/** The workflow state to display */
15+
workflowState: WorkflowState
16+
/** Title for the modal header */
17+
title?: string
18+
}
19+
20+
/**
21+
* Expanded workflow preview modal with clickable blocks.
22+
* Shows the workflow preview at full size with a pinned panel
23+
* displaying subblock values when a block is clicked.
24+
*/
25+
export function ExpandedWorkflowPreview({
26+
isOpen,
27+
onClose,
28+
workflowState,
29+
title = 'Workflow Preview',
30+
}: ExpandedWorkflowPreviewProps) {
31+
const [selectedBlockId, setSelectedBlockId] = useState<string | null>(null)
32+
33+
const selectedBlock = selectedBlockId ? workflowState.blocks?.[selectedBlockId] : null
34+
35+
const handleNodeClick = (blockId: string) => {
36+
// Toggle selection if clicking the same block
37+
if (selectedBlockId === blockId) {
38+
setSelectedBlockId(null)
39+
} else {
40+
setSelectedBlockId(blockId)
41+
}
42+
}
43+
44+
const handleClose = () => {
45+
setSelectedBlockId(null)
46+
onClose()
47+
}
48+
49+
const handleClosePanel = () => {
50+
setSelectedBlockId(null)
51+
}
52+
53+
return (
54+
<Modal open={isOpen} onOpenChange={handleClose}>
55+
<ModalContent size='full' className='flex h-[90vh] flex-col'>
56+
<ModalHeader>{title}</ModalHeader>
57+
58+
<ModalBody className='!p-0 relative min-h-0 flex-1'>
59+
<div className='h-full w-full overflow-hidden rounded-[4px] border border-[var(--border)]'>
60+
<WorkflowPreview
61+
workflowState={workflowState}
62+
showSubBlocks={true}
63+
isPannable={true}
64+
defaultPosition={{ x: 0, y: 0 }}
65+
defaultZoom={0.8}
66+
onNodeClick={handleNodeClick}
67+
cursorStyle='pointer'
68+
/>
69+
</div>
70+
71+
{selectedBlock && <PinnedSubBlocks block={selectedBlock} onClose={handleClosePanel} />}
72+
</ModalBody>
73+
</ModalContent>
74+
</Modal>
75+
)
76+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { ExpandedWorkflowPreview } from './expanded-preview'
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { ExpandedWorkflowPreview } from './expanded-preview'
2+
export { PinnedSubBlocks } from './pinned-sub-blocks'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { PinnedSubBlocks } from './pinned-sub-blocks'

0 commit comments

Comments
 (0)