dmitri.shuralyov.com/app/changes/...

Add experimental support for approved event.
dmitshur committed 7 years ago commit a91b64a47fe6acbe27dd06da14f4fc8355ab81f3
Collapse all
cmd/changesdev/main.go
@@ -41,14 +41,15 @@ var httpFlag = flag.String("http", ":8080", "Listen for HTTP connections on this

func main() {
	flag.Parse()

	var service changes.Service
	switch 0 {
	switch 2 {
	case 0:
		cacheTransport := httpcache.NewMemoryCacheTransport()
		gerrit, err := gerrit.NewClient("https://go-review.googlesource.com/", &http.Client{Transport: cacheTransport})
		//gerrit, err := gerrit.NewClient("https://upspin-review.googlesource.com/", &http.Client{Transport: cacheTransport})
		if err != nil {
			log.Fatalln(err)
		}

		service = gerritapi.NewService(gerrit)
@@ -120,11 +121,15 @@ func main() {
		req.URL.Path = req.URL.Path[prefixLen:]
		if req.URL.Path == "" {
			req.URL.Path = "/"
		}
		//req = req.WithContext(context.WithValue(req.Context(), changesapp.RepoSpecContextKey, "go.googlesource.com/go"))
		//req = req.WithContext(context.WithValue(req.Context(), changesapp.RepoSpecContextKey, "go.googlesource.com/tools"))
		//req = req.WithContext(context.WithValue(req.Context(), changesapp.RepoSpecContextKey, "upspin.googlesource.com/upspin"))
		req = req.WithContext(context.WithValue(req.Context(), changesapp.RepoSpecContextKey, "github.com/google/go-github"))
		//req = req.WithContext(context.WithValue(req.Context(), changesapp.RepoSpecContextKey, "github.com/dustin/go-humanize"))
		//req = req.WithContext(context.WithValue(req.Context(), changesapp.RepoSpecContextKey, "github.com/neugram/ng"))
		req = req.WithContext(context.WithValue(req.Context(), changesapp.BaseURIContextKey, "/changes"))
		changesApp.ServeHTTP(w, req)
	})
	http.Handle("/changes", issuesHandler)
	http.Handle("/changes/", issuesHandler)
component/component.go
@@ -66,10 +66,13 @@ func (e Event) icon() *html.Node {
		icon = octiconssvg.X()
	case "ReviewRequestedEvent":
		icon = octiconssvg.Eye()
	case "ReviewRequestRemovedEvent":
		icon = octiconssvg.X()
	case "ApprovedEvent":
		icon = octiconssvg.Check()
		color, backgroundColor = "#fff", "#6cc644"
	default:
		icon = octiconssvg.PrimitiveDot()
	}
	return &html.Node{
		Type: html.ElementNode, Data: atom.Span.String(),
@@ -109,10 +112,12 @@ func (e Event) text() []*html.Node {
	case "ReviewRequestRemovedEvent":
		ns := []*html.Node{htmlg.Text("removed the review request from ")}
		ns = append(ns, Avatar{User: e.Event.RequestedReviewer, Size: 16, Inline: true}.Render()...)
		ns = append(ns, User{e.Event.RequestedReviewer}.Render()...)
		return ns
	case "ApprovedEvent":
		return []*html.Node{htmlg.Text("approved these changes")}
	default:
		return []*html.Node{htmlg.Text(string(e.Event.Type))}
	}
}