Skip to content

Commit d97641d

Browse files
committed
fix(marketplace): rollback open workflow on view mode
1 parent e6bf5cf commit d97641d

File tree

4 files changed

+7
-84
lines changed

4 files changed

+7
-84
lines changed

sim/app/w/[id]/workflow.tsx

Lines changed: 4 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ function WorkflowContent() {
4343
// State
4444
const [selectedEdgeId, setSelectedEdgeId] = useState<string | null>(null)
4545
const [isInitialized, setIsInitialized] = useState(false)
46-
const [isPublicWorkflow, setIsPublicWorkflow] = useState(false)
47-
const [publicWorkflowData, setPublicWorkflowData] = useState<any>(null)
48-
const [loadingPublicWorkflow, setLoadingPublicWorkflow] = useState(false)
4946

5047
// Hooks
5148
const params = useParams()
@@ -54,16 +51,8 @@ function WorkflowContent() {
5451

5552
// Store access
5653
const { workflows, setActiveWorkflow, createWorkflow } = useWorkflowRegistry()
57-
const {
58-
blocks,
59-
edges,
60-
loops,
61-
addBlock,
62-
updateBlockPosition,
63-
addEdge,
64-
removeEdge,
65-
initializeWorkflow,
66-
} = useWorkflowStore()
54+
const { blocks, edges, loops, addBlock, updateBlockPosition, addEdge, removeEdge } =
55+
useWorkflowStore()
6756
const { setValue: setSubBlockValue } = useSubBlockStore()
6857
const { markAllAsRead } = useNotificationStore()
6958
const { resetLoaded: resetVariablesLoaded } = useVariablesStore()
@@ -162,47 +151,9 @@ function WorkflowContent() {
162151
return
163152
}
164153

165-
// Check if the workflow is in the user's registry
166154
if (!workflows[currentId]) {
167-
// If not in registry, try to load it as a public workflow
168-
setLoadingPublicWorkflow(true)
169-
try {
170-
const response = await fetch(`/api/workflows/public/${currentId}`)
171-
172-
if (response.ok) {
173-
// Workflow exists and is public
174-
const data = await response.json()
175-
setPublicWorkflowData(data.data)
176-
setIsPublicWorkflow(true)
177-
178-
// Initialize the workflow store with the public workflow state
179-
if (data.data?.state) {
180-
const { blocks, edges, loops } = data.data.state
181-
initializeWorkflow(blocks || {}, edges || [], loops || {})
182-
183-
// Initialize subblock store with workflow values
184-
if (blocks) {
185-
useSubBlockStore.getState().initializeFromWorkflow(currentId, blocks)
186-
}
187-
}
188-
setLoadingPublicWorkflow(false)
189-
return
190-
} else if (response.status === 403) {
191-
// Workflow exists but is not public, redirect to first workflow
192-
router.replace(`/w/${workflowIds[0]}`)
193-
return
194-
} else {
195-
// Workflow doesn't exist, redirect to first workflow
196-
router.replace(`/w/${workflowIds[0]}`)
197-
return
198-
}
199-
} catch (error) {
200-
console.error('Error loading public workflow:', error)
201-
router.replace(`/w/${workflowIds[0]}`)
202-
return
203-
} finally {
204-
setLoadingPublicWorkflow(false)
205-
}
155+
router.replace(`/w/${workflowIds[0]}`)
156+
return
206157
}
207158

208159
// Import the isActivelyLoadingFromDB function to check sync status
@@ -239,7 +190,6 @@ function WorkflowContent() {
239190
isInitialized,
240191
markAllAsRead,
241192
resetVariablesLoaded,
242-
initializeWorkflow,
243193
])
244194

245195
// Transform blocks and loops into ReactFlow nodes

sim/app/w/marketplace/components/workflow-card.tsx

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use client'
22

33
import { useEffect, useState } from 'react'
4-
import Link from 'next/link'
54
import { Eye, Star } from 'lucide-react'
65
import { Card, CardContent, CardFooter, CardHeader } from '@/components/ui/card'
76
import { Workflow } from '../marketplace'
@@ -61,18 +60,10 @@ export function WorkflowCard({ workflow, onHover }: WorkflowCardProps) {
6160
}
6261
}
6362

64-
// Extract the actual workflow ID from workflow
65-
const workflowUrl = workflow.workflowUrl || `/w/${workflow.id}`
66-
6763
return (
68-
<Link
69-
href={workflowUrl}
70-
className="block"
71-
aria-label={`View ${workflow.name} workflow`}
72-
onClick={handleClick}
73-
>
64+
<div className="block" aria-label={`View ${workflow.name} workflow`} onClick={handleClick}>
7465
<Card
75-
className="overflow-hidden transition-all hover:shadow-md flex flex-col h-full"
66+
className="overflow-hidden transition-all hover:shadow-md flex flex-col h-full cursor-pointer"
7667
onMouseEnter={handleMouseEnter}
7768
>
7869
{/* Workflow preview/thumbnail area */}
@@ -126,6 +117,6 @@ export function WorkflowCard({ workflow, onHover }: WorkflowCardProps) {
126117
</CardFooter>
127118
</div>
128119
</Card>
129-
</Link>
120+
</div>
130121
)
131122
}

sim/stores/workflows/workflow/store.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -306,23 +306,6 @@ export const useWorkflowStore = create<WorkflowStoreWithHistory>()(
306306
}
307307
},
308308

309-
// Initialize workflow from external state (used for public workflows)
310-
initializeWorkflow: (blocks: any, edges: any, loops: any) => {
311-
const newState = {
312-
blocks: blocks || {},
313-
edges: edges || [],
314-
loops: loops || {},
315-
lastSaved: Date.now(),
316-
isDeployed: false,
317-
deployedAt: undefined,
318-
isPublished: true,
319-
}
320-
321-
set(newState)
322-
// Don't push to history since this is an initial load
323-
// Don't sync to avoid overwriting the original workflow
324-
},
325-
326309
toggleBlockEnabled: (id: string) => {
327310
const newState = {
328311
blocks: {

sim/stores/workflows/workflow/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ export interface WorkflowActions {
6262
triggerUpdate: () => void
6363
setDeploymentStatus: (isDeployed: boolean, deployedAt?: Date) => void
6464
setPublishStatus: (isPublished: boolean) => void
65-
initializeWorkflow: (blocks: any, edges: any, loops: any) => void
6665
}
6766

6867
export type WorkflowStore = WorkflowState & WorkflowActions

0 commit comments

Comments
 (0)