Skip to content

Commit

Permalink
task: clean up unused om org select
Browse files Browse the repository at this point in the history
  • Loading branch information
gssbzn committed Mar 8, 2024
1 parent 0447d46 commit 910b2d4
Showing 1 changed file with 4 additions and 25 deletions.
29 changes: 4 additions & 25 deletions internal/prompt/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/mongodb/mongodb-atlas-cli/atlascli/internal/config"
"github.com/mongodb/mongodb-atlas-cli/atlascli/internal/validate"
atlasv2 "go.mongodb.org/atlas-sdk/v20231115007/admin"
atlas "go.mongodb.org/atlas/mongodbatlas"
)

func NewOrgIDInput() survey.Prompt {
Expand Down Expand Up @@ -88,41 +87,21 @@ func NewProfileReplaceConfirm(entry string) survey.Prompt {
}

// NewOrgSelect create a prompt to choice the organization.
func NewOrgSelect(options *[]atlasv2.AtlasOrganization) survey.Prompt {
opt := make([]string, len(*options))
for i, o := range *options {
opt[i] = *o.Id
}

return &survey.Select{
Message: "Choose a default organization:",
Options: opt,
Description: func(_ string, i int) string {
return (*options)[i].Name
},
Filter: func(filter string, _ string, i int) bool {
filter = strings.ToLower(filter)
return strings.HasPrefix(strings.ToLower((*options)[i].Name), filter) || strings.HasPrefix(*(*options)[i].Id, filter)
},
}
}

// NewOnPremOrgSelect create a prompt to choice the organization.
func NewOnPremOrgSelect(options []*atlas.Organization) survey.Prompt {
func NewOrgSelect(options []atlasv2.AtlasOrganization) survey.Prompt {
opt := make([]string, len(options))
for i, o := range options {
opt[i] = o.ID
opt[i] = o.GetId()
}

return &survey.Select{
Message: "Choose a default organization:",
Options: opt,
Description: func(_ string, i int) string {
return options[i].Name
return options[i].GetName()
},
Filter: func(filter string, _ string, i int) bool {
filter = strings.ToLower(filter)
return strings.HasPrefix(strings.ToLower(options[i].Name), filter) || strings.HasPrefix(options[i].ID, filter)
return strings.HasPrefix(strings.ToLower(options[i].GetName()), filter) || strings.HasPrefix(options[i].GetId(), filter)
},
}
}
Expand Down

0 comments on commit 910b2d4

Please sign in to comment.