(form *tview.Form, frame *tview.Frame, app *tview.Application)
| 19 | } |
| 20 | |
| 21 | func (i *PacketStreamConfig) ConfigureForm(form *tview.Form, frame *tview.Frame, app *tview.Application) { |
| 22 | cid := "" |
| 23 | isError := false |
| 24 | showingError := false |
| 25 | form.AddInputField("CID", i.CID, 50, nil, func(text string) { |
| 26 | cid = text |
| 27 | }) |
| 28 | form.AddButton("Save", func() { |
| 29 | isError = stringIsEmpty(cid) |
| 30 | if isError { |
| 31 | if !showingError { |
| 32 | form.AddTextView("Error", "All fields are required", 0, 1, true, true) |
| 33 | showingError = true |
| 34 | } |
| 35 | return |
| 36 | } |
| 37 | i.CID = cid |
| 38 | i.Configured = true |
| 39 | returnToMenu(frame, app) |
| 40 | }) |
| 41 | form.AddButton("Cancel", func() { |
| 42 | returnToMenu(frame, app) |
| 43 | }) |
| 44 | form.AddButton("Register", func() { |
| 45 | modal := tview.NewModal(). |
| 46 | SetText("Register on PacketStream\n" + PACKETSTREAM_REFERRAL_LINK). |
| 47 | AddButtons([]string{"Open", "Cancel"}). |
| 48 | SetDoneFunc(func(buttonIndex int, buttonLabel string) { |
| 49 | if buttonLabel == "Open" { |
| 50 | webbrowser.Open(PACKETSTREAM_REFERRAL_LINK) |
| 51 | } |
| 52 | app.SetRoot(form, true) |
| 53 | }) |
| 54 | app.SetRoot(modal, true) |
| 55 | }) |
| 56 | } |
| 57 | |
| 58 | func (i *PacketStreamConfig) ConfigureDocker(kind DockerConfigKind, form *tview.Form) (string, error) { |
| 59 | switch kind { |
nothing calls this directly
no test coverage detected