Skip to content

Commit 78171b7

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(workflow): clarify resource deploy loading states
1 parent d061558 commit 78171b7

3 files changed

Lines changed: 23 additions & 8 deletions

File tree

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -383,11 +383,8 @@ export function EmbeddedWorkflowActions({ workspaceId, workflowId }: EmbeddedWor
383383
const isRunButtonDisabled =
384384
!isExecuting &&
385385
(isUsageGateLoading || (!effectivePermissions.canRead && !effectivePermissions.isLoading))
386-
const isWorkflowLockDataLoading =
387-
isWorkflowMapLoading || isFolderMapLoading || !workflowMap || !folderMap
388-
const isWorkflowLocked =
389-
isWorkflowLockDataLoading ||
390-
isWorkflowEffectivelyLocked(workflowMap?.[workflowId], folderMap ?? {})
386+
const isWorkflowLockDataLoading = isWorkflowMapLoading || isFolderMapLoading
387+
const isWorkflowLocked = isWorkflowEffectivelyLocked(workflowMap?.[workflowId], folderMap ?? {})
391388

392389
const handleRun = async () => {
393390
setActiveWorkflow(workflowId)
@@ -464,7 +461,8 @@ export function EmbeddedWorkflowActions({ workspaceId, workflowId }: EmbeddedWor
464461
userPermissions={effectivePermissions}
465462
className={RESOURCE_TAB_ICON_BUTTON_CLASS}
466463
compact
467-
disabled={isWorkflowLocked}
464+
disabled={isWorkflowLockDataLoading || isWorkflowLocked}
465+
disabledTooltip={isWorkflowLockDataLoading ? 'Loading workflow lock status...' : undefined}
468466
/>
469467
</>
470468
)

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/deploy.test.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ import { Deploy } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/
9696
let container: HTMLDivElement
9797
let root: Root
9898

99-
function renderDeploy(overrides: Partial<typeof mockState> = {}) {
99+
function renderDeploy(
100+
overrides: Partial<typeof mockState> = {},
101+
props: { disabled?: boolean; disabledTooltip?: string } = {}
102+
) {
100103
Object.assign(mockState, overrides)
101104
act(() => {
102105
root.render(
@@ -112,6 +115,7 @@ function renderDeploy(overrides: Partial<typeof mockState> = {}) {
112115
}}
113116
compact
114117
className='resource-action'
118+
{...props}
115119
/>
116120
)
117121
})
@@ -168,6 +172,14 @@ describe('Deploy compact mode', () => {
168172
renderDeploy({ hydrationWorkflowId: 'workflow-2', registryActiveWorkflowId: 'workflow-2' })
169173

170174
expect(container.querySelector('button')?.disabled).toBe(true)
175+
expect(container.textContent).toContain('Loading workflow...')
176+
})
177+
178+
it('uses a caller-provided tooltip for external loading states', () => {
179+
renderDeploy({}, { disabled: true, disabledTooltip: 'Loading workflow lock status...' })
180+
181+
expect(container.querySelector('button')?.disabled).toBe(true)
182+
expect(container.textContent).toContain('Loading workflow lock status...')
171183
})
172184

173185
it.each([

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ interface DeployProps {
2020
className?: string
2121
compact?: boolean
2222
disabled?: boolean
23+
disabledTooltip?: string
2324
}
2425

2526
export function Deploy({
@@ -28,6 +29,7 @@ export function Deploy({
2829
className,
2930
compact = false,
3031
disabled = false,
32+
disabledTooltip,
3133
}: DeployProps) {
3234
const [isModalOpen, setIsModalOpen] = useState(false)
3335
const registryActiveWorkflowId = useWorkflowRegistry((state) => state.activeWorkflowId)
@@ -89,14 +91,17 @@ export function Deploy({
8991
}
9092

9193
const getTooltipText = () => {
94+
if (isRegistryLoading) {
95+
return 'Loading workflow...'
96+
}
9297
if (isEmpty) {
9398
return 'Cannot deploy an empty workflow'
9499
}
95100
if (!canDeploy) {
96101
return 'Admin permissions required'
97102
}
98103
if (disabled) {
99-
return 'Workflow is locked'
104+
return disabledTooltip ?? 'Workflow is locked'
100105
}
101106
if (isDeploying) {
102107
return 'Deploying...'

0 commit comments

Comments
 (0)