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

UI/exit node status indicators (emphasizes the added functionality) #177

Closed
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
4 changes: 2 additions & 2 deletions cmd/tailscale/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ func (s *BackendState) updateExitNodes() {
hasMyExit = hasMyExit || myExit
exit := Peer{
Label: p.DisplayName(true),
Online: canRoute,
Online: *p.Online(),
ID: p.StableID(),
Location: p.Hostinfo().Location(),
}
Expand All @@ -729,7 +729,7 @@ func (s *BackendState) updateExitNodes() {

if myExit {
s.Exit = exit
if canRoute {
if canRoute && *p.Online() {
s.ExitStatus = ExitOnline
}
}
Expand Down
56 changes: 40 additions & 16 deletions cmd/tailscale/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -1064,20 +1064,24 @@ func (ui *UI) layoutExitNodeDialog(gtx layout.Context, sysIns system.Insets, exi
if idx >= 2 {
node = exits[idx-2]
}
lbl := node.Label
if !node.Online {
lbl = lbl + " (offline)"
}
btn := material.RadioButton(ui.theme, &d.exits, string(node.ID), lbl)
if !node.Online {
if node.Online {
btn := material.RadioButton(ui.theme, &d.exits, string(node.ID), node.Label)
return layout.Inset{
Right: unit.Dp(16),
Left: unit.Dp(16),
Bottom: unit.Dp(16),
}.Layout(gtx, btn.Layout)
} else {
node.Label = node.Label + " (offline)"
btn := material.RadioButton(ui.theme, &d.exits, string(node.ID), node.Label)
btn.Color = rgb(0xbbbbbb)
btn.IconColor = btn.Color
return layout.Inset{
Right: unit.Dp(16),
Left: unit.Dp(16),
Bottom: unit.Dp(16),
}.Layout(gtx, btn.Layout)
}
return layout.Inset{
Right: unit.Dp(16),
Left: unit.Dp(16),
Bottom: unit.Dp(16),
}.Layout(gtx, btn.Layout)
})
}),
)
Expand Down Expand Up @@ -1317,10 +1321,30 @@ func (ui *UI) layoutPeer(gtx layout.Context, sysIns system.Insets, p *UIPeer, us
gtx.Constraints.Min.X = gtx.Constraints.Max.X
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(func(gtx C) D {
return layout.Inset{Bottom: unit.Dp(4)}.Layout(gtx, func(gtx C) D {
name := p.Peer.DisplayName(p.Peer.User == user)
return material.H6(ui.theme, name).Layout(gtx)
})
return layout.Stack{}.Layout(gtx,
layout.Expanded(func(gtx C) D {
return layout.Stack{Alignment: layout.W}.Layout(gtx,
layout.Stacked(func(gtx C) D {
return layout.Inset{}.Layout(gtx, func(gtx C) D {
statusbullet := material.H4(ui.theme, "•")
if p.Peer.Online != nil && *p.Peer.Online {
statusbullet.Color = rgb(0x009966)
} else {
statusbullet.Color = rgb(0xcccccc)
}
return statusbullet.Layout(gtx)
})
}),
layout.Stacked(func(gtx C) D {
return layout.Inset{Left: unit.Dp(16), Bottom: unit.Dp(4)}.Layout(gtx, func(gtx C) D {
name := p.Peer.DisplayName(p.Peer.User == user)
return material.H6(ui.theme, name).Layout(gtx)
})
}),
)
}),
)

}),
layout.Rigid(func(gtx C) D {
var bestIP netip.Addr // IP to show; first IPv4, or first IPv6 if no IPv4
Expand Down Expand Up @@ -1472,7 +1496,7 @@ func (ui *UI) layoutSearchbar(gtx layout.Context, sysIns system.Insets) layout.D
return ui.icons.search.Layout(gtx, col)
}),
layout.Flexed(1,
material.Editor(ui.theme, &ui.search, "Search by machine name...").Layout,
material.Editor(ui.theme, &ui.search, "Search by device name...").Layout,
),
)
})
Expand Down