package interactive
import (
"github.com/manifoldco/promptui"
"gitlab.com/pcanilho/go-jira-cli/internal"
)
type userTop struct {
promptui.Select
controller internal.Controller
next, previous Menu
}
var useTopItems = []string{PreviousMenu, "Search by ...", "Get by username"}
const (
searchBySelected = iota + 1
getByUsernameSelected
)
var userTopTemplate = &promptui.SelectTemplates{
Label: "-------- User Menu --------",
Active: "→ {{ . | cyan }}",
Inactive: " {{ . | cyan }}",
Selected: "→ {{ . | red | cyan }}",
}
func NewUserTopMenu(parent Menu) Menu {
return &userTop{
previous: parent,
Select: promptui.Select{
HideSelected: true,
Templates: userTopTemplate,
Items: useTopItems,
},
}
}
func (mut *userTop) AttachController(controller internal.Controller) {
mut.controller = controller
}
func (mut *userTop) Render() (int, string, error) {
i, _, _ := mut.Run()
switch i {
case PreviousSelected:
mut.next = mut.previous
case searchBySelected:
// @TODO - userSearchByMenu
case getByUsernameSelected:
mut.next = NewUserPrompt(mut)
}
mut.next.AttachController(mut.controller)
return mut.next.Render()
}
|
The pages are generated with Golds v0.3.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |