mirror of
https://github.com/Gu1llaum-3/sshm.git
synced 2025-10-19 01:17:20 +02:00
feat: show error when move requires includes but none found
This commit is contained in:
parent
3c627a5d21
commit
306f38e862
@ -99,6 +99,10 @@ type Model struct {
|
|||||||
height int
|
height int
|
||||||
styles Styles
|
styles Styles
|
||||||
ready bool
|
ready bool
|
||||||
|
|
||||||
|
// Error handling
|
||||||
|
errorMessage string
|
||||||
|
showingError bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// updateTableStyles updates the table header border color based on focus state
|
// updateTableStyles updates the table header border color based on focus state
|
||||||
|
@ -42,7 +42,7 @@ func NewMoveForm(hostName string, styles Styles, width, height int, configFile s
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(files) == 0 {
|
if len(files) == 0 {
|
||||||
return nil, fmt.Errorf("no other config files available to move host to")
|
return nil, fmt.Errorf("no includes found in SSH config file - move operation requires multiple config files")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a custom file selector for move operation
|
// Create a custom file selector for move operation
|
||||||
|
@ -19,6 +19,7 @@ type (
|
|||||||
pingResultMsg *connectivity.HostPingResult
|
pingResultMsg *connectivity.HostPingResult
|
||||||
versionCheckMsg *version.UpdateInfo
|
versionCheckMsg *version.UpdateInfo
|
||||||
versionErrorMsg error
|
versionErrorMsg error
|
||||||
|
errorMsg string
|
||||||
)
|
)
|
||||||
|
|
||||||
// startPingAllCmd creates a command to ping all hosts concurrently
|
// startPingAllCmd creates a command to ping all hosts concurrently
|
||||||
@ -157,6 +158,14 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
// as it might disrupt the user experience
|
// as it might disrupt the user experience
|
||||||
return m, nil
|
return m, nil
|
||||||
|
|
||||||
|
case errorMsg:
|
||||||
|
// Handle general error messages
|
||||||
|
if string(msg) == "clear" {
|
||||||
|
m.showingError = false
|
||||||
|
m.errorMessage = ""
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
|
||||||
case addFormSubmitMsg:
|
case addFormSubmitMsg:
|
||||||
if msg.err != nil {
|
if msg.err != nil {
|
||||||
// Show error in form
|
// Show error in form
|
||||||
@ -587,8 +596,13 @@ func (m Model) handleListViewKeys(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
|
|||||||
hostName := extractHostNameFromTableRow(selected[0]) // Extract hostname from first column
|
hostName := extractHostNameFromTableRow(selected[0]) // Extract hostname from first column
|
||||||
moveForm, err := NewMoveForm(hostName, m.styles, m.width, m.height, m.configFile)
|
moveForm, err := NewMoveForm(hostName, m.styles, m.width, m.height, m.configFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Handle error - could show in UI, e.g., no other config files available
|
// Show error message to user
|
||||||
return m, nil
|
m.errorMessage = err.Error()
|
||||||
|
m.showingError = true
|
||||||
|
return m, func() tea.Msg {
|
||||||
|
time.Sleep(3 * time.Second) // Show error for 3 seconds
|
||||||
|
return errorMsg("clear")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
m.moveForm = moveForm
|
m.moveForm = moveForm
|
||||||
m.viewMode = ViewMove
|
m.viewMode = ViewMove
|
||||||
|
@ -72,6 +72,20 @@ func (m Model) renderListView() string {
|
|||||||
components = append(components, updateStyle.Render(updateText))
|
components = append(components, updateStyle.Render(updateText))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add error message if there's one to show
|
||||||
|
if m.showingError && m.errorMessage != "" {
|
||||||
|
errorStyle := lipgloss.NewStyle().
|
||||||
|
Foreground(lipgloss.Color("9")). // Red color
|
||||||
|
Background(lipgloss.Color("1")). // Dark red background
|
||||||
|
Bold(true).
|
||||||
|
Padding(0, 1).
|
||||||
|
Border(lipgloss.RoundedBorder()).
|
||||||
|
BorderForeground(lipgloss.Color("9")).
|
||||||
|
Align(lipgloss.Center)
|
||||||
|
|
||||||
|
components = append(components, errorStyle.Render("❌ "+m.errorMessage))
|
||||||
|
}
|
||||||
|
|
||||||
// Add the search bar with the appropriate style based on focus
|
// Add the search bar with the appropriate style based on focus
|
||||||
searchPrompt := "Search (/ to focus): "
|
searchPrompt := "Search (/ to focus): "
|
||||||
if m.searchMode {
|
if m.searchMode {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user