11import { useEffect , useState } from "react" ;
2- import { Link } from "react-router-dom" ;
2+ import { useNavigate } from "react-router-dom" ;
33import { useRepoStore } from "../store/useRepoStore" ;
44import { usePipelineStore } from "../store/usePipelineStore" ;
55
66export default function ConfigurePage ( ) {
77 const { repo, branch } = useRepoStore ( ) ;
88 const pipeline = usePipelineStore ( ) ;
9+ const navigate = useNavigate ( ) ;
910
10- // Load available AWS roles once
11+ // Log on mount with repo, branch, and navigate check
1112 useEffect ( ( ) => {
12- pipeline . loadAwsRoles ?.( ) . catch ( console . error ) ;
13+ console . log ( "[ConfigurePage] Mounted. Repo:" , repo , "Branch:" , branch ) ;
14+ if ( ! navigate ) console . warn ( "[ConfigurePage] ⚠️ navigate() not initialized!" ) ;
15+ } , [ repo , branch , navigate ] ) ;
16+
17+ // Load available AWS roles once, safely
18+ useEffect ( ( ) => {
19+ let loaded = false ;
20+
21+ async function init ( ) {
22+ if ( loaded ) return ;
23+ loaded = true ;
24+ try {
25+ console . log ( "[ConfigurePage] Loading AWS roles once..." ) ;
26+ await pipeline . loadAwsRoles ?.( ) ;
27+
28+ // Re-read roles from store after load completes
29+ const updatedRoles = usePipelineStore . getState ( ) . roles ;
30+ console . log ( "[ConfigurePage] Roles (after load):" , updatedRoles ) ;
31+ } catch ( err ) {
32+ console . error ( "Failed to load AWS roles:" , err ) ;
33+ }
34+ }
35+
36+ init ( ) ;
1337 // eslint-disable-next-line react-hooks/exhaustive-deps
1438 } , [ ] ) ;
1539
@@ -22,6 +46,7 @@ export default function ConfigurePage() {
2246 setBusy ( false ) ;
2347 }
2448
49+ console . log ( "[ConfigurePage] pipeline.result:" , pipeline . result ) ;
2550 return (
2651 < section style = { { display : "grid" , gap : 16 } } >
2752 < h1 > Configure Pipeline</ h1 >
@@ -60,23 +85,45 @@ export default function ConfigurePage() {
6085
6186 < label >
6287 AWS Role (OIDC)
63- < select value = { pipeline . options . awsRoleArn ?? "" } onChange = { ( e ) => pipeline . setOption ( "awsRoleArn" , e . target . value ) } style = { { display : "block" , padding : 8 } } >
88+ < select disabled = { busy } value = { pipeline . options . awsRoleArn ?? "" } onChange = { ( e ) => pipeline . setOption ( "awsRoleArn" , e . target . value ) } style = { { display : "block" , padding : 8 } } >
6489 < option value = "" > -- select --</ option >
65- { pipeline . roles ?. map ( ( r ) => < option key = { r } value = { r } > { r } </ option > ) }
90+ { pipeline . roles ?. map ( ( r ) => (
91+ < option key = { r . arn } value = { r . arn } >
92+ { r . name }
93+ </ option >
94+ ) ) }
6695 </ select >
6796 </ label >
6897
6998 < div style = { { display : "flex" , gap : 8 } } >
7099 < button onClick = { onGenerate } disabled = { busy } > { busy ? "Generating…" : "Generate Pipeline" } </ button >
71- < Link to = "/secrets" >
72- < button disabled = { ! pipeline . result ?. generated_yaml } > Continue → Secrets</ button >
73- </ Link >
100+ < button
101+ onClick = { ( ) => {
102+ console . log ( "[ConfigurePage] Navigate button clicked." ) ;
103+ console . log ( "[ConfigurePage] Pipeline result before navigating:" , pipeline . result ) ;
104+ try {
105+ navigate ( "/secrets" , { state : { pipeline : pipeline . result } } ) ;
106+ console . log ( "[ConfigurePage] ✅ Navigation triggered successfully." ) ;
107+ } catch ( err ) {
108+ console . error ( "[ConfigurePage] ❌ Navigation failed:" , err ) ;
109+ }
110+ } }
111+ disabled = {
112+ ! (
113+ pipeline . result ?. yaml ||
114+ pipeline . result ?. generated_yaml ||
115+ pipeline . result ?. data ?. generated_yaml
116+ )
117+ }
118+ >
119+ Continue → Secrets
120+ </ button >
74121 </ div >
75122
76123 < div >
77124 < div > YAML Preview</ div >
78125 < pre style = { { maxHeight : 400 , overflow : "auto" , background : "#f6f6f6" , padding : 12 } } >
79- { pipeline . result ?. generated_yaml ?? "Click Generate Pipeline to preview YAML…" }
126+ { pipeline . result ?. yaml ?? pipeline . result ?. generated_yaml ?? "Click Generate Pipeline to preview YAML…" }
80127 </ pre >
81128 </ div >
82129 </ section >
0 commit comments