@@ -31,6 +31,8 @@ import {
31
31
checkDeploymentStatus ,
32
32
fetchDeploymentStatus ,
33
33
deriveOverallStatus ,
34
+ cleanPendingsFromDeploymentStatus ,
35
+ isDeployFinishing ,
34
36
} from './utils' ;
35
37
import {
36
38
type File ,
@@ -126,7 +128,7 @@ export function Deploy(props: Props) {
126
128
const identity = localStorageGetIdentity ( wallet ) ;
127
129
if ( identity && chainId ) {
128
130
const authChain = Authenticator . signPayload ( identity , info . rootCID ) ;
129
- void deploy ( { address : wallet , authChain, chainId : ChainId . ETHEREUM_SEPOLIA } )
131
+ void deploy ( { address : wallet , authChain, chainId } )
130
132
. then ( ( ) => {
131
133
if ( ! isMounted ( ) ) return ;
132
134
} )
@@ -196,9 +198,12 @@ export function Deploy(props: Props) {
196
198
}
197
199
} , [ jumpInUrl ] ) ;
198
200
199
- const handleDeployFinish = useCallback ( ( status : Status , error ?: string ) => {
200
- setDeployStatus ( status ) ;
201
- setError ( error ?? null ) ;
201
+ const handleDeploySuccess = useCallback ( ( ) => {
202
+ setDeployStatus ( 'complete' ) ;
203
+ } , [ ] ) ;
204
+
205
+ const handleDeployRetry = useCallback ( ( ) => {
206
+ props . onBack && props . onBack ( ) ;
202
207
} , [ ] ) ;
203
208
204
209
return (
@@ -240,6 +245,7 @@ export function Deploy(props: Props) {
240
245
</ label >
241
246
< span className = "buttons" >
242
247
< Button
248
+ color = "secondary"
243
249
variant = "outlined"
244
250
size = "medium"
245
251
onClick = { handleBack }
@@ -321,8 +327,9 @@ export function Deploy(props: Props) {
321
327
< Deploying
322
328
info = { info }
323
329
url = { jumpInUrl }
324
- onFinish = { handleDeployFinish }
330
+ onSuccess = { handleDeploySuccess }
325
331
onClick = { handleJumpIn }
332
+ onRetry = { handleDeployRetry }
326
333
/>
327
334
) }
328
335
{ deployStatus === 'complete' && (
@@ -393,11 +400,12 @@ function Idle({ files, error, onClick }: IdleProps) {
393
400
type DeployingProps = {
394
401
info : Info ;
395
402
url : string | null ;
396
- onFinish : ( status : Status , error ?: string ) => void ;
403
+ onSuccess : ( ) => void ;
397
404
onClick : ( ) => void ;
405
+ onRetry : ( ) => void ;
398
406
} ;
399
407
400
- function Deploying ( { info, url, onFinish , onClick } : DeployingProps ) {
408
+ function Deploying ( { info, url, onSuccess , onClick, onRetry } : DeployingProps ) {
401
409
const { wallet } = useAuth ( ) ;
402
410
const [ deployState , setDeployState ] = useState < DeploymentStatus > ( getInitialDeploymentStatus ( ) ) ;
403
411
@@ -406,41 +414,37 @@ function Deploying({ info, url, onFinish, onClick }: DeployingProps) {
406
414
const identity = localStorageGetIdentity ( wallet ) ;
407
415
if ( ! identity ) throw new Error ( `No identity found for wallet ${ wallet } ` ) ;
408
416
return fetchDeploymentStatus ( info . rootCID , identity ) ;
409
- } , [ info ] ) ;
417
+ } , [ wallet , info ] ) ;
418
+
419
+ const onReportIssue = useCallback ( ( ) => {
420
+ void misc . openExternal ( 'https://decentraland.canny.io' ) ;
421
+ } , [ ] ) ;
410
422
411
423
useEffect (
412
424
( ) => {
413
425
let isCancelled = false ;
414
426
415
427
const handleUpdate = ( status : DeploymentStatus ) => {
416
- // if catalyst deploy fails, we abort the deployment completely
417
- if ( status . catalyst === 'failed' ) {
418
- isCancelled = true ;
419
- return onFinish (
420
- 'failed' ,
421
- t ( 'modal.publish_project.deploy.deploying.errors.catalyst_deploy' ) ,
422
- ) ;
428
+ if ( ! isCancelled ) {
429
+ if ( deriveOverallStatus ( status ) === 'failed' ) {
430
+ isCancelled = true ;
431
+ setDeployState ( cleanPendingsFromDeploymentStatus ( status ) ) ;
432
+ } else {
433
+ setDeployState ( status ) ;
434
+ }
423
435
}
424
- if ( ! isCancelled ) setDeployState ( status ) ;
425
436
} ;
426
437
427
- const handleSuccess = ( status : DeploymentStatus ) => {
428
- if ( ! isCancelled ) onFinish ( deriveOverallStatus ( status ) ) ;
438
+ const handleSuccess = ( ) => {
439
+ if ( ! isCancelled ) onSuccess ( ) ;
429
440
} ;
430
441
431
442
const handleFailure = ( error : any ) => {
432
443
if ( ! isCancelled ) {
433
- // if we know the error, we can translate it
444
+ // info: if we know the error, we can translate it
434
445
if ( isDeploymentError ( error , 'MAX_RETRIES' ) ) {
435
- return onFinish (
436
- 'failed' ,
437
- t ( 'modal.publish_project.deploy.deploying.errors.max_retries' , {
438
- error : error . message ,
439
- } ) ,
440
- ) ;
446
+ setDeployState ( cleanPendingsFromDeploymentStatus ( error . status ) ) ;
441
447
}
442
-
443
- onFinish ( 'failed' , error . message ) ;
444
448
}
445
449
} ;
446
450
@@ -465,48 +469,79 @@ function Deploying({ info, url, onFinish, onClick }: DeployingProps) {
465
469
[ ] /* no deps, want this to run ONLY on mount */ ,
466
470
) ;
467
471
468
- const text = useMemo ( ( ) => t ( 'modal.publish_project.deploy.deploying.step.loading' ) , [ ] ) ;
469
- const is = useCallback ( ( status : Status , status2 : Status ) => status === status2 , [ ] ) ;
472
+ const getStepDescription = useCallback ( ( status : Status ) => {
473
+ switch ( status ) {
474
+ case 'pending' :
475
+ return t ( 'modal.publish_project.deploy.deploying.step.loading' ) ;
476
+ case 'failed' :
477
+ return t ( 'modal.publish_project.deploy.deploying.step.failed' ) ;
478
+ default :
479
+ return undefined ;
480
+ }
481
+ } , [ ] ) ;
470
482
471
483
const steps : Step [ ] = useMemo ( ( ) => {
472
484
const { catalyst, assetBundle, lods } = deployState ;
473
-
474
485
return [
475
486
{
476
487
bulletText : '1' ,
477
488
name : t ( 'modal.publish_project.deploy.deploying.step.catalyst' ) ,
478
- text : is ( 'pending' , catalyst ) ? text : undefined ,
489
+ description : getStepDescription ( catalyst ) ,
479
490
state : catalyst ,
480
491
} ,
481
492
{
482
493
bulletText : '2' ,
483
494
name : t ( 'modal.publish_project.deploy.deploying.step.asset_bundle' ) ,
484
- text : is ( 'pending' , assetBundle ) ? text : undefined ,
495
+ description : getStepDescription ( assetBundle ) ,
485
496
state : assetBundle ,
486
497
} ,
487
498
{
488
499
bulletText : '3' ,
489
500
name : t ( 'modal.publish_project.deploy.deploying.step.lods' ) ,
490
- text : is ( 'pending' , lods ) ? text : undefined ,
501
+ description : getStepDescription ( lods ) ,
491
502
state : lods ,
492
503
} ,
493
504
] ;
494
- } , [ deployState ] ) ;
505
+ } , [ deployState , getStepDescription ] ) ;
495
506
496
- const lastStep = steps [ steps . length - 1 ] ;
507
+ const isFinishing = useMemo ( ( ) => isDeployFinishing ( deployState ) , [ deployState ] ) ;
508
+ const overallStatus = useMemo ( ( ) => deriveOverallStatus ( deployState ) , [ deployState ] ) ;
509
+ const title = useMemo ( ( ) => {
510
+ if ( overallStatus === 'failed' ) return t ( 'modal.publish_project.deploy.deploying.failed' ) ;
511
+ if ( isFinishing ) return t ( 'modal.publish_project.deploy.deploying.finishing' ) ;
512
+ return t ( 'modal.publish_project.deploy.deploying.publish' ) ;
513
+ } , [ overallStatus , isFinishing ] ) ;
497
514
498
515
return (
499
516
< div className = "Deploying" >
500
- < div className = "title" >
501
- < Loader />
502
- < Typography variant = "h5" >
503
- { lastStep . state === 'pending'
504
- ? t ( 'modal.publish_project.deploy.deploying.finishing' )
505
- : t ( 'modal.publish_project.deploy.deploying.publish' ) }
506
- </ Typography >
517
+ < div className = "header" >
518
+ < div className = "title" >
519
+ { overallStatus === 'failed' ? < div className = "Warning" /> : < Loader /> }
520
+ < Typography variant = "h5" > { title } </ Typography >
521
+ </ div >
522
+ { overallStatus === 'failed' && (
523
+ < span > { t ( 'modal.publish_project.deploy.deploying.try_again' ) } </ span >
524
+ ) }
507
525
</ div >
508
526
< ConnectedSteps steps = { steps } />
509
- { lastStep . state === 'pending' ? (
527
+ { overallStatus === 'failed' ? (
528
+ < div className = "actions" >
529
+ < Button
530
+ size = "large"
531
+ variant = "outlined"
532
+ color = "secondary"
533
+ onClick = { onReportIssue }
534
+ >
535
+ { t ( 'modal.publish_project.deploy.deploying.actions.report_issue' ) }
536
+ </ Button >
537
+ < Button
538
+ size = "large"
539
+ onClick = { onRetry }
540
+ >
541
+ { t ( 'modal.publish_project.deploy.deploying.actions.retry' ) }
542
+ </ Button >
543
+ </ div >
544
+ ) : isFinishing ? (
510
545
< >
511
546
< div className = "jump" >
512
547
< JumpUrl
0 commit comments