@@ -22,6 +22,7 @@ import { NodeFieldElementOverlay } from 'features/nodes/components/sidePanel/bui
22
22
import { useDoesWorkflowHaveUnsavedChanges } from 'features/nodes/components/sidePanel/workflow/IsolatedWorkflowBuilderWatcher' ;
23
23
import {
24
24
$isInPublishFlow ,
25
+ $isPublishing ,
25
26
$isReadyToDoValidationRun ,
26
27
$isSelectingOutputNode ,
27
28
$outputNodeId ,
@@ -183,13 +184,14 @@ SelectOutputNodeButton.displayName = 'SelectOutputNodeButton';
183
184
184
185
const CancelPublishButton = memo ( ( ) => {
185
186
const { t } = useTranslation ( ) ;
187
+ const isPublishing = useStore ( $isPublishing ) ;
186
188
const onClick = useCallback ( ( ) => {
187
189
$isInPublishFlow . set ( false ) ;
188
190
$isSelectingOutputNode . set ( false ) ;
189
191
$outputNodeId . set ( null ) ;
190
192
} , [ ] ) ;
191
193
return (
192
- < Button leftIcon = { < PiXBold /> } onClick = { onClick } >
194
+ < Button leftIcon = { < PiXBold /> } onClick = { onClick } isDisabled = { isPublishing } >
193
195
{ t ( 'common.cancel' ) }
194
196
</ Button >
195
197
) ;
@@ -198,6 +200,7 @@ CancelPublishButton.displayName = 'CancelDeployButton';
198
200
199
201
const PublishWorkflowButton = memo ( ( ) => {
200
202
const { t } = useTranslation ( ) ;
203
+ const isPublishing = useStore ( $isPublishing ) ;
201
204
const isReadyToDoValidationRun = useStore ( $isReadyToDoValidationRun ) ;
202
205
const isReadyToEnqueue = useStore ( $isReadyToEnqueue ) ;
203
206
const doesWorkflowHaveUnsavedChanges = useDoesWorkflowHaveUnsavedChanges ( ) ;
@@ -211,6 +214,7 @@ const PublishWorkflowButton = memo(() => {
211
214
212
215
const enqueue = useEnqueueWorkflows ( ) ;
213
216
const onClick = useCallback ( async ( ) => {
217
+ $isPublishing . set ( true ) ;
214
218
const result = await withResultAsync ( ( ) => enqueue ( true , true ) ) ;
215
219
if ( result . isErr ( ) ) {
216
220
toast ( {
@@ -244,8 +248,30 @@ const PublishWorkflowButton = memo(() => {
244
248
} ) ;
245
249
log . debug ( parseify ( result . value ) , 'Enqueued batch' ) ;
246
250
}
251
+ $isPublishing . set ( false ) ;
247
252
} , [ enqueue , projectUrl , t ] ) ;
248
253
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
+
249
275
return (
250
276
< PublishTooltip
251
277
isWorkflowSaved = { ! doesWorkflowHaveUnsavedChanges }
@@ -255,19 +281,8 @@ const PublishWorkflowButton = memo(() => {
255
281
hasPublishableInputs = { inputs . publishable . length > 0 }
256
282
hasUnpublishableInputs = { inputs . unpublishable . length > 0 }
257
283
>
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' ) }
271
286
</ Button >
272
287
</ PublishTooltip >
273
288
) ;
@@ -337,6 +352,10 @@ export const StartPublishFlowButton = memo(() => {
337
352
$isInPublishFlow . set ( true ) ;
338
353
} , [ ] ) ;
339
354
355
+ const isDisabled = useMemo ( ( ) => {
356
+ return ! allowPublishWorkflows || ! isReadyToEnqueue || doesWorkflowHaveUnsavedChanges || hasUnpublishableNodes ;
357
+ } , [ allowPublishWorkflows , doesWorkflowHaveUnsavedChanges , hasUnpublishableNodes , isReadyToEnqueue ] ) ;
358
+
340
359
return (
341
360
< PublishTooltip
342
361
isWorkflowSaved = { ! doesWorkflowHaveUnsavedChanges }
@@ -346,15 +365,7 @@ export const StartPublishFlowButton = memo(() => {
346
365
hasPublishableInputs = { inputs . publishable . length > 0 }
347
366
hasUnpublishableInputs = { inputs . unpublishable . length > 0 }
348
367
>
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 } >
358
369
{ t ( 'workflows.builder.publish' ) }
359
370
</ Button >
360
371
</ PublishTooltip >
0 commit comments