tui

package
v0.14.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2023 License: MIT Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ListPRColumns = []teax.Column[git.PullRequest]{
	{
		Column:  table.Column{Title: `Total: {{.Total}}`, Width: 6},
		Extract: func(pr git.PullRequest) string { return pr.Project.Name },
	},
	{
		Column:  table.Column{Title: "No.", Width: 1},
		Extract: func(pr git.PullRequest) string { return strconv.Itoa(pr.Number) },
	},
	{
		Column:  table.Column{Title: "Title (last update: {{.LastReload.Format \"15:04:05\" }}, Δ: {{.LoadedIn.String}})", Width: 16},
		Extract: func(pr git.PullRequest) string { return pr.Title },
	},
	{
		Column:  table.Column{Title: "Author", Width: 4},
		Extract: func(pr git.PullRequest) string { return pr.Author.Username },
	},
	{
		Column:  table.Column{Title: "Created At", Width: 3},
		Extract: func(pr git.PullRequest) string { return pr.CreatedAt.Format("2006-01-02") },
	},
	{
		Column: table.Column{Title: "Threads", Width: 2},
		Extract: func(pr git.PullRequest) string {
			resolved := lo.CountBy(pr.Threads, func(t git.Comment) bool { return t.Resolved })
			return fmt.Sprintf("%d/%d (%s)",
				resolved, len(pr.Threads),
				checkmark(resolved == len(pr.Threads)),
			)
		},
	},
	{
		Column: table.Column{Title: "Approvals", Width: 3},
		Extract: func(pr git.PullRequest) string {
			return fmt.Sprintf("%d/%d (%s)",
				len(pr.Approvals.By), pr.Approvals.Required,
				checkmark(pr.Approvals.SatisfiesRules),
			)
		},
	},
}

ListPRColumns are the columns to show in the table.

Functions

func NewListPR

func NewListPR(ctx context.Context, params ListPRParams) (tea.Model, error)

NewListPR returns a new ListPR TUI.

func Version

func Version(version string) string

Version makes a prettified view of the version.

Types

type ListPR

type ListPR struct {
	ListPRParams
	tea.Model
	// contains filtered or unexported fields
}

ListPR is a TUI to list merge requests.

func (*ListPR) Load

func (l *ListPR) Load() ([]git.PullRequest, error)

Load loads the merge requests.

func (*ListPR) OnEnter

func (l *ListPR) OnEnter(pr git.PullRequest) error

OnEnter either opens the merge request in the browser or copies the URL to the clipboard.

func (*ListPR) Update

func (l *ListPR) Update(msg tea.Msg) (_ tea.Model, cmd tea.Cmd)

Update updates the model.

func (*ListPR) View

func (l *ListPR) View() string

View adds the version to the table view.

type ListPRParams

type ListPRParams struct {
	Service      PRStore
	Request      service.ListPRsRequest
	OpenOnEnter  bool
	PollInterval time.Duration
	Version      string
}

ListPRParams are the parameters to initialize a ListPR TUI.

type PRStore

type PRStore interface {
	ListPullRequests(ctx context.Context, req service.ListPRsRequest) ([]git.PullRequest, error)
}

PRStore is a store of pull requests.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL