ShowErrorModal displays an error message in a modal
(title, message string, onClose func())
| 525 | |
| 526 | // ShowErrorModal displays an error message in a modal |
| 527 | func (u *UIManager) ShowErrorModal(title, message string, onClose func()) { |
| 528 | pages := u.app.Pages() |
| 529 | |
| 530 | closeError := func() { |
| 531 | pages.RemovePage("commandError") |
| 532 | if onClose != nil { |
| 533 | onClose() |
| 534 | } |
| 535 | } |
| 536 | |
| 537 | modal := tview.NewModal(). |
| 538 | SetText(fmt.Sprintf("%s\n\n%s", title, message)). |
| 539 | AddButtons([]string{"OK"}). |
| 540 | SetDoneFunc(func(buttonIndex int, buttonLabel string) { |
| 541 | closeError() |
| 542 | }) |
| 543 | modal.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { |
| 544 | if isBackKey(event) { |
| 545 | closeError() |
| 546 | return nil |
| 547 | } |
| 548 | |
| 549 | return event |
| 550 | }) |
| 551 | |
| 552 | pages.AddPage("commandError", modal, true, true) |
| 553 | } |
| 554 | |
| 555 | // parseContainerTarget parses a container target string in the format "node/vmid" |
| 556 | // and returns the node name and container ID. |
no test coverage detected