Skip to content

Commit

Permalink
Set custom URL for vue SDK (#106)
Browse files Browse the repository at this point in the history
The vue SDK doesn't have a "hello-vue" repository like the other SDKs,
so we need to handle this case by defining where its instructions are.
  • Loading branch information
dbolson authored Apr 2, 2024
1 parent c575248 commit 606520b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
7 changes: 7 additions & 0 deletions internal/quickstart/choose_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ type sdkDetail struct {
canonicalName string
displayName string
kind string
url string // custom URL if it differs from the other SDKs
}

func (s sdkDetail) FilterValue() string { return "" }
Expand All @@ -85,6 +86,12 @@ var SDKs = []sdkDetail{
{canonicalName: "java", displayName: "Java", kind: serverSideSDK},
{canonicalName: "dotnet-server", displayName: ".NET (server-side)", kind: serverSideSDK},
{canonicalName: "js", displayName: "JavaScript", kind: clientSideSDK},
{
canonicalName: "vue",
displayName: "Vue",
kind: clientSideSDK,
url: "https://raw.githubusercontent.com/launchdarkly/vue-client-sdk/main/example/README.md",
},
{canonicalName: "ios-swift", displayName: "iOS", kind: clientSideSDK},
{canonicalName: "go", displayName: "Go", kind: serverSideSDK},
{canonicalName: "android", displayName: "Android", kind: clientSideSDK},
Expand Down
8 changes: 2 additions & 6 deletions internal/quickstart/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (m ContainerModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if model, ok := updated.(chooseSDKModel); ok {
m.sdk = model.selectedSDK
m.currentStep += 1
cmd = sendFetchSDKInstructionsMsg(m.sdk.canonicalName, m.sdk.displayName)
cmd = sendFetchSDKInstructionsMsg(m.sdk, m.flagKey)

}
case showSDKInstructionsStep:
Expand All @@ -105,11 +105,7 @@ func (m ContainerModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case errMsg:
m.err = msg.err
case fetchSDKInstructionsMsg:
updated, cmd = m.steps[showSDKInstructionsStep].Update(fetchSDKInstructionsMsg{
canonicalName: m.sdk.canonicalName,
flagKey: m.flagKey,
name: m.sdk.displayName,
})
updated, cmd = m.steps[showSDKInstructionsStep].Update(msg)
if model, ok := updated.(showSDKInstructionsModel); ok {
model.sdk = m.sdk.displayName
m.steps[showSDKInstructionsStep] = model
Expand Down
9 changes: 6 additions & 3 deletions internal/quickstart/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ type fetchSDKInstructionsMsg struct {
canonicalName string
flagKey string
name string
url string
}

func sendFetchSDKInstructionsMsg(canonicalName string, displayName string) tea.Cmd {
func sendFetchSDKInstructionsMsg(sdk sdkDetail, flagKey string) tea.Cmd {
return func() tea.Msg {
return fetchSDKInstructionsMsg{
canonicalName: canonicalName,
name: displayName,
canonicalName: sdk.canonicalName,
flagKey: flagKey,
name: sdk.displayName,
url: sdk.url,
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion internal/quickstart/show_sdk_instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ func NewShowSDKInstructionsModel() tea.Model {
}

func (m showSDKInstructionsModel) Init() tea.Cmd {
// send command to make request?
return nil
}

func (m showSDKInstructionsModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case fetchSDKInstructionsMsg:
url := fmt.Sprintf(instructionsURL, msg.canonicalName)
if msg.url != "" {
url = msg.url
}
c := &http.Client{
Timeout: 5 * time.Second,
}
Expand Down

0 comments on commit 606520b

Please sign in to comment.