From aa229b8778d3e17fb7551d33772cc82da7cde6c0 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 4 Mar 2025 15:45:52 -0600 Subject: [PATCH] insert PB table seems to work --- doGui.go | 35 ----------------- windowRepos.go | 100 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 35 deletions(-) diff --git a/doGui.go b/doGui.go index 26b74b9..943dd62 100644 --- a/doGui.go +++ b/doGui.go @@ -354,41 +354,6 @@ func makeStandardReposWindow(title string, pb *gitpb.Repos) (*gitpb.ReposTable, return t, box } -func makeWritableWindow(pb *gitpb.Repos) (*gadgets.GenericWindow, *gitpb.ReposTable) { - win := gadgets.NewGenericWindow("Repos You have write access to", "Configure") - t := pb.NewTable("testForgeRepos") - t.NewUuid() - - grid := win.Group.RawGrid() - grid.NewButton("git pull", func() { - log.Info("todo: run git pull on each repo") - }) - - grid.NewButton("do repos.ReScan()", func() { - t.Update() - }) - - tbox := win.Bottom.Box() - t.SetParent(tbox) - - sf := t.AddStringFunc("repo", func(r *gitpb.Repo) string { - return r.GetGoPath() - }) - sf.Custom = func(r *gitpb.Repo) { - log.Info("do button click on", r.GetGoPath()) - } - t.AddTimeFunc("age", func(repo *gitpb.Repo) time.Time { - return repo.NewestTime() - }) - t.AddMasterVersion() - t.AddDevelVersion() - t.AddUserVersion() - t.AddCurrentBranchName() - t.AddState() - t.ShowTable() - return win, t -} - func findMergeToDevel() *gitpb.Repos { found := gitpb.NewRepos() diff --git a/windowRepos.go b/windowRepos.go index db853b7..2e76a24 100644 --- a/windowRepos.go +++ b/windowRepos.go @@ -8,6 +8,7 @@ package main import ( "fmt" "os" + "time" "go.wit.com/lib/gadgets" "go.wit.com/lib/protobuf/gitpb" @@ -81,6 +82,40 @@ func makeReposWin() *gadgets.GenericWindow { makeStandardReposWindow("All repos", me.found) }) + var insertWin *gadgets.GenericWindow + me.repoWritableB = grid.NewButton("insert test", func() { + // if the window exists, just toggle it open or closed + if insertWin != nil { + insertWin.Toggle() + return + } + + insertWin = makeWindowForPB() + insertWin.Win.Custom = func() { + log.Info("test delete window here") + } + grid := insertWin.Group.RawGrid() + grid.NewButton("do something", func() { + log.Info("do something on each pb row") + }) + grid.NewButton("attempt to insert table", func() { + // make the window for the first time + found := new(gitpb.Repos) + all := me.forge.Repos.SortByFullPath() + for all.Scan() { + repo := all.Next() + if me.forge.Config.IsReadOnly(repo.GetGoPath()) { + continue + } + + found.AppendByGoPath(repo) + + } + t := addWindowPB(insertWin, found) + log.Info("table has uuid", t.GetUuid()) + }) + }) + grid.NewButton("Configure", func() { log.Info("add a forge config window here") }) @@ -277,3 +312,68 @@ func masterRemoteProblem() *gitpb.Repos { } return found } + +func makeWritableWindow(pb *gitpb.Repos) (*gadgets.GenericWindow, *gitpb.ReposTable) { + win := gadgets.NewGenericWindow("Repos You have write access to", "Configure") + t := pb.NewTable("testForgeRepos") + t.NewUuid() + + grid := win.Group.RawGrid() + grid.NewButton("git pull", func() { + log.Info("todo: run git pull on each repo") + }) + + grid.NewButton("do repos.ReScan()", func() { + t.Update() + }) + + tbox := win.Bottom.Box() + t.SetParent(tbox) + + sf := t.AddStringFunc("repo", func(r *gitpb.Repo) string { + return r.GetGoPath() + }) + sf.Custom = func(r *gitpb.Repo) { + log.Info("do button click on", r.GetGoPath()) + } + t.AddTimeFunc("age", func(repo *gitpb.Repo) time.Time { + return repo.NewestTime() + }) + t.AddMasterVersion() + t.AddDevelVersion() + t.AddUserVersion() + t.AddCurrentBranchName() + t.AddState() + t.ShowTable() + return win, t +} + +func makeWindowForPB() *gadgets.GenericWindow { + win := gadgets.NewGenericWindow("Raw PB View", "Configure") + + return win +} + +func addWindowPB(win *gadgets.GenericWindow, pb *gitpb.Repos) *gitpb.ReposTable { + t := pb.NewTable("testForgeRepos") + t.NewUuid() + tbox := win.Bottom.Box() + t.SetParent(tbox) + + sf := t.AddStringFunc("repo", func(r *gitpb.Repo) string { + return r.GetGoPath() + }) + sf.Custom = func(r *gitpb.Repo) { + log.Info("do button click on", r.GetGoPath()) + } + t.AddTimeFunc("age", func(repo *gitpb.Repo) time.Time { + return repo.NewestTime() + }) + t.AddMasterVersion() + t.AddDevelVersion() + t.AddUserVersion() + t.AddCurrentBranchName() + t.AddState() + t.ShowTable() + return t +}