work on forge 'mode' windows

This commit is contained in:
Jeff Carr 2025-03-02 07:49:30 -06:00
parent c5b6539c3b
commit 9ccc3d0470
1 changed files with 63 additions and 10 deletions

View File

@ -183,9 +183,33 @@ func drawWindow(win *gadgets.BasicWindow) {
log.Info("todo: move releaser here") log.Info("todo: move releaser here")
log.Info("for now, run guireleaser") log.Info("for now, run guireleaser")
}) })
me.modeReleaseW.Disable()
// the Devel / Patch mode window
var patchWin *patchesWindow
me.modePatchW = gridM.NewButton("Patch Window", func() { me.modePatchW = gridM.NewButton("Patch Window", func() {
if patchWin != nil {
patchWin.Toggle()
return
}
patchWin = new(patchesWindow)
patchWin.initWindow()
patchWin.Show()
}) })
me.modePatchW.Disable()
// the user mode "hack Window"
var hackWin *GenericWindow
me.modeUserW = gridM.NewButton("Hack Window", func() { me.modeUserW = gridM.NewButton("Hack Window", func() {
if hackWin != nil {
hackWin.Toggle()
return
}
hackWin := NewGenericWindow("Hack / User Mode Window", "Things that might be wrong")
grid := hackWin.Group.RawGrid()
grid.NewButton("git pull", func() {
log.Info("todo: run git pull on each repo")
})
}) })
grid.NextRow() grid.NextRow()
@ -348,17 +372,19 @@ func drawWindow(win *gadgets.BasicWindow) {
debugger.DebugWindow() debugger.DebugWindow()
}) })
var patchWin *patchesWindow /*
var patchWin *patchesWindow
grid.NewButton("Patches Window", func() { grid.NewButton("Patches Window", func() {
if patchWin != nil { if patchWin != nil {
patchWin.Toggle() patchWin.Toggle()
return return
} }
patchWin = new(patchesWindow) patchWin = new(patchesWindow)
patchWin.initWindow() patchWin.initWindow()
patchWin.Show() patchWin.Show()
}) })
*/
} }
// sets the text in the labels in the window // sets the text in the labels in the window
@ -399,10 +425,37 @@ func forgeSwitchMode(newMode forgepb.ForgeMode) {
me.modeUserW.Enable() me.modeUserW.Enable()
} }
if me.forge.Config.Mode != forgepb.ForgeMode_USER {
doDisableUserW()
}
me.forge.SetConfigSave(true) me.forge.SetConfigSave(true)
me.forge.ConfigSave() me.forge.ConfigSave()
} }
func doDisableUserW() {
me.argvCheckoutUser = false
me.modeUserW.Disable()
var count int
all := me.forge.Repos.SortByFullPath()
for all.Scan() {
repo := all.Next()
if !repo.IsLocalBranch(repo.GetUserBranchName()) {
// log.Info("repo doesn't have user branch", repo.GetGoPath())
continue
}
count += 1
}
if count > 0 {
s := fmt.Sprintf("git delete %d user branches", count)
me.modeUserW.SetLabel(s)
me.modeUserW.Enable()
return
}
}
// this is the magic that generates a window directly from the protocol buffer // this is the magic that generates a window directly from the protocol buffer
func makeStandardReposGrid(pb *gitpb.Repos) *gitpb.ReposTable { func makeStandardReposGrid(pb *gitpb.Repos) *gitpb.ReposTable {
t := pb.NewTable("testDirty") t := pb.NewTable("testDirty")