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

Display number of replies and files changed in tabnav.

Follows https://dmitri.shuralyov.com/service/change/...$commit/c96517b0fff082bd01bd62d8b020b7f7827cd63d.
dmitshur committed 6 years ago commit 47ea398f910ebfa312911770ee4957b2788596a7
Collapse all
main.go
@@ -554,16 +554,23 @@ type state struct {
	Changes  component.Changes
	Change   change.Change
	Timeline []timelineItem
}

// Tabnav renders the tabnav.
func (s state) Tabnav(selected string) template.HTML {
	// Render the tabnav.
	var files htmlg.Component = iconText{Icon: octiconssvg.Diff, Text: "Files"}
	if s.Change.ChangedFiles != 0 {
		files = contentCounter{Content: files, Count: s.Change.ChangedFiles}
	}
	return template.HTML(htmlg.RenderComponentsString(tabnav{
		Tabs: []tab{
			{
				Content:  iconText{Icon: octiconssvg.CommentDiscussion, Text: "Discussion"},
				Content: contentCounter{
					Content: iconText{Icon: octiconssvg.CommentDiscussion, Text: "Discussion"},
					Count:   s.Change.Replies,
				},
				URL:      fmt.Sprintf("%s/%d", s.BaseURI, s.ChangeID),
				Selected: selected == "Discussion",
			},
			{
				Content: contentCounter{
@@ -572,11 +579,11 @@ func (s state) Tabnav(selected string) template.HTML {
				},
				URL:      fmt.Sprintf("%s/%d/commits", s.BaseURI, s.ChangeID),
				Selected: selected == "Commits",
			},
			{
				Content:  iconText{Icon: octiconssvg.Diff, Text: "Files"},
				Content:  files,
				URL:      fmt.Sprintf("%s/%d/files", s.BaseURI, s.ChangeID),
				Selected: selected == "Files",
			},
		},
	}))