feat: picking the key shares, with no second popup
The picker already shows what's shared. The confirmation stays for a key from share.key, which wasn't picked. The share format's version is documented as kept readable. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
3 files changed
+31
-7
No files matched your search
@@ -137,13 +137,13 @@ func (m *Model) confirmShare(s sharing) {
|
||||
})
|
||||
}
|
||||
|
||||
// pickShareKey asks which secret to encrypt with, in Go to.
|
||||
// pickShareKey asks which secret to encrypt with, in Go to, then shares
|
||||
// with it.
|
||||
func (m *Model) pickShareKey(s sharing) tea.Cmd {
|
||||
cmd := m.openGoTo(tabSearch, true)
|
||||
m.search.pick = func(m *Model, key ref.Ref) tea.Cmd {
|
||||
s.key = key
|
||||
m.confirmShare(s)
|
||||
return nil
|
||||
return m.seal(s) // the picker showed what's shared
|
||||
}
|
||||
m.search.pickTitle = shareTitle(s)
|
||||
m.search.pickLines = append(m.sharedFiles(s), "",
|
||||
|
||||
@@ -79,10 +79,7 @@ func shareFrom(t *testing.T, root string, paste bool) string {
|
||||
}
|
||||
d.keys("enter")
|
||||
}
|
||||
if !strings.Contains(d.screen(), ".env") || !strings.Contains(d.screen(), "db-password") {
|
||||
t.Errorf("the files and key aren't shown before sharing:\n%s", d.screen())
|
||||
}
|
||||
d.keys("c")
|
||||
// Picking it shares: the picker said what.
|
||||
if !strings.HasPrefix(clip.content, "lazysecrets://share/") {
|
||||
t.Fatalf("copied %q (%s)", clip.content, d.m.flash.text)
|
||||
}
|
||||
@@ -129,6 +126,28 @@ func TestShareFilesRoundTrip(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestShareWithShareKeyConfirms(t *testing.T) {
|
||||
if _, err := exec.LookPath("git"); err != nil {
|
||||
t.Skip("no git")
|
||||
}
|
||||
root := cloneWith(t, map[string]string{
|
||||
".env": "A=1\n",
|
||||
".lazysecrets.yaml": "share:\n key: https://" + kv + "/secrets/db-password\n",
|
||||
})
|
||||
clip := &fakeClipboard{}
|
||||
d := newDriverOpts(t, Options{Clipboard: clip, ShareRules: demoRules}, fake.Azure(0), repo.New(repo.Settings{Dir: root}))
|
||||
d.wait = scryptWait
|
||||
d.keys("S", "f")
|
||||
// The key wasn't picked: it shows which, before sharing.
|
||||
if d.m.search != nil || d.m.prompt == nil || d.m.prompt.title != "Share .env" || !strings.Contains(d.screen(), "db-password") {
|
||||
t.Fatalf("no confirmation:\n%s", d.screen())
|
||||
}
|
||||
d.keys("c")
|
||||
if !strings.HasPrefix(clip.content, "lazysecrets://share/") {
|
||||
t.Errorf("copied %q (%s)", clip.content, d.m.flash.text)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShareLinkElsewhereAsksWhere(t *testing.T) {
|
||||
if _, err := exec.LookPath("git"); err != nil {
|
||||
t.Skip("no git")
|
||||
|
||||
Reference in new issue
Block a user