Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warnings for health issues #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions libts/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ type State struct {
// Peer status of the local node.
Self *ipnstate.PeerStatus

// Health contains health check problems.
// Empty means everything is good. (or at least that no known
// problems are detected)
Health []string

// Tailnet lock key. Nil if not enabled.
LockKey *key.NLPublic
// True if the node is locked out by tailnet lock.
Expand Down Expand Up @@ -79,6 +84,7 @@ func MakeState(status *ipnstate.Status, prefs *ipn.Prefs, lock *ipnstate.Network
BackendState: status.BackendState,
TSVersion: status.Version,
Self: status.Self,
Health: status.Health,
SortedExitNodes: getSortedExitNodes(status),
}

Expand Down
1 change: 1 addition & 0 deletions ui/appmenu.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func (i *AppmenuItem) render(isSelected bool, isAnySubmenuOpen bool) string {
arrow := style.
Padding(0, 1).
Render(">")

return left + right + arrow
}

Expand Down
21 changes: 21 additions & 0 deletions view.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,21 @@ func renderLockedOutWarning(m *model) string {
return lipgloss.PlaceHorizontal(m.terminalWidth, lipgloss.Center, lockedOutWarning)
}

// Render the locked out warning. Returns static output; should be called conditionally.
func renderWarnings(m *model) string {
bodyText := "Warning: "

for i, issue := range m.state.Health {
bodyText += issue

if i != len(m.state.Health)-1 {
bodyText += ", "
}
}

return bodyText
}

// Format the top header section.
func renderHeader(m *model) string {
logo := lipgloss.NewStyle().
Expand Down Expand Up @@ -113,6 +128,12 @@ func renderHeader(m *model) string {
Render("--")
}

status += "\n"

if len(m.state.Health) != 0 {
status += renderWarnings(m) + "\n\n"
}

// App versions.
versions := "tsui: " + Version + "\n"
versions += "tailscale: "
Expand Down