refactor: the account pane becomes Fields, the pane for anything but a secret
CI / Checks (pull_request) Successful in 25s
PR title / Conventional title (pull_request) Successful in 1s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kebandClaude Opus 5.5 committed 2026-10-11 10:32:46 +02:00
1 parent 0a80073aad
commit e64748e85d
5 files changed
+46 -44

No files matched your search

@@ -8,10 +8,12 @@ import (
"git.kebcloud.no/keb/lazysecrets/internal/ui/styles"
)
// SourceDetail is the fourth pane on a provider's row: what's known about
// its account, one field per row, to move through, filter and copy from.
// It's a List, so / filters it like the other panes.
type SourceDetail struct {
// Fields is the fourth pane for anything but a secret (an account, and
// what describes vaults, scopes and files): labelled values, one per row,
// a label on the first of several values, to move through, filter and
// copy from. It's a List, so / filters it like the other panes. Secrets
// have Detail, for revealing and versions.
type Fields struct {
List[Field]
}
@@ -22,7 +24,7 @@ type Field struct {
Info bool
}
func NewSourceDetail() SourceDetail {
func NewFields() Fields {
l := NewList("", Item[Field]{
ID: func(f Field) string { return f.Label + "\x00" + f.Value },
Filter: func(f Field) string { return f.Value },
@@ -36,13 +38,13 @@ func NewSourceDetail() SourceDetail {
return ansi.Truncate(st.Label.Render(fmt.Sprintf("%-10s", f.Label))+" "+value, width, "…")
},
})
l.Empty = "nothing known about this account"
return SourceDetail{l}
l.Empty = "nothing to show"
return Fields{l}
}
// Set shows fields under title. Another title (another account) starts
// over, without a filter.
func (s *SourceDetail) Set(title string, fields []Field) {
// Set shows fields under title. Another title (another account or vault)
// starts over, without a filter.
func (s *Fields) Set(title string, fields []Field) {
if title != s.Title {
s.Reset()
s.Title = title
@@ -53,10 +55,10 @@ func (s *SourceDetail) Set(title string, fields []Field) {
}
// Shown reports whether there's anything to show.
func (s SourceDetail) Shown() bool { return len(s.Items()) > 0 }
func (s Fields) Shown() bool { return len(s.Items()) > 0 }
// Selected is the field under the cursor, unless it's an info row.
func (s SourceDetail) Selected() (Field, bool) {
func (s Fields) Selected() (Field, bool) {
f, ok := s.List.Selected()
if !ok || f.Info {
return Field{}, false