start switching to generic GUI table code

This commit is contained in:
Jeff Carr 2025-02-24 11:00:08 -06:00
parent e3d786a79c
commit 948c47b7ff
1 changed files with 49 additions and 3 deletions

View File

@ -203,8 +203,16 @@ func drawWindow(win *gadgets.BasicWindow) {
})
var writeWin *GenericWindow
me.repoWritableB = grid.NewButton("writable", func() {
me.found = new(gitpb.Repos)
// if the window exists, just toggle it open or closed
if writeWin != nil {
writeWin.Toggle()
return
}
// make the window for the first time
found := new(gitpb.Repos)
all := me.forge.Repos.SortByFullPath()
for all.Scan() {
repo := all.Next()
@ -212,10 +220,13 @@ func drawWindow(win *gadgets.BasicWindow) {
continue
}
me.found.AppendByGoPath(repo)
found.AppendByGoPath(repo)
}
makeStandardReposWindow("Repos that you have write access to", me.found)
writeWin, _ = makeWritableWindow(found)
writeWin.Win.Custom = func() {
log.Info("closing window. could do somethine here")
}
})
me.repoAllB = grid.NewButton("All", func() {
@ -384,6 +395,41 @@ func makeStandardReposWindow(title string, pb *gitpb.Repos) (*gitpb.ReposTable,
return t, box
}
func makeWritableWindow(pb *gitpb.Repos) (*GenericWindow, *gitpb.ReposTable) {
win := 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()