@@ -22,6 +22,7 @@ import { NodeFieldElementOverlay } from 'features/nodes/components/sidePanel/bui
2222import { useDoesWorkflowHaveUnsavedChanges } from 'features/nodes/components/sidePanel/workflow/IsolatedWorkflowBuilderWatcher' ;
2323import {
2424 $isInPublishFlow ,
25+ $isPublishing ,
2526 $isReadyToDoValidationRun ,
2627 $isSelectingOutputNode ,
2728 $outputNodeId ,
@@ -183,13 +184,14 @@ SelectOutputNodeButton.displayName = 'SelectOutputNodeButton';
183184
184185const CancelPublishButton = memo ( ( ) => {
185186 const { t } = useTranslation ( ) ;
187+ const isPublishing = useStore ( $isPublishing ) ;
186188 const onClick = useCallback ( ( ) => {
187189 $isInPublishFlow . set ( false ) ;
188190 $isSelectingOutputNode . set ( false ) ;
189191 $outputNodeId . set ( null ) ;
190192 } , [ ] ) ;
191193 return (
192- < Button leftIcon = { < PiXBold /> } onClick = { onClick } >
194+ < Button leftIcon = { < PiXBold /> } onClick = { onClick } isDisabled = { isPublishing } >
193195 { t ( 'common.cancel' ) }
194196 </ Button >
195197 ) ;
@@ -198,6 +200,7 @@ CancelPublishButton.displayName = 'CancelDeployButton';
198200
199201const PublishWorkflowButton = memo ( ( ) => {
200202 const { t } = useTranslation ( ) ;
203+ const isPublishing = useStore ( $isPublishing ) ;
201204 const isReadyToDoValidationRun = useStore ( $isReadyToDoValidationRun ) ;
202205 const isReadyToEnqueue = useStore ( $isReadyToEnqueue ) ;
203206 const doesWorkflowHaveUnsavedChanges = useDoesWorkflowHaveUnsavedChanges ( ) ;
@@ -211,6 +214,7 @@ const PublishWorkflowButton = memo(() => {
211214
212215 const enqueue = useEnqueueWorkflows ( ) ;
213216 const onClick = useCallback ( async ( ) => {
217+ $isPublishing . set ( true ) ;
214218 const result = await withResultAsync ( ( ) => enqueue ( true , true ) ) ;
215219 if ( result . isErr ( ) ) {
216220 toast ( {
@@ -244,8 +248,30 @@ const PublishWorkflowButton = memo(() => {
244248 } ) ;
245249 log . debug ( parseify ( result . value ) , 'Enqueued batch' ) ;
246250 }
251+ $isPublishing . set ( false ) ;
247252 } , [ enqueue , projectUrl , t ] ) ;
248253
254+ const isDisabled = useMemo ( ( ) => {
255+ return (
256+ ! allowPublishWorkflows ||
257+ ! isReadyToEnqueue ||
258+ doesWorkflowHaveUnsavedChanges ||
259+ hasUnpublishableNodes ||
260+ ! isReadyToDoValidationRun ||
261+ ! ( outputNodeId !== null && ! isSelectingOutputNode ) ||
262+ isPublishing
263+ ) ;
264+ } , [
265+ allowPublishWorkflows ,
266+ doesWorkflowHaveUnsavedChanges ,
267+ hasUnpublishableNodes ,
268+ isReadyToDoValidationRun ,
269+ isReadyToEnqueue ,
270+ isSelectingOutputNode ,
271+ outputNodeId ,
272+ isPublishing ,
273+ ] ) ;
274+
249275 return (
250276 < PublishTooltip
251277 isWorkflowSaved = { ! doesWorkflowHaveUnsavedChanges }
@@ -255,19 +281,8 @@ const PublishWorkflowButton = memo(() => {
255281 hasPublishableInputs = { inputs . publishable . length > 0 }
256282 hasUnpublishableInputs = { inputs . unpublishable . length > 0 }
257283 >
258- < Button
259- leftIcon = { < PiLightningFill /> }
260- isDisabled = {
261- ! allowPublishWorkflows ||
262- ! isReadyToEnqueue ||
263- doesWorkflowHaveUnsavedChanges ||
264- hasUnpublishableNodes ||
265- ! isReadyToDoValidationRun ||
266- ! ( outputNodeId !== null && ! isSelectingOutputNode )
267- }
268- onClick = { onClick }
269- >
270- { t ( 'workflows.builder.publish' ) }
284+ < Button leftIcon = { < PiLightningFill /> } isDisabled = { isDisabled } onClick = { onClick } >
285+ { isPublishing ? t ( 'workflows.builder.publishing' ) : t ( 'workflows.builder.publish' ) }
271286 </ Button >
272287 </ PublishTooltip >
273288 ) ;
@@ -337,6 +352,10 @@ export const StartPublishFlowButton = memo(() => {
337352 $isInPublishFlow . set ( true ) ;
338353 } , [ ] ) ;
339354
355+ const isDisabled = useMemo ( ( ) => {
356+ return ! allowPublishWorkflows || ! isReadyToEnqueue || doesWorkflowHaveUnsavedChanges || hasUnpublishableNodes ;
357+ } , [ allowPublishWorkflows , doesWorkflowHaveUnsavedChanges , hasUnpublishableNodes , isReadyToEnqueue ] ) ;
358+
340359 return (
341360 < PublishTooltip
342361 isWorkflowSaved = { ! doesWorkflowHaveUnsavedChanges }
@@ -346,15 +365,7 @@ export const StartPublishFlowButton = memo(() => {
346365 hasPublishableInputs = { inputs . publishable . length > 0 }
347366 hasUnpublishableInputs = { inputs . unpublishable . length > 0 }
348367 >
349- < Button
350- onClick = { onClick }
351- leftIcon = { < PiLightningFill /> }
352- variant = "ghost"
353- size = "sm"
354- isDisabled = {
355- ! allowPublishWorkflows || ! isReadyToEnqueue || doesWorkflowHaveUnsavedChanges || hasUnpublishableNodes
356- }
357- >
368+ < Button onClick = { onClick } leftIcon = { < PiLightningFill /> } variant = "ghost" size = "sm" isDisabled = { isDisabled } >
358369 { t ( 'workflows.builder.publish' ) }
359370 </ Button >
360371 </ PublishTooltip >
0 commit comments