Skip to content

Commit 852f643

Browse files
committed
feat: enable features radio soon to be checkbox
1 parent a9a44c1 commit 852f643

File tree

1 file changed

+55
-8
lines changed

1 file changed

+55
-8
lines changed

models/weaveinit/run_l1_node.go

+55-8
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func (m *RunL1NodeVersionInput) Init() tea.Cmd {
8787
func (m *RunL1NodeVersionInput) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
8888
input, done := m.TextInput.Update(msg)
8989
if done {
90-
m.state.initiadVersion = string(input.Text)
90+
m.state.initiadVersion = input.Text
9191
return NewRunL1NodeChainIdInput(m.state), nil
9292
}
9393
m.TextInput = input
@@ -117,7 +117,7 @@ func (m *RunL1NodeChainIdInput) Init() tea.Cmd {
117117
func (m *RunL1NodeChainIdInput) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
118118
input, done := m.TextInput.Update(msg)
119119
if done {
120-
m.state.chainId = string(input.Text)
120+
m.state.chainId = input.Text
121121
return NewRunL1NodeMonikerInput(m.state), nil
122122
}
123123
m.TextInput = input
@@ -147,7 +147,7 @@ func (m *RunL1NodeMonikerInput) Init() tea.Cmd {
147147
func (m *RunL1NodeMonikerInput) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
148148
input, done := m.TextInput.Update(msg)
149149
if done {
150-
m.state.moniker = string(input.Text)
150+
m.state.moniker = input.Text
151151
fmt.Println("\n[info] state", m.state)
152152
return NewExistingAppChecker(m.state), utils.DoTick()
153153
}
@@ -182,8 +182,10 @@ func (m *ExistingAppChecker) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
182182
return m, tea.Quit
183183
}
184184

185-
configTomlPath := filepath.Join(homeDir, ".initia", "config", "config.toml")
186-
if !utils.FileOrFolderExists(configTomlPath) {
185+
initiaConfigPath := filepath.Join(homeDir, ".initia", "config")
186+
appTomlPath := filepath.Join(initiaConfigPath, "app.toml")
187+
configTomlPath := filepath.Join(initiaConfigPath, "config.toml")
188+
if !utils.FileOrFolderExists(configTomlPath) || !utils.FileOrFolderExists(appTomlPath) {
187189
m.state.existingApp = false
188190
return NewMinGasPriceInput(m.state), nil
189191
} else {
@@ -233,6 +235,7 @@ func (m *ExistingAppReplaceSelect) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
233235
switch *selected {
234236
case UseCurrent:
235237
m.state.replaceExistingApp = false
238+
// TODO: Continue
236239
fmt.Println("\n[info] Using current files")
237240
case Replace:
238241
m.state.replaceExistingApp = true
@@ -275,8 +278,8 @@ func (m *MinGasPriceInput) Init() tea.Cmd {
275278
func (m *MinGasPriceInput) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
276279
input, done := m.TextInput.Update(msg)
277280
if done {
278-
m.state.minGasPrice = string(input.Text)
279-
return m, tea.Quit
281+
m.state.minGasPrice = input.Text
282+
return NewEnableFeaturesCheckbox(m.state), nil
280283
}
281284
m.TextInput = input
282285
return m, nil
@@ -285,7 +288,51 @@ func (m *MinGasPriceInput) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
285288
func (m *MinGasPriceInput) View() string {
286289
preText := ""
287290
if !m.state.existingApp {
288-
preText += "No existing .initia directory found. Creating a new one.\n"
291+
preText += "i There is no config/app.toml or config/config.toml available. You will need to enter the required information to proceed.\n\n"
289292
}
290293
return fmt.Sprintf("%s? Please specify min-gas-price (uinit)\n> %s\n", preText, m.TextInput.View())
291294
}
295+
296+
type EnableFeaturesCheckbox struct {
297+
utils.Selector[EnableFeaturesOption]
298+
state *RunL1NodeState
299+
}
300+
301+
type EnableFeaturesOption string
302+
303+
const (
304+
LCD EnableFeaturesOption = "LCD API"
305+
gRPC EnableFeaturesOption = "gRPC"
306+
)
307+
308+
func NewEnableFeaturesCheckbox(state *RunL1NodeState) *EnableFeaturesCheckbox {
309+
return &EnableFeaturesCheckbox{
310+
Selector: utils.Selector[EnableFeaturesOption]{
311+
Options: []EnableFeaturesOption{
312+
LCD,
313+
gRPC,
314+
},
315+
},
316+
state: state,
317+
}
318+
}
319+
320+
func (m *EnableFeaturesCheckbox) Init() tea.Cmd {
321+
return nil
322+
}
323+
324+
func (m *EnableFeaturesCheckbox) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
325+
return m, nil
326+
}
327+
328+
func (m *EnableFeaturesCheckbox) View() string {
329+
view := "? Would you like to enable the following options?\n"
330+
for i, option := range m.Options {
331+
if i == m.Cursor {
332+
view += "(■) " + string(option) + "\n"
333+
} else {
334+
view += "( ) " + string(option) + "\n"
335+
}
336+
}
337+
return view + "\nUse arrow-keys. Space to select. Return to submit, or q to quit."
338+
}

0 commit comments

Comments
 (0)