fix: change back navigation to 'b' key and improve deletion confirmation with name verification
- Changed 'q' key to 'b' for back navigation in client details - Added 'esc' key binding for back navigation - Updated help text to reflect new key bindings - Created new DeleteConfirmModal component with name verification - User must type exact client name to confirm deletion (safety feature) - Improved modal styling with visual feedback (red/green indicators) - Case-sensitive name matching to prevent accidental deletions Fixes: wg-admin-az7
This commit is contained in:
@@ -17,7 +17,7 @@ type DetailScreen struct {
|
||||
lastHandshake time.Time
|
||||
transferRx string
|
||||
transferTx string
|
||||
confirmModal *components.ConfirmModel
|
||||
confirmModal *components.DeleteConfirmModel
|
||||
showConfirm bool
|
||||
clipboardCopied bool
|
||||
clipboardTimer int
|
||||
@@ -97,16 +97,6 @@ func (s *DetailScreen) Update(msg tea.Msg) (Screen, tea.Cmd) {
|
||||
return s, nil
|
||||
}
|
||||
|
||||
// Handle Enter key to confirm
|
||||
switch msg := msg.(type) {
|
||||
case tea.KeyMsg:
|
||||
if msg.String() == "enter" && s.confirmModal.IsConfirmed() {
|
||||
return s, tea.Batch(s.deleteClient(), func() tea.Msg {
|
||||
return CloseDetailScreenMsg{}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return s, cmd
|
||||
}
|
||||
|
||||
@@ -121,13 +111,13 @@ func (s *DetailScreen) Update(msg tea.Msg) (Screen, tea.Cmd) {
|
||||
s.transferTx = msg.transferTx
|
||||
case tea.KeyMsg:
|
||||
switch msg.String() {
|
||||
case "q", "esc":
|
||||
case "b", "esc":
|
||||
// Return to list screen - signal parent to switch screens
|
||||
return s, nil
|
||||
case "d":
|
||||
// Show delete confirmation
|
||||
s.confirmModal = components.NewConfirm(
|
||||
fmt.Sprintf("Are you sure you want to delete client '%s'?\n\nThis action cannot be undone.", s.client.Name),
|
||||
s.confirmModal = components.NewDeleteConfirm(
|
||||
s.client.Name,
|
||||
80,
|
||||
24,
|
||||
)
|
||||
@@ -196,7 +186,7 @@ func (s *DetailScreen) renderContent() string {
|
||||
)
|
||||
|
||||
// Add help text
|
||||
helpText := detailHelpStyle.Render("Actions: [d] Delete • [c] Copy Public Key • [q] Back")
|
||||
helpText := detailHelpStyle.Render("Actions: [d] Delete • [c] Copy Public Key • [b] Back")
|
||||
content = lipgloss.JoinVertical(lipgloss.Left, content, helpText)
|
||||
|
||||
// Show clipboard confirmation
|
||||
|
||||
Reference in New Issue
Block a user