From 2aec52c8898e3aa35476224fbcce2e8026eb8568 Mon Sep 17 00:00:00 2001 From: keivin Date: Sat, 26 Oct 2024 21:36:06 +0800 Subject: [PATCH 1/3] feat(ci): add ci view commands to GUI --- commands/ci/view/view.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/commands/ci/view/view.go b/commands/ci/view/view.go index 71ae21bb7..1c7c17c6d 100644 --- a/commands/ci/view/view.go +++ b/commands/ci/view/view.go @@ -268,7 +268,46 @@ func inputCapture( inputCh <- struct{}{} } } + switch event.Key() { + // TODO: set showHelpModel to true bey default + case tcell.KeyCtrlH: + modalVisible = true + + modal := tview.NewModal(). + SetBackgroundColor(tcell.ColorDefault). + // SetBorderAttributes(tcell.NewEventResize(200, 300)). + SetText(fmt.Sprintln(`Supports viewing, running, tracing, and canceling jobs. + + Use arrow keys to navigate jobs and logs. + + - 'Enter' to toggle through a job's logs / traces, or display a child pipeline. Trigger jobs are marked with a '»'. + + - 'Esc' or 'q' to close the logs or trace, or return to the parent pipeline. + + - 'Ctrl+R', 'Ctrl+P' to run, retry, or play a job. Use 'Tab' or arrow keys to navigate the modal, and 'Enter' to confirm. + + - 'Ctrl+D' to cancel a job. If the selected job isn't running or pending, quits the CI/CD view. + + - 'Ctrl+Q' to quit the CI/CD view. + + - 'Ctrl+Space' to suspend application and view the logs. + `)). + AddButtons([]string{"✘ Close"}). + SetDoneFunc(func(buttonIndex int, buttonLabel string) { + modalVisible = false + // root.RemovePage("yesno") + // if buttonLabel != "✔ Yes" { + // app.ForceDraw() + // return + // } + // root.RemovePage("logs-" + curJob.Name) + app.ForceDraw() + }) + root.AddAndSwitchToPage("yesno", modal, false) + inputCh <- struct{}{} + app.ForceDraw() + return nil case tcell.KeyCtrlQ: app.Stop() return nil -- GitLab From 50c260eacbfc7e16711c666a219aa031a98cec78 Mon Sep 17 00:00:00 2001 From: keivin Date: Sun, 27 Oct 2024 00:31:39 +0800 Subject: [PATCH 2/3] fix: replaced input key to footer --- commands/ci/view/view.go | 72 ++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 39 deletions(-) diff --git a/commands/ci/view/view.go b/commands/ci/view/view.go index 1c7c17c6d..9aafb0672 100644 --- a/commands/ci/view/view.go +++ b/commands/ci/view/view.go @@ -221,7 +221,39 @@ func drawView(opts ViewOpts) error { app.Draw() } }() - if err := app.SetScreen(screen).SetRoot(root, true).SetAfterDrawFunc(linkJobsView(app)).Run(); err != nil { + + const ( + naviText = `Use arrow keys to navigate jobs and logs. + + - 'Enter' to toggle through a job's logs / traces, or display a child pipeline. Trigger jobs are marked with a '»'. + + - 'Esc' or 'q' to close the logs or trace, or return to the parent pipeline. + + - 'Ctrl+R', 'Ctrl+P' to run, retry, or play a job. Use 'Tab' or arrow keys to navigate the modal, and 'Enter' to confirm. + + - 'Ctrl+D' to cancel a job. If the selected job isn't running or pending, quits the CI/CD view. + + - 'Ctrl+Q' to quit the CI/CD view. + + - 'Ctrl+Space' to suspend application and view the logs.` + ) + // Create a new TextView with a title and border + // textView := tview.NewTextView(). + textView := tview.NewTextView(). + SetDynamicColors(true). + SetRegions(true). + SetWordWrap(true) + + go func() { + fmt.Fprintf(textView, "%s ", naviText) + }() + + flex := tview.NewFlex(). + SetDirection(tview.FlexRow). + AddItem(root, 0, 1, false). + AddItem(textView, 14, 0, true) + // AddItem(textView.SetBackgroundColor(tcell.ColorDefault).SetBorder(true), 3, 0, false) + if err := app.SetScreen(screen).SetRoot(flex, true).SetAfterDrawFunc(linkJobsView(app)).Run(); err != nil { return err } return nil @@ -270,44 +302,6 @@ func inputCapture( } switch event.Key() { - // TODO: set showHelpModel to true bey default - case tcell.KeyCtrlH: - modalVisible = true - - modal := tview.NewModal(). - SetBackgroundColor(tcell.ColorDefault). - // SetBorderAttributes(tcell.NewEventResize(200, 300)). - SetText(fmt.Sprintln(`Supports viewing, running, tracing, and canceling jobs. - - Use arrow keys to navigate jobs and logs. - - - 'Enter' to toggle through a job's logs / traces, or display a child pipeline. Trigger jobs are marked with a '»'. - - - 'Esc' or 'q' to close the logs or trace, or return to the parent pipeline. - - - 'Ctrl+R', 'Ctrl+P' to run, retry, or play a job. Use 'Tab' or arrow keys to navigate the modal, and 'Enter' to confirm. - - - 'Ctrl+D' to cancel a job. If the selected job isn't running or pending, quits the CI/CD view. - - - 'Ctrl+Q' to quit the CI/CD view. - - - 'Ctrl+Space' to suspend application and view the logs. - `)). - AddButtons([]string{"✘ Close"}). - SetDoneFunc(func(buttonIndex int, buttonLabel string) { - modalVisible = false - // root.RemovePage("yesno") - // if buttonLabel != "✔ Yes" { - // app.ForceDraw() - // return - // } - // root.RemovePage("logs-" + curJob.Name) - app.ForceDraw() - }) - root.AddAndSwitchToPage("yesno", modal, false) - inputCh <- struct{}{} - app.ForceDraw() - return nil case tcell.KeyCtrlQ: app.Stop() return nil -- GitLab From ce04c2ab8f16113656a0eb31526d4f6a86a6ec86 Mon Sep 17 00:00:00 2001 From: keivin Date: Sun, 27 Oct 2024 00:41:55 +0800 Subject: [PATCH 3/3] fix: removed comment --- commands/ci/view/view.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/commands/ci/view/view.go b/commands/ci/view/view.go index 9aafb0672..d5a62341b 100644 --- a/commands/ci/view/view.go +++ b/commands/ci/view/view.go @@ -251,8 +251,7 @@ func drawView(opts ViewOpts) error { flex := tview.NewFlex(). SetDirection(tview.FlexRow). AddItem(root, 0, 1, false). - AddItem(textView, 14, 0, true) - // AddItem(textView.SetBackgroundColor(tcell.ColorDefault).SetBorder(true), 3, 0, false) + AddItem(textView, 14, 1, true) if err := app.SetScreen(screen).SetRoot(flex, true).SetAfterDrawFunc(linkJobsView(app)).Run(); err != nil { return err } -- GitLab