add a submit button

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-02-13 13:50:19 -06:00
parent e4c3aafb7b
commit 0ef88b82d1
4 changed files with 30 additions and 38 deletions

View File

@ -78,9 +78,11 @@ func globalBuildOptions(vbox *gui.Node) {
me.develBranch = gadgets.NewBasicCombobox(grid, "default devel branch") me.develBranch = gadgets.NewBasicCombobox(grid, "default devel branch")
me.develBranch.AddText("devel") me.develBranch.AddText("devel")
me.develBranch.Disable()
me.userBranch = gadgets.NewBasicCombobox(grid, "default user branch") me.userBranch = gadgets.NewBasicCombobox(grid, "default user branch")
me.userBranch.AddText(usr.Username) me.userBranch.AddText(usr.Username)
me.userBranch.Disable()
var newBranch *gui.Node var newBranch *gui.Node
var setBranchB *gui.Node var setBranchB *gui.Node

View File

@ -1,15 +1,10 @@
package main package main
import ( import (
"fmt"
"os"
"path/filepath"
"go.wit.com/gui" "go.wit.com/gui"
"go.wit.com/lib/debugger" "go.wit.com/lib/debugger"
"go.wit.com/lib/gui/gowit" "go.wit.com/lib/gui/gowit"
"go.wit.com/lib/gui/logsettings" "go.wit.com/lib/gui/logsettings"
"go.wit.com/log"
) )
func globalDisplaySetRepoState() { func globalDisplaySetRepoState() {
@ -73,33 +68,6 @@ func globalDisplayOptions(vbox *gui.Node) {
} }
me.scanEveryMinute = group1.NewCheckbox("Scan every minute").SetChecked(false) me.scanEveryMinute = group1.NewCheckbox("Scan every minute").SetChecked(false)
group1.NewButton("make go.work file", func() {
me.autotypistWindow.Disable()
goSrcDir := me.goSrcPwd.String()
filename := filepath.Join(goSrcDir, "go.work")
f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE, 0600)
if err != nil {
return
}
defer f.Close()
fmt.Fprintln(f, "go 1.21.4")
fmt.Fprintln(f, "")
fmt.Fprintln(f, "use (")
for _, repo := range me.allrepos {
if repo.status.Exists("go.mod") {
fmt.Fprintln(f, "\t"+repo.String())
} else {
log.Info("missing go.mod for", repo.String())
repo.status.MakeRedomod()
}
}
fmt.Fprintln(f, ")")
me.autotypistWindow.Enable()
})
var tagsW *tagWindow var tagsW *tagWindow
group1.NewButton("git tags Window", func() { group1.NewButton("git tags Window", func() {
if tagsW == nil { if tagsW == nil {

View File

@ -71,7 +71,7 @@ type autoType struct {
// displays a summary of all the repos // displays a summary of all the repos
// has total dirty, total read-only // has total dirty, total read-only
// total patches, etc // total patches, etc
summary *develSummary summary *patchSummary
} }
type repo struct { type repo struct {

View File

@ -10,7 +10,7 @@ import (
"go.wit.com/log" "go.wit.com/log"
) )
type develSummary struct { type patchSummary struct {
grid *gui.Node grid *gui.Node
updateB *gui.Node updateB *gui.Node
docsB *gui.Node docsB *gui.Node
@ -20,11 +20,14 @@ type develSummary struct {
readonlyOL *gadgets.OneLiner readonlyOL *gadgets.OneLiner
totalPatchesOL *gadgets.OneLiner totalPatchesOL *gadgets.OneLiner
reason *gadgets.BasicEntry
submitB *gui.Node
allp []*patch allp []*patch
} }
func submitPatchesBox(box *gui.Node) *develSummary { func submitPatchesBox(box *gui.Node) *patchSummary {
s := new(develSummary) s := new(patchSummary)
group1 := box.NewGroup("Submit Patches Summary") group1 := box.NewGroup("Submit Patches Summary")
s.grid = group1.RawGrid() s.grid = group1.RawGrid()
@ -61,10 +64,27 @@ func submitPatchesBox(box *gui.Node) *develSummary {
s.totalPatchesOL = gadgets.NewOneLiner(s.grid, "total commits") s.totalPatchesOL = gadgets.NewOneLiner(s.grid, "total commits")
s.grid.NextRow() s.grid.NextRow()
s.reason = gadgets.NewBasicEntry(s.grid, "patch name:")
s.reason.Custom = func() {
if s.reason.String() != "" {
s.submitB.Enable()
} else {
s.submitB.Disable()
}
}
s.submitB = s.grid.NewButton("Submit Patches", func() {
for i, p := range s.allp {
log.Info(i, p.ref, p.rs.String())
}
})
// disable these until there are not dirty repos
s.reason.Disable()
s.submitB.Disable()
return s return s
} }
func (s *develSummary) Update() { func (s *patchSummary) Update() {
var total, dirty, readonly int var total, dirty, readonly int
for _, repo := range me.allrepos { for _, repo := range me.allrepos {
total += 1 total += 1
@ -86,6 +106,8 @@ func (s *develSummary) Update() {
} }
if dirty == 0 { if dirty == 0 {
s.totalPatchesOL.SetText(strconv.Itoa(p) + " patches") s.totalPatchesOL.SetText(strconv.Itoa(p) + " patches")
s.submitB.Enable()
s.reason.Enable()
} else { } else {
s.totalPatchesOL.SetText(strconv.Itoa(p) + " patches + ? dirty") s.totalPatchesOL.SetText(strconv.Itoa(p) + " patches + ? dirty")
} }
@ -97,7 +119,7 @@ type patch struct {
rs *repostatus.RepoStatus rs *repostatus.RepoStatus
} }
func (s *develSummary) GetPatches() (int, []*patch) { func (s *patchSummary) GetPatches() (int, []*patch) {
var patchcount int var patchcount int
patches := make([]*patch, 0, 0) patches := make([]*patch, 0, 0)
for _, repo := range me.allrepos { for _, repo := range me.allrepos {