Skip to content

Commit

Permalink
ui/UserView: show custom control server URL in account switcher
Browse files Browse the repository at this point in the history
Fixes tailscale/corp#23660

Brings each row of the account switcher to parity with iOS by using `LoginName` instead of `DisplayName`, and showing a custom control server hostname as a third row when it is set.

Signed-off-by: Andrea Gottardo <[email protected]>
  • Loading branch information
agottardo committed Oct 4, 2024
1 parent be89cb1 commit e1d7967
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
6 changes: 6 additions & 0 deletions android/src/main/java/com/tailscale/ipn/ui/model/IpnState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,15 @@ class IpnLocal {
val UserProfile: Tailcfg.UserProfile,
val NetworkProfile: Tailcfg.NetworkProfile? = null,
val LocalUserID: String,
var ControlURL: String? = null,
) {
fun isEmpty(): Boolean {
return ID.isEmpty()
}

// Returns true if the profile uses a custom control server (not Tailscale SaaS).
fun isUsingCustomControlServer(): Boolean {
return ControlURL != null && ControlURL != "controlplane.tailscale.com"
}
}
}
22 changes: 16 additions & 6 deletions android/src/main/java/com/tailscale/ipn/ui/view/UserView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package com.tailscale.ipn.ui.view

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.offset
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight
Expand Down Expand Up @@ -54,17 +55,26 @@ fun UserView(
leadingContent = { Avatar(profile = profile, size = 36) },
headlineContent = {
AutoResizingText(
text = profile.UserProfile.DisplayName,
text = profile.UserProfile.LoginName,
style = MaterialTheme.typography.titleMedium.short,
minFontSize = MaterialTheme.typography.minTextSize,
overflow = TextOverflow.Ellipsis)
},
supportingContent = {
AutoResizingText(
text = profile.NetworkProfile?.DomainName ?: "",
style = MaterialTheme.typography.bodyMedium.short,
minFontSize = MaterialTheme.typography.minTextSize,
overflow = TextOverflow.Ellipsis)
Column {
AutoResizingText(
text = profile.NetworkProfile?.DomainName ?: "",
style = MaterialTheme.typography.bodyMedium.short,
minFontSize = MaterialTheme.typography.minTextSize,
overflow = TextOverflow.Ellipsis)
if (profile.isUsingCustomControlServer()) {
AutoResizingText(
text = profile.ControlURL ?: "",
style = MaterialTheme.typography.bodyMedium.short,
minFontSize = MaterialTheme.typography.minTextSize,
overflow = TextOverflow.Ellipsis)
}
}
},
trailingContent = {
when (actionState) {
Expand Down

0 comments on commit e1d7967

Please sign in to comment.