@@ -51,6 +51,7 @@ export default function IntegrationBuilderPage({ files }: { files: Record<string
51
51
const [ isLinkCopied , setLinkCopied ] = useState < boolean > ( false ) ;
52
52
const [ IBCountdown , setIBCountdown ] = useState < number > ( 10 ) ;
53
53
const [ builderView , setBuilderView ] = useState < boolean > ( true ) ;
54
+ const [ abortCountdown , setAbortCountdown ] = useState < boolean > ( false ) ;
54
55
const [ showPreviewModal , setShowPreviewModal ] = useState < boolean > ( false ) ;
55
56
const url = new URL ( getWindowLocation ( ) ) ;
56
57
const [ stepIndex , setStepIndex ] = useState (
@@ -118,6 +119,7 @@ export default function IntegrationBuilderPage({ files }: { files: Record<string
118
119
...builderOptions ,
119
120
[ optionKey ] : optionValue ,
120
121
} ) ;
122
+ setAbortCountdown ( true ) ;
121
123
} ;
122
124
123
125
const toggleBuilderView = async ( ) => {
@@ -173,7 +175,7 @@ export default function IntegrationBuilderPage({ files }: { files: Record<string
173
175
if ( IBCountdown > 0 ) {
174
176
setTimeout ( ( ) => setIBCountdown ( IBCountdown - 1 ) , 1000 ) ;
175
177
}
176
- if ( IBCountdown === 0 && builderView ) {
178
+ if ( IBCountdown === 0 && builderView && ! abortCountdown ) {
177
179
toggleBuilderView ( ) ;
178
180
}
179
181
} , [ IBCountdown ] ) ;
@@ -330,26 +332,8 @@ export default function IntegrationBuilderPage({ files }: { files: Record<string
330
332
< div className = { styles . optionsHeader } >
331
333
< h2 className = { styles . optionsHeaderText } > Builder Settings</ h2 >
332
334
< div className = { styles . optionsHeaderButtonsContainer } >
333
- { /* {integration.embedLink && (
334
- <button
335
- className={styles.previewButton}
336
- onClick={() => togglePreviewModal(integration.embedLink)}
337
- type="button"
338
- id="headerButton"
339
- >
340
- Preview
341
- </button>
342
- )} */ }
343
- { /* <button
344
- className={styles.copyButton}
345
- onClick={() => window.open(integration.sourceCodeLink, "_blank")}
346
- type="button"
347
- id="headerButton"
348
- >
349
- Source Code
350
- </button> */ }
351
335
< button className = { styles . hideButton } onClick = { toggleBuilderView } type = "button" >
352
- { IBCountdown ? `${ IBCountdown } s` : "" }
336
+ { IBCountdown && ! abortCountdown ? `${ IBCountdown } s` : "" }
353
337
< svg
354
338
width = "20"
355
339
height = "21"
@@ -376,15 +360,21 @@ export default function IntegrationBuilderPage({ files }: { files: Record<string
376
360
{ integration . embedLink && (
377
361
< button
378
362
className = { styles . previewButton2 }
379
- onClick = { ( ) => togglePreviewModal ( integration . embedLink ) }
363
+ onClick = { ( ) => {
364
+ togglePreviewModal ( integration . embedLink ) ;
365
+ setAbortCountdown ( true ) ;
366
+ } }
380
367
type = "button"
381
368
>
382
369
Preview
383
370
</ button >
384
371
) }
385
372
< button
386
373
className = { styles . copyButton2 }
387
- onClick = { ( ) => window . open ( integration . sourceCodeLink , "_blank" ) }
374
+ onClick = { ( ) => {
375
+ window . open ( integration . sourceCodeLink , "_blank" ) ;
376
+ setAbortCountdown ( true ) ;
377
+ } }
388
378
type = "button"
389
379
>
390
380
Source Code
@@ -415,7 +405,10 @@ export default function IntegrationBuilderPage({ files }: { files: Record<string
415
405
{ integration . embedLink && (
416
406
< button
417
407
className = { styles . previewButton }
418
- onClick = { ( ) => togglePreviewModal ( integration . embedLink ) }
408
+ onClick = { ( ) => {
409
+ togglePreviewModal ( integration . embedLink ) ;
410
+ setAbortCountdown ( true ) ;
411
+ } }
419
412
type = "button"
420
413
id = "headerButton"
421
414
>
@@ -424,7 +417,10 @@ export default function IntegrationBuilderPage({ files }: { files: Record<string
424
417
) }
425
418
< button
426
419
className = { styles . copyButton }
427
- onClick = { ( ) => window . open ( integration . sourceCodeLink , "_blank" ) }
420
+ onClick = { ( ) => {
421
+ window . open ( integration . sourceCodeLink , "_blank" ) ;
422
+ setAbortCountdown ( true ) ;
423
+ } }
428
424
type = "button"
429
425
id = "headerButton"
430
426
>
0 commit comments