tui

package
v0.17.3 Latest Latest
Warning

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

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

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) OnKey

func (l *ListPR) OnKey(key string, _ int, pr git.PullRequest) (reload bool, err error)

OnKey reacts on user's key presses.

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)
	Approve(ctx context.Context, projectID string, prNumber int) 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