diff --git a/windowPatches.go b/windowPatches.go index aaf1c4f..bcb41bb 100644 --- a/windowPatches.go +++ b/windowPatches.go @@ -12,10 +12,10 @@ import ( ) type patchesWindow struct { - once sync.Once // only init() the window once - win *gadgets.BasicWindow // the patches window - stack *gui.Node // the top box set as vertical - shelf *gui.Node // the first box in the stack, set as horizontal + once sync.Once // only init() the window once + win *gadgets.BasicWindow // the patches window + stack *gui.Node // the top box set as vertical + // shelf *gui.Node // the first box in the stack, set as horizontal grid *gui.Node // the list of available patches summary *patchSummary // summary of current patches setgrid *gui.Node // the list of each patchset @@ -66,50 +66,34 @@ func (r *patchesWindow) initWindow() { r.grid = r.stack.NewGrid("", 0, 0) - r.shelf = r.initGroup() + /* + r.shelf = r.initGroup() + group1 := r.stack.NewGroup("stuff") + vbox := group1.Box() + vbox.Vertical() + */ + r.summary = r.submitPatchesBox(r.stack) - r.initSetList() -} -func (r *patchesWindow) initGroup() *gui.Node { - group1 := r.stack.NewGroup("stuff") + // update the stats about the repos and patches + r.summary.Update() - vbox := group1.Box() - vbox.Vertical() + g := r.stack.NewGroup("PatchSet List") - hbox := vbox.Box().Horizontal() - - dirty := hbox.NewCheckbox("dirty") - dirty.Custom = func() { - log.Info("filter dirty =", dirty.Checked()) - } - - hbox.NewButton("update patch summary", func() { - r.summary.Update() - }) - hbox.NewButton("test add", func() { - me.patchWin.initGroup() - }) - - hbox.NewButton("Get Patchsets", func() { - psets, err := me.forge.GetPatchesets() - if err != nil { - log.Info(err) - return - } - all := psets.All() - for all.Scan() { - pset := all.Next() - log.Info(pset) - } - }) - return vbox -} - -func (r *patchesWindow) initSetList() *gui.Node { - r.setgrid = r.stack.NewGrid("", 0, 0) + // add the grid + r.setgrid = g.NewGrid("", 0, 0) r.setlist = make(map[string]*forgepb.Patchset) - return nil + + // query for current patchsets + lines, err := listPatches() + if err != nil { + log.Info(err) + return + } + for i, line := range lines { + log.Info(i, line) + r.addPatchset(line) + } } func (r *patchesWindow) addPatchset(line string) { @@ -151,5 +135,22 @@ func (r *patchesWindow) addPatchset(line string) { return } }) + r.setgrid.NewButton("Apply", func() { + pset := r.setlist[name] + if pset == nil { + log.Info(name, "was nil") + return + } + if _, _, _, err := IsEverythingOnDevel(); err != nil { + log.Info("You can only apply patches to the devel branch") + return + } + if IsAnythingDirty() { + log.Info("You can't apply patches when repos are dirty") + me.forge.PrintHumanTable(me.found) + return + } + applyPatchset(pset) + }) r.setgrid.NextRow() } diff --git a/windowSummary.go b/windowSummary.go index f54051c..4b60413 100644 --- a/windowSummary.go +++ b/windowSummary.go @@ -6,7 +6,6 @@ import ( "go.wit.com/gui" "go.wit.com/lib/gadgets" - "go.wit.com/log" ) type patchSummary struct { @@ -60,8 +59,13 @@ func (r *patchesWindow) submitPatchesBox(box *gui.Node) *patchSummary { s.fileCount = s.grid.NewLabel("x files") s.grid.NextRow() - group1 = box.NewGroup("Submit Patch Set") + group1 = box.NewGroup("PatchSet Create") s.grid = group1.RawGrid() + + s.grid.NewButton("update patch summary", func() { + s.Update() + }) + s.reason = gadgets.NewBasicEntry(s.grid, "set name:") s.reason.Custom = func() { if s.reason.String() != "" { @@ -70,39 +74,29 @@ func (r *patchesWindow) submitPatchesBox(box *gui.Node) *patchSummary { s.submitB.Disable() } } - s.submitB = s.grid.NewButton("Submit", func() { + s.submitB = s.grid.NewButton("Create", func() { doSubmit(s.reason.String()) }) - s.grid.NewButton("List Patchsets", func() { - lines, err := listPatches() - if err != nil { - log.Info(err) - return - } - for i, line := range lines { - log.Info(i, line) - r.addPatchset(line) - } - }) - - s.grid.NewButton("Apply Latest Patchset", func() { - lastp := lastPatch() - pset, err := getPatch(lastp) - if err != nil { - return - } - if _, _, _, err := IsEverythingOnDevel(); err != nil { - log.Info("You can only apply patches to the devel branch") - return - } - if IsAnythingDirty() { - log.Info("You can't apply patches when repos are dirty") - me.forge.PrintHumanTable(me.found) - return - } - applyPatchset(pset) - }) + /* + s.grid.NewButton("Apply Latest Patchset", func() { + lastp := lastPatch() + pset, err := getPatch(lastp) + if err != nil { + return + } + if _, _, _, err := IsEverythingOnDevel(); err != nil { + log.Info("You can only apply patches to the devel branch") + return + } + if IsAnythingDirty() { + log.Info("You can't apply patches when repos are dirty") + me.forge.PrintHumanTable(me.found) + return + } + applyPatchset(pset) + }) + */ // disable these until there are not dirty repos // s.reason.Disable()