MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / ShowErrorModal

Method ShowErrorModal

internal/plugins/command-runner/ui.go:527–553  ·  view source on GitHub ↗

ShowErrorModal displays an error message in a modal

(title, message string, onClose func())

Source from the content-addressed store, hash-verified

525
526// ShowErrorModal displays an error message in a modal
527func (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.

Callers 1

showCommandMenuMethod · 0.95

Calls 5

SetDoneFuncMethod · 0.80
AddButtonsMethod · 0.80
isBackKeyFunction · 0.70
PagesMethod · 0.65
SetTextMethod · 0.45

Tested by

no test coverage detected