1- import type { ImportResult , ImportResourceResult } from '../../../commands/import/types' ;
1+ import type { ImportResourceResult , ImportResult } from '../../../commands/import/types' ;
2+ import { type NextStep , NextSteps } from '../../components/NextSteps' ;
3+ import { Panel } from '../../components/Panel' ;
24import { ErrorPrompt } from '../../components/PromptScreen' ;
3- import { NextSteps , type NextStep } from '../../components/NextSteps' ;
45import { Screen } from '../../components/Screen' ;
5- import { Panel } from '../../components/Panel' ;
66import { HELP_TEXT } from '../../constants' ;
77import { ArnInputScreen } from './ArnInputScreen' ;
88import { CodePathScreen } from './CodePathScreen' ;
@@ -38,15 +38,16 @@ const IMPORT_NEXT_STEPS: NextStep[] = [
3838
3939interface ImportFlowProps {
4040 onBack : ( ) => void ;
41+ onNavigate ?: ( command : string ) => void ;
4142}
4243
43- export function ImportFlow ( { onBack } : ImportFlowProps ) {
44+ export function ImportFlow ( { onBack, onNavigate } : ImportFlowProps ) {
4445 const [ flow , setFlow ] = useState < ImportFlowState > ( { name : 'select-type' } ) ;
4546
4647 if ( flow . name === 'select-type' ) {
4748 return (
4849 < ImportSelectScreen
49- onSelect = { ( type ) => {
50+ onSelect = { type => {
5051 if ( type === 'runtime' || type === 'memory' ) {
5152 setFlow ( { name : 'arn-input' , resourceType : type } ) ;
5253 } else {
@@ -62,7 +63,7 @@ export function ImportFlow({ onBack }: ImportFlowProps) {
6263 return (
6364 < ArnInputScreen
6465 resourceType = { flow . resourceType }
65- onSubmit = { ( arn ) => {
66+ onSubmit = { arn => {
6667 if ( flow . resourceType === 'runtime' ) {
6768 setFlow ( { name : 'code-path' , resourceType : 'runtime' , arn } ) ;
6869 } else {
@@ -81,7 +82,7 @@ export function ImportFlow({ onBack }: ImportFlowProps) {
8182 if ( flow . name === 'code-path' ) {
8283 return (
8384 < CodePathScreen
84- onSubmit = { ( codePath ) => {
85+ onSubmit = { codePath => {
8586 setFlow ( {
8687 name : 'importing' ,
8788 importType : 'runtime' ,
@@ -97,7 +98,7 @@ export function ImportFlow({ onBack }: ImportFlowProps) {
9798 if ( flow . name === 'yaml-path' ) {
9899 return (
99100 < YamlPathScreen
100- onSubmit = { ( yamlPath ) => {
101+ onSubmit = { yamlPath => {
101102 setFlow ( {
102103 name : 'importing' ,
103104 importType : 'starter-toolkit' ,
@@ -116,10 +117,10 @@ export function ImportFlow({ onBack }: ImportFlowProps) {
116117 arn = { flow . arn }
117118 code = { flow . code }
118119 yamlPath = { flow . yamlPath }
119- onSuccess = { ( result ) => {
120+ onSuccess = { result => {
120121 setFlow ( { name : 'success' , importType : flow . importType , result } ) ;
121122 } }
122- onError = { ( message ) => {
123+ onError = { message => {
123124 setFlow ( { name : 'error' , message } ) ;
124125 } }
125126 onExit = { onBack }
@@ -129,40 +130,39 @@ export function ImportFlow({ onBack }: ImportFlowProps) {
129130
130131 if ( flow . name === 'success' ) {
131132 const result = flow . result ;
132- const isResource = 'resourceType' in result ;
133133
134134 return (
135135 < Screen title = "Import Complete" onExit = { onBack } helpText = { HELP_TEXT . BACK } >
136136 < Panel >
137137 < Box flexDirection = "column" >
138138 < Text color = "green" > Import successful!</ Text >
139- { isResource && (
139+ { 'resourceType' in result && (
140140 < Box flexDirection = "column" marginTop = { 1 } >
141141 < Text >
142142 < Text dimColor > Type: </ Text >
143- < Text > { ( result as ImportResourceResult ) . resourceType } </ Text >
143+ < Text > { result . resourceType } </ Text >
144144 </ Text >
145145 < Text >
146146 < Text dimColor > Name: </ Text >
147- < Text > { ( result as ImportResourceResult ) . resourceName } </ Text >
147+ < Text > { result . resourceName } </ Text >
148148 </ Text >
149- { ( result as ImportResourceResult ) . resourceId && (
149+ { result . resourceId && (
150150 < Text >
151151 < Text dimColor > ID: </ Text >
152- < Text > { ( result as ImportResourceResult ) . resourceId } </ Text >
152+ < Text > { result . resourceId } </ Text >
153153 </ Text >
154154 ) }
155155 </ Box >
156156 ) }
157- { ! isResource && (
157+ { 'importedAgents' in result && (
158158 < Box flexDirection = "column" marginTop = { 1 } >
159- { ( result as ImportResult ) . importedAgents ?. map ( ( agent ) => (
159+ { result . importedAgents ?. map ( agent => (
160160 < Text key = { agent } >
161161 < Text dimColor > Agent: </ Text >
162162 < Text > { agent } </ Text >
163163 </ Text >
164164 ) ) }
165- { ( result as ImportResult ) . importedMemories ?. map ( ( mem ) => (
165+ { result . importedMemories ?. map ( mem => (
166166 < Text key = { mem } >
167167 < Text dimColor > Memory: </ Text >
168168 < Text > { mem } </ Text >
@@ -172,7 +172,12 @@ export function ImportFlow({ onBack }: ImportFlowProps) {
172172 ) }
173173 </ Box >
174174 </ Panel >
175- < NextSteps steps = { IMPORT_NEXT_STEPS } isInteractive = { true } onSelect = { ( ) => onBack ( ) } onBack = { onBack } />
175+ < NextSteps
176+ steps = { IMPORT_NEXT_STEPS }
177+ isInteractive = { true }
178+ onSelect = { step => ( onNavigate ? onNavigate ( step . command ) : onBack ( ) ) }
179+ onBack = { onBack }
180+ />
176181 </ Screen >
177182 ) ;
178183 }
0 commit comments