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

Method showAddGroupDialog

internal/ui/components/connection_profiles.go:861–973  ·  view source on GitHub ↗

showAddGroupDialog prompts for a new group name and then opens the editor.

()

Source from the content-addressed store, hash-verified

859// showAddGroupDialog prompts for a new group name and then opens the editor.
860
861func (a *App) showAddGroupDialog() {
862
863 // Store last focused primitive if we haven't already (e.g. if coming from menu directly)
864
865 if a.lastFocus == nil {
866
867 a.lastFocus = a.GetFocus()
868
869 }
870
871 form := newStandardForm()
872
873 form.SetBorder(true)
874
875 form.SetTitle(" Create New Group ")
876
877 form.SetBorderColor(theme.Colors.Border)
878
879 // Group Name Input
880
881 nameInput := tview.NewInputField().
882 SetLabel("Group Name").
883 SetFieldWidth(30)
884
885 form.AddFormItem(nameInput)
886
887 validateGroupName := func(name string) bool {
888 name = strings.TrimSpace(name)
889 if name == "" {
890 a.showMessageSafe("Group name cannot be empty")
891 return false
892 }
893 if _, exists := a.config.Profiles[name]; exists {
894 a.showMessageSafe("Group name conflicts with an existing profile")
895 return false
896 }
897 if a.config.IsGroup(name) {
898 a.showMessageSafe("Group name already exists")
899 return false
900 }
901 return true
902 }
903
904 // Create Button
905 form.AddButton("Create", func() {
906 name := strings.TrimSpace(nameInput.GetText())
907 if !validateGroupName(name) {
908 return
909 }
910 go func() {
911 a.Application.QueueUpdateDraw(func() {
912 a.pages.RemovePage("addGroupInput")
913 a.showEditGroupDialog(name)
914 })
915 }()
916 })
917
918 // Cancel Button

Callers 1

Calls 11

showMessageSafeMethod · 0.95
showEditGroupDialogMethod · 0.95
newStandardFormFunction · 0.85
SetFieldWidthMethod · 0.80
SetLabelMethod · 0.80
IsGroupMethod · 0.80
QueueUpdateDrawMethod · 0.80
SetDoneFuncMethod · 0.80
SetTitleMethod · 0.65
SetFocusMethod · 0.65

Tested by

no test coverage detected