-
Notifications
You must be signed in to change notification settings - Fork 13
feat: Can go back to choose SDK page from show SDK instructions #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,17 +19,16 @@ const ( | |
| // ContainerModel is a high level container model that controls the nested models wher each | ||
| // represents a step in the quick-start flow. | ||
| type ContainerModel struct { | ||
| err error | ||
| flagKey string | ||
| flagsClient flags.Client | ||
| quitMsg string // TODO: set this? | ||
| quitting bool | ||
|
|
||
| accessToken string | ||
| baseUri string | ||
| currentModel tea.Model | ||
| currentStep int | ||
| sdkKind string | ||
| err error | ||
| flagKey string | ||
| flagsClient flags.Client | ||
| quitMsg string // TODO: set this? | ||
| quitting bool | ||
| sdk sdkDetail | ||
| totalSteps int | ||
| } | ||
|
|
||
|
|
@@ -55,32 +54,57 @@ func (m ContainerModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { | |
| case key.Matches(msg, keys.Quit): | ||
| m.quitting = true | ||
| cmd = tea.Quit | ||
| case key.Matches(msg, keys.Back): | ||
| // if showing SDK instructions, let the user go back to choose a different SDK | ||
| if m.currentStep == 2 { | ||
| m.currentStep -= 1 | ||
| m.currentModel = NewChooseSDKModel(m.sdk.index) | ||
| cmd = m.currentModel.Init() | ||
| } | ||
| default: | ||
| // delegate all other input to the current model | ||
| m.currentModel, cmd = m.currentModel.Update(msg) | ||
| } | ||
| case choseSDKMsg: | ||
| m.currentModel = NewShowSDKInstructionsModel(m.accessToken, m.baseUri, msg.canonicalName, msg.url, m.flagKey) | ||
| m.currentModel = NewShowSDKInstructionsModel( | ||
| m.accessToken, | ||
| m.baseUri, | ||
| msg.sdk.canonicalName, | ||
| msg.sdk.url, | ||
| m.flagKey, | ||
| ) | ||
| cmd = m.currentModel.Init() | ||
| m.sdkKind = msg.sdkKind | ||
| m.sdk = msg.sdk | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm passing the entire sdk details instead of its fields. |
||
| m.currentStep += 1 | ||
| case createdFlagMsg: | ||
| m.currentModel = NewChooseSDKModel() | ||
| m.currentModel = NewChooseSDKModel(0) | ||
| m.flagKey = msg.flagKey // TODO: figure out if we maintain state here or pass in another message | ||
| m.currentStep += 1 | ||
| case errMsg: | ||
| m.err = msg.err | ||
| case noInstructionsMsg: | ||
| // skip the ShowSDKInstructionsModel and move along to toggling the flag | ||
| m.currentModel = NewToggleFlagModel(m.flagsClient, m.accessToken, m.baseUri, m.flagKey, m.sdkKind) | ||
| m.currentModel = NewToggleFlagModel( | ||
| m.flagsClient, | ||
| m.accessToken, | ||
| m.baseUri, | ||
| m.flagKey, | ||
| m.sdk.kind, | ||
| ) | ||
| m.currentStep += 1 | ||
| case fetchedSDKInstructions, fetchedEnv, toggledFlagMsg: | ||
| case fetchedSDKInstructions, fetchedEnv, selectedSDKMsg, toggledFlagMsg: | ||
| m.currentModel, cmd = m.currentModel.Update(msg) | ||
| case showToggleFlagMsg: | ||
| m.currentModel = NewToggleFlagModel(m.flagsClient, m.accessToken, m.baseUri, m.flagKey, m.sdkKind) | ||
| m.currentModel = NewToggleFlagModel( | ||
| m.flagsClient, | ||
| m.accessToken, | ||
| m.baseUri, | ||
| m.flagKey, | ||
| m.sdk.kind, | ||
| ) | ||
| m.currentStep += 1 | ||
| default: | ||
| log.Println("container default - bad", msg) | ||
| log.Printf("container default: %T\n", msg) | ||
| } | ||
|
|
||
| return m, cmd | ||
|
|
@@ -113,12 +137,17 @@ func (m ContainerModel) View() string { | |
| } | ||
|
|
||
| type keyMap struct { | ||
| Back key.Binding | ||
| Enter key.Binding | ||
| Quit key.Binding | ||
| Tab key.Binding | ||
| } | ||
|
|
||
| var keys = keyMap{ | ||
| Back: key.NewBinding( | ||
| key.WithKeys("esc"), | ||
| key.WithHelp("esc", "go back"), | ||
| ), | ||
| Enter: key.NewBinding( | ||
| key.WithKeys("enter"), | ||
| key.WithHelp("enter", "select"), | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this and sorted the others.