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

githubapi: Add support for deleted branch events.
dmitshur committed 6 years ago commit b6c9977d8f33f8d6d0df086e86854cfa2af4766a
Collapse all
component/component.go
@@ -48,30 +48,38 @@ func (e Event) icon() *html.Node {
	var (
		icon            *html.Node
		color           = "#767676"
		backgroundColor = "#f3f3f3"
	)
	switch e.Event.Payload.(type) {
	switch p := e.Event.Payload.(type) {
	case changes.ClosedEvent:
		icon = octiconssvg.CircleSlash()
		color, backgroundColor = "#fff", "#bd2c00"
	case changes.ReopenedEvent:
		icon = octiconssvg.PrimitiveDot()
		color, backgroundColor = "#fff", "#6cc644"
	case changes.RenamedEvent:
		icon = octiconssvg.Pencil()
	case changes.LabeledEvent, changes.UnlabeledEvent:
		icon = octiconssvg.Tag()
	case changes.CommentDeletedEvent:
		icon = octiconssvg.X()
	case changes.ReviewRequestedEvent:
		icon = octiconssvg.Eye()
	case changes.ReviewRequestRemovedEvent:
		icon = octiconssvg.X()
	case changes.MergedEvent:
		icon = octiconssvg.GitMerge()
		color, backgroundColor = "#fff", "#6f42c1"
	case changes.DeletedEvent:
		switch p.Type {
		case "branch":
			icon = octiconssvg.GitBranch()
			color, backgroundColor = "#fff", "#767676"
		case "comment":
			icon = octiconssvg.X()
		default:
			panic("unreachable")
		}
	case changes.ApprovedEvent:
		icon = octiconssvg.Check()
		color, backgroundColor = "#fff", "#6cc644"
	case changes.ChangesRequestedEvent:
		icon = octiconssvg.X()
@@ -107,12 +115,10 @@ func (e Event) text() []*html.Node {
		var ns []*html.Node
		ns = append(ns, htmlg.Text("removed the "))
		ns = append(ns, issuescomponent.Label{Label: p.Label}.Render()...)
		ns = append(ns, htmlg.Text(" label"))
		return ns
	case changes.CommentDeletedEvent:
		return []*html.Node{htmlg.Text("deleted a comment")}
	case changes.ReviewRequestedEvent:
		ns := []*html.Node{htmlg.Text("requested a review from ")}
		ns = append(ns, Avatar{User: p.RequestedReviewer, Size: 16, inline: true}.Render()...)
		ns = append(ns, User{p.RequestedReviewer}.Render()...)
		return ns
@@ -126,10 +132,23 @@ func (e Event) text() []*html.Node {
		ns = append(ns, htmlg.Text("merged commit "))
		ns = append(ns, htmlg.Strong(p.CommitID)) // TODO: Code{}, use CommitHTMLURL.
		ns = append(ns, htmlg.Text(" into "))
		ns = append(ns, htmlg.Strong(p.RefName)) // TODO: Code{}.
		return ns
	case changes.DeletedEvent:
		switch p.Type {
		case "branch":
			var ns []*html.Node
			ns = append(ns, htmlg.Text("deleted the "))
			ns = append(ns, htmlg.Strong(p.Name)) // TODO: Code{}.
			ns = append(ns, htmlg.Text(" branch"))
			return ns
		case "comment":
			return []*html.Node{htmlg.Text("deleted a comment")}
		default:
			panic("unreachable")
		}
	case changes.ApprovedEvent:
		return []*html.Node{htmlg.Text("approved this change")}
	case changes.ChangesRequestedEvent:
		return []*html.Node{htmlg.Text("requested changes")}
	default: