Hide synthetic vault root beside recycle bin
This commit is contained in:
@@ -5136,6 +5136,33 @@ func TestUIAutoEntersSingleVaultRootGroupAndDisplaysSlashRoot(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUIAutoEntersSingleVaultRootWhenRecycleBinAlsoExists(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
u := newUIWithModel("desktop", vault.Model{
|
||||||
|
Entries: []vault.Entry{
|
||||||
|
{ID: "vault-console", Title: "Vault Console", Path: []string{"keepass", "Crew", "Internet"}},
|
||||||
|
},
|
||||||
|
Groups: [][]string{
|
||||||
|
{"keepass"},
|
||||||
|
{"keepass", "Crew"},
|
||||||
|
{"Recycle Bin"},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
u.showEntriesSection()
|
||||||
|
|
||||||
|
if got := u.currentPath; !slices.Equal(got, []string{"keepass"}) {
|
||||||
|
t.Fatalf("currentPath = %v, want [keepass]", got)
|
||||||
|
}
|
||||||
|
if got := u.displayPath(); len(got) != 0 {
|
||||||
|
t.Fatalf("displayPath() = %v, want root slash path", got)
|
||||||
|
}
|
||||||
|
if got := u.childGroups(); !slices.Equal(got, []string{"Crew"}) {
|
||||||
|
t.Fatalf("childGroups() = %v, want [Crew]", got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestUIShowEntriesSectionRestoresHiddenRootAfterLeavingEntries(t *testing.T) {
|
func TestUIShowEntriesSectionRestoresHiddenRootAfterLeavingEntries(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
|||||||
@@ -1270,10 +1270,17 @@ func (u *ui) hiddenVaultRoot() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
groups := model.ChildGroups(nil)
|
groups := model.ChildGroups(nil)
|
||||||
if len(groups) != 1 {
|
roots := make([]string, 0, len(groups))
|
||||||
|
for _, group := range groups {
|
||||||
|
if group == "Recycle Bin" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
roots = append(roots, group)
|
||||||
|
}
|
||||||
|
if len(roots) != 1 {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
return groups[0]
|
return roots[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *ui) enterHiddenVaultRoot() {
|
func (u *ui) enterHiddenVaultRoot() {
|
||||||
|
|||||||
Reference in New Issue
Block a user