summaryrefslogtreecommitdiff
path: root/windowReposNew.go
blob: 0b7a9699a72edfc868a676dc0d5da5a4790889dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0

package main

// An app to submit patches for the 30 GO GUI repos

import (
	"sync"

	"go.wit.com/gui"
	"go.wit.com/lib/gadgets"
	"go.wit.com/lib/protobuf/gitpb"
	"go.wit.com/log"
)

type stdReposTableWin struct {
	sync.Mutex
	win    *gadgets.GenericWindow // the machines gui window
	boxTB  *gui.Node              // the machines gui parent box widget
	TB     *gitpb.ReposTable      // the gui table buffer
	pb     *gitpb.Repos           // the current repos protobuf
	update bool                   // if the window should be updated
}

func (w *stdReposTableWin) Toggle() {
	if w == nil {
		return
	}
	if w.win == nil {
		return
	}
	w.win.Toggle()
}

func makeWindowForPB() *gadgets.GenericWindow {
	win := gadgets.NewGenericWindow("Forge Repos Raw Protobuf View", "Filter Git Repositories")

	return win
}

func makeReposWinNew() *gadgets.GenericWindow {
	insertWin := makeWindowForPB()
	insertWin.Win.Custom = func() {
		log.Info("test delete window here")
	}
	grid := insertWin.Group.RawGrid()

	var t *gitpb.ReposTable
	grid.NewButton("dirty", func() {
		if t != nil {
			t.Delete()
			t = nil
		}
		found := findDirty()

		// display the protobuf
		t = addWindowPB(insertWin, found)
		f := func(repo *gitpb.Repo) {
			log.Info("got to ReposTable.Custom() id =", repo.GetGoPath(), repo.GetCurrentVersion())
		}
		t.Custom(f)
		log.Info("table has uuid", t.GetUuid())
	})

	grid.NewButton("writeable", func() {
		if t != nil {
			t.Delete()
			t = nil
		}
		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)

		}

		// make the window for the first time
		t = addWindowPB(insertWin, found)
		f := func(repo *gitpb.Repo) {
			log.Info("got to ReposTable.Custom() id =", repo.GetGoPath(), repo.GetCurrentVersion())
		}
		t.Custom(f)
		log.Info("table has uuid", t.GetUuid())
	})

	grid.NewButton("all", func() {
		if t != nil {
			t.Delete()
			t = nil
		}
		found := new(gitpb.Repos)
		all := me.forge.Repos.SortByFullPath()
		for all.Scan() {
			repo := all.Next()
			found.AppendByGoPath(repo)

		}
		// display the protobuf
		t = addWindowPB(insertWin, found)
		f := func(repo *gitpb.Repo) {
			log.Info("got to ReposTable.Custom() id =", repo.GetGoPath(), repo.GetCurrentVersion())
		}
		t.Custom(f)
		log.Info("table has uuid", t.GetUuid())
	})

	return insertWin
}