Skip to content

Commit d3c3137

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(workflow): retry unavailable resource lock data
1 parent 78171b7 commit d3c3137

1 file changed

Lines changed: 45 additions & 10 deletions

File tree

  • apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content

apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-content/resource-content.tsx

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
FileX,
88
Folder as FolderIcon,
99
Library,
10+
RefreshCw,
1011
Square,
1112
SquareArrowUpRight,
1213
Workflow as WorkflowIcon,
@@ -362,8 +363,16 @@ export function EmbeddedWorkflowActions({ workspaceId, workflowId }: EmbeddedWor
362363
const { data: session } = useSession()
363364
const hostContext = useWorkspaceHostContext()
364365
const { userPermissions: effectivePermissions } = useWorkspacePermissionsContext()
365-
const { data: workflowMap, isLoading: isWorkflowMapLoading } = useWorkflowMap(workspaceId)
366-
const { data: folderMap, isLoading: isFolderMapLoading } = useFolderMap(workspaceId)
366+
const {
367+
data: workflowMap,
368+
isLoading: isWorkflowMapLoading,
369+
refetch: refetchWorkflowMap,
370+
} = useWorkflowMap(workspaceId)
371+
const {
372+
data: folderMap,
373+
isLoading: isFolderMapLoading,
374+
refetch: refetchFolderMap,
375+
} = useFolderMap(workspaceId)
367376
const setActiveWorkflow = useWorkflowRegistry((state) => state.setActiveWorkflow)
368377
const { handleRunWorkflow, handleCancelExecution } = useWorkflowExecution()
369378
const isExecuting = useExecutionStore(
@@ -384,8 +393,14 @@ export function EmbeddedWorkflowActions({ workspaceId, workflowId }: EmbeddedWor
384393
!isExecuting &&
385394
(isUsageGateLoading || (!effectivePermissions.canRead && !effectivePermissions.isLoading))
386395
const isWorkflowLockDataLoading = isWorkflowMapLoading || isFolderMapLoading
396+
const isWorkflowLockDataUnavailable = !workflowMap || !folderMap
387397
const isWorkflowLocked = isWorkflowEffectivelyLocked(workflowMap?.[workflowId], folderMap ?? {})
388398

399+
const handleRetryWorkflowLockData = () => {
400+
if (!workflowMap) void refetchWorkflowMap()
401+
if (!folderMap) void refetchFolderMap()
402+
}
403+
389404
const handleRun = async () => {
390405
setActiveWorkflow(workflowId)
391406

@@ -456,14 +471,34 @@ export function EmbeddedWorkflowActions({ workspaceId, workflowId }: EmbeddedWor
456471
<p>{isExecuting ? 'Stop' : 'Run workflow'}</p>
457472
</Tooltip.Content>
458473
</Tooltip.Root>
459-
<Deploy
460-
activeWorkflowId={workflowId}
461-
userPermissions={effectivePermissions}
462-
className={RESOURCE_TAB_ICON_BUTTON_CLASS}
463-
compact
464-
disabled={isWorkflowLockDataLoading || isWorkflowLocked}
465-
disabledTooltip={isWorkflowLockDataLoading ? 'Loading workflow lock status...' : undefined}
466-
/>
474+
{isWorkflowLockDataUnavailable && !isWorkflowLockDataLoading ? (
475+
<Tooltip.Root>
476+
<Tooltip.Trigger asChild>
477+
<Button
478+
variant='subtle'
479+
onClick={handleRetryWorkflowLockData}
480+
className={RESOURCE_TAB_ICON_BUTTON_CLASS}
481+
aria-label='Retry loading workflow lock status'
482+
>
483+
<RefreshCw className={RESOURCE_TAB_ICON_CLASS} />
484+
</Button>
485+
</Tooltip.Trigger>
486+
<Tooltip.Content side='bottom'>
487+
<p>Retry loading workflow lock status</p>
488+
</Tooltip.Content>
489+
</Tooltip.Root>
490+
) : (
491+
<Deploy
492+
activeWorkflowId={workflowId}
493+
userPermissions={effectivePermissions}
494+
className={RESOURCE_TAB_ICON_BUTTON_CLASS}
495+
compact
496+
disabled={isWorkflowLockDataLoading || isWorkflowLocked}
497+
disabledTooltip={
498+
isWorkflowLockDataLoading ? 'Loading workflow lock status...' : undefined
499+
}
500+
/>
501+
)}
467502
</>
468503
)
469504
}

0 commit comments

Comments
 (0)