- Added internal/vault/client.go for creating a Vault client with configuration settings. - Introduced internal/vault/errors.go to classify Vault API errors for better UI handling. - Created internal/vault/kv.go to manage KV secrets, including listing, reading, writing, and deleting operations. - Implemented internal/vault/mounts.go to list and describe secret engine mounts. - Developed internal/vault/service.go to provide a unified entry point for Vault operations. - Added internal/vault/kv_test.go for comprehensive testing of KV operations. - Introduced internal/ui/toast.go for transient notifications in the UI. - Added renovate.json for dependency management and updates.
61 lines
1.3 KiB
Go
61 lines
1.3 KiB
Go
package ui
|
|
|
|
import (
|
|
tea "charm.land/bubbletea/v2"
|
|
"charm.land/lipgloss/v2"
|
|
)
|
|
|
|
func (m *Model) updateConfirm(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) {
|
|
c := m.confirm
|
|
if c.typeToConf != "" {
|
|
switch msg.String() {
|
|
case "esc":
|
|
m.confirm = nil
|
|
return m, nil
|
|
case "enter":
|
|
if c.input == c.typeToConf {
|
|
cmd := c.onConfirm()
|
|
m.confirm = nil
|
|
return m, cmd
|
|
}
|
|
return m, nil
|
|
case "backspace":
|
|
if len(c.input) > 0 {
|
|
c.input = c.input[:len(c.input)-1]
|
|
}
|
|
return m, nil
|
|
default:
|
|
if len(msg.Text) > 0 {
|
|
c.input += msg.Text
|
|
}
|
|
return m, nil
|
|
}
|
|
}
|
|
switch msg.String() {
|
|
case "y", "enter":
|
|
cmd := c.onConfirm()
|
|
m.confirm = nil
|
|
return m, cmd
|
|
case "n", "esc":
|
|
m.confirm = nil
|
|
return m, nil
|
|
}
|
|
return m, nil
|
|
}
|
|
|
|
func (m *Model) viewConfirm() string {
|
|
c := m.confirm
|
|
style := m.styles.Modal
|
|
if c.danger {
|
|
style = m.styles.ModalDanger
|
|
}
|
|
w := m.modalWrapWidth()
|
|
lines := []string{m.styles.ModalTitle.Render(c.title), lipgloss.Wrap(c.body, w, ""), ""}
|
|
if c.typeToConf != "" {
|
|
lines = append(lines, "Type "+c.typeToConf+" to confirm:", "> "+c.input)
|
|
} else {
|
|
lines = append(lines, m.styles.Help.Render("y/enter confirm • n/esc cancel"))
|
|
}
|
|
return style.Render(lipgloss.JoinVertical(lipgloss.Left, lines...))
|
|
}
|