11import { Box , Text , useApp , useInput } from "ink"
22import { useState } from "react"
3- import { ErrorStep , WizardExpertSelector } from "../../src/components/index.js"
3+ import { ErrorStep , VersionSelector , WizardExpertSelector } from "../../src/components/index.js"
44import type { WizardExpertChoice , WizardVersionInfo } from "../../src/types/wizard.js"
5- import { getStatusColor } from "../../src/utils/index.js"
65
76type WizardStep =
87 | { type : "selectExpert" }
@@ -19,56 +18,6 @@ type UnpublishAppProps = {
1918 onComplete : ( result : UnpublishWizardResult ) => void
2019 onCancel : ( ) => void
2120}
22- function VersionSelector ( {
23- expertName,
24- versions,
25- onSelect,
26- onBack,
27- } : {
28- expertName : string
29- versions : WizardVersionInfo [ ]
30- onSelect : ( version : WizardVersionInfo ) => void
31- onBack : ( ) => void
32- } ) {
33- const { exit } = useApp ( )
34- const [ selectedIndex , setSelectedIndex ] = useState ( 0 )
35- useInput ( ( input , key ) => {
36- if ( key . upArrow ) {
37- setSelectedIndex ( ( prev ) => ( prev > 0 ? prev - 1 : versions . length - 1 ) )
38- } else if ( key . downArrow ) {
39- setSelectedIndex ( ( prev ) => ( prev < versions . length - 1 ? prev + 1 : 0 ) )
40- } else if ( key . return ) {
41- const version = versions [ selectedIndex ]
42- if ( version ) {
43- onSelect ( version )
44- }
45- } else if ( key . escape || key . backspace || key . delete ) {
46- onBack ( )
47- } else if ( input === "q" ) {
48- exit ( )
49- }
50- } )
51- return (
52- < Box flexDirection = "column" >
53- < Text bold > Select a version of { expertName } to unpublish:</ Text >
54- < Box flexDirection = "column" marginTop = { 1 } >
55- { versions . map ( ( v , index ) => (
56- < Box key = { v . key } >
57- < Text color = { index === selectedIndex ? "cyan" : undefined } >
58- { index === selectedIndex ? "❯ " : " " }
59- { v . version }
60- { v . tags . length > 0 && < Text color = "magenta" > [{ v . tags . join ( ", " ) } ]</ Text > }
61- < Text color = { getStatusColor ( v . status ) } > { v . status } </ Text >
62- </ Text >
63- </ Box >
64- ) ) }
65- </ Box >
66- < Box marginTop = { 1 } >
67- < Text dimColor > ↑↓ navigate · enter select · esc back · q quit</ Text >
68- </ Box >
69- </ Box >
70- )
71- }
7221function ConfirmStep ( {
7322 expertKey,
7423 version,
@@ -199,6 +148,7 @@ export function UnpublishApp({
199148 versions = { step . versions }
200149 onSelect = { handleVersionSelect }
201150 onBack = { handleBack }
151+ title = { `Select a version of ${ step . expertName } to unpublish:` }
202152 />
203153 )
204154 case "confirm" :
0 commit comments