Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions internal/setup/flag_toggle.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (m flagToggleModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch {
case key.Matches(msg, keys.Enter):
case key.Matches(msg, keys.Toggle):
m.enabled = !m.enabled
}
}
Expand All @@ -33,13 +33,13 @@ func (m flagToggleModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {

func (m flagToggleModel) View() string {
var furtherInstructions string
title := "Toggle your feature flag!"
title := "Toggle your feature flag (press tab)"
toggle := "OFF"
bgColor := "#646a73"
margin := 1
if m.enabled {
bgColor = "#3d9c51"
furtherInstructions = "\n\nCheck your [browser|application logs] to see the change."
furtherInstructions = "\n\nCheck your [browser|application logs] to see the change!"
margin = 2
toggle = "ON"
}
Expand Down
21 changes: 17 additions & 4 deletions internal/setup/wizard.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/charmbracelet/bubbles/key"
tea "github.com/charmbracelet/bubbletea"
"github.com/muesli/reflow/wordwrap"
)

// TODO: we may want to rename this for clarity
Expand Down Expand Up @@ -102,7 +103,10 @@ func (m WizardModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case flagToggleStep:
updatedModel, _ := m.steps[flagToggleStep].Update(msg)
m.steps[flagToggleStep] = updatedModel
m.currStep += 1
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

increment here on enter so we can see the final text

default:
return m, tea.Quit
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we're here that means we're done! will prevent out of index errors


}
case key.Matches(msg, keys.Back):
// only go back if not on the first step
Expand Down Expand Up @@ -130,14 +134,19 @@ func (m WizardModel) View() string {
return fmt.Sprintf("ERROR: %s", m.err)
}

if m.currStep > flagToggleStep {
return wordwrap.String("\nCongratulations! You’ve just used feature flags to control how your application works, without having to rebuild or redeploy your application.\n\nNow that you’re set up with your first feature flag, let’s make it easier to manage your flags collaboratively with your team. <Instructions will go here>", m.width)
}

return fmt.Sprintf("\nStep %d of %d\n"+m.steps[m.currStep].View(), m.currStep+1, len(m.steps))
}

type keyMap struct {
Back key.Binding
Enter key.Binding
Help key.Binding
Quit key.Binding
Back key.Binding
Enter key.Binding
Help key.Binding
Quit key.Binding
Toggle key.Binding
}

var keys = keyMap{
Expand All @@ -157,4 +166,8 @@ var keys = keyMap{
key.WithKeys("ctrl+c", "q"),
key.WithHelp("q", "quit"),
),
Toggle: key.NewBinding(
key.WithKeys("tab"),
key.WithHelp("tab", "toggle"),
),
}