Keep parent breadcrumb on phone
This commit is contained in:
@@ -5364,7 +5364,7 @@ func (u *ui) visibleBreadcrumbs(displayPath []string) ([]string, []int) {
|
|||||||
return indices
|
return indices
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
if u.mode != "phone" || len(displayPath) <= 1 {
|
if u.mode != "phone" || len(displayPath) <= 2 {
|
||||||
crumbs := append([]string{"/"}, append([]string{}, displayPath...)...)
|
crumbs := append([]string{"/"}, append([]string{}, displayPath...)...)
|
||||||
indices := make([]int, 0, len(crumbs))
|
indices := make([]int, 0, len(crumbs))
|
||||||
indices = append(indices, 0)
|
indices = append(indices, 0)
|
||||||
@@ -5373,9 +5373,6 @@ func (u *ui) visibleBreadcrumbs(displayPath []string) ([]string, []int) {
|
|||||||
}
|
}
|
||||||
return crumbs, indices
|
return crumbs, indices
|
||||||
}
|
}
|
||||||
if len(displayPath) == 2 {
|
|
||||||
return []string{"/", displayPath[len(displayPath)-1]}, []int{0, len(displayPath)}
|
|
||||||
}
|
|
||||||
crumbs := []string{"/", "…", displayPath[len(displayPath)-1]}
|
crumbs := []string{"/", "…", displayPath[len(displayPath)-1]}
|
||||||
indices := []int{0, len(displayPath) - 1, len(displayPath)}
|
indices := []int{0, len(displayPath) - 1, len(displayPath)}
|
||||||
return crumbs, indices
|
return crumbs, indices
|
||||||
|
|||||||
+17
-4
@@ -5197,11 +5197,11 @@ func TestUIVisibleBreadcrumbsCompressesAggressivelyOnPhone(t *testing.T) {
|
|||||||
u := newUIWithModel("phone", vault.Model{})
|
u := newUIWithModel("phone", vault.Model{})
|
||||||
|
|
||||||
gotCrumbs, gotIndices := u.visibleBreadcrumbs([]string{"Root", "Infrastructure"})
|
gotCrumbs, gotIndices := u.visibleBreadcrumbs([]string{"Root", "Infrastructure"})
|
||||||
if !slices.Equal(gotCrumbs, []string{"/", "Infrastructure"}) {
|
if !slices.Equal(gotCrumbs, []string{"/", "Root", "Infrastructure"}) {
|
||||||
t.Fatalf("visibleBreadcrumbs() crumbs = %v, want [\"/\" Infrastructure]", gotCrumbs)
|
t.Fatalf("visibleBreadcrumbs() crumbs = %v, want [\"/\" Root Infrastructure]", gotCrumbs)
|
||||||
}
|
}
|
||||||
if !slices.Equal(gotIndices, []int{0, 2}) {
|
if !slices.Equal(gotIndices, []int{0, 1, 2}) {
|
||||||
t.Fatalf("visibleBreadcrumbs() indices = %v, want [0 2]", gotIndices)
|
t.Fatalf("visibleBreadcrumbs() indices = %v, want [0 1 2]", gotIndices)
|
||||||
}
|
}
|
||||||
|
|
||||||
gotCrumbs, gotIndices = u.visibleBreadcrumbs([]string{"Root", "Infrastructure", "SSH"})
|
gotCrumbs, gotIndices = u.visibleBreadcrumbs([]string{"Root", "Infrastructure", "SSH"})
|
||||||
@@ -5213,6 +5213,19 @@ func TestUIVisibleBreadcrumbsCompressesAggressivelyOnPhone(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUIPhoneVisibleBreadcrumbsKeepParentForTwoSegmentPath(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
u := newUIWithModel("phone", vault.Model{})
|
||||||
|
gotCrumbs, gotIndices := u.visibleBreadcrumbs([]string{"Crew", "Internet"})
|
||||||
|
if !slices.Equal(gotCrumbs, []string{"/", "Crew", "Internet"}) {
|
||||||
|
t.Fatalf("visibleBreadcrumbs() crumbs = %v, want [\"/\" Crew Internet]", gotCrumbs)
|
||||||
|
}
|
||||||
|
if !slices.Equal(gotIndices, []int{0, 1, 2}) {
|
||||||
|
t.Fatalf("visibleBreadcrumbs() indices = %v, want [0 1 2]", gotIndices)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestUILocalLifecycleActionErrorsAreVisibleAndSpecific(t *testing.T) {
|
func TestUILocalLifecycleActionErrorsAreVisibleAndSpecific(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user