diff --git a/app/app/components/section/github/type-editor.js b/app/app/components/section/github/type-editor.js index e73003c2..1402c23d 100644 --- a/app/app/components/section/github/type-editor.js +++ b/app/app/components/section/github/type-editor.js @@ -41,6 +41,9 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, branchLines: "100", userId: "", pageId: page.get('id'), + showMilestones: false, + showIssues: false, + showCommits: false, }; try { @@ -50,6 +53,9 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, config.branchSince = metaConfig.branchSince; config.userId = metaConfig.userId; config.pageId = metaConfig.pageId; + config.showMilestones = metaConfig.showMilestones; + config.showIssues = metaConfig.showIssues; + config.showCommits = metaConfig.showCommits; } catch (e) {} self.set('config', config); @@ -168,12 +174,16 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, return this.get('isDirty'); }, - onListCheckbox(id) { + onListCheckbox(id) { // select one repository only let lists = this.get('config.lists'); let list = lists.findBy('id', id); + lists.forEach(function (entry) { + Ember.set(entry, 'included', false); + }); + if (list !== null) { - Ember.set(list, 'included', !list.included); + Ember.set(list, 'included', true); } }, diff --git a/app/app/templates/components/section/github/type-editor.hbs b/app/app/templates/components/section/github/type-editor.hbs index 76d781c6..1e35767d 100644 --- a/app/app/templates/components/section/github/type-editor.hbs +++ b/app/app/templates/components/section/github/type-editor.hbs @@ -7,18 +7,30 @@
-
Select Repositories
+
Select Repository
Choose source of code information to be displayed
-
Select organization or username whose repositories you want to show
+
Select organization or username whose repository you want to show
{{ui-select id="owners-dropdown" content=owners action=(action 'onOwnerChange') optionValuePath="id" optionLabelPath="name" selection=config.owner}}
{{input id="branch-since" value=config.branchSince type="text" }}
+
+ + {{input id="show-milestone" checked=config.showMilestones type="checkbox"}}
+
+
+ + {{input id="show-issues" checked=config.showIssues type="checkbox"}}
+
+
+ + {{input id="show-commits" checked=config.showCommits type="checkbox" }}
+
@@ -28,7 +40,7 @@
-
Select the repositories to show
+
Select the repository to show
{{#each config.lists as |list|}}
diff --git a/core/section/github/commits.go b/core/section/github/commits.go index 9caaec4d..f197e3dc 100644 --- a/core/section/github/commits.go +++ b/core/section/github/commits.go @@ -90,6 +90,10 @@ const tagCommitsData = "commitsData" func getCommits(client *gogithub.Client, config *githubConfig) ([]githubCommit, []githubAuthorStats, error) { + if !config.ShowCommits { + return nil, nil, nil + } + // first make sure we've got all the branches for _, orb := range config.Lists { if orb.Included { @@ -253,6 +257,11 @@ func getCommits(client *gogithub.Client, config *githubConfig) ([]githubCommit, } func refreshCommits(gr *githubRender, config *githubConfig, client *gogithub.Client) (err error) { + + if !config.ShowCommits { + return nil + } + gr.BranchCommits, gr.AuthorStats, err = getCommits(client, config) if err != nil { log.Error("github refreshCommits:", err) @@ -262,6 +271,11 @@ func refreshCommits(gr *githubRender, config *githubConfig, client *gogithub.Cli } func renderCommits(payload *githubRender, c *githubConfig) error { + + if !c.ShowCommits { + return nil + } + payload.CommitCount = 0 for range payload.BranchCommits { payload.CommitCount++ diff --git a/core/section/github/commits_template.go b/core/section/github/commits_template.go index bb45875f..a8601a51 100644 --- a/core/section/github/commits_template.go +++ b/core/section/github/commits_template.go @@ -13,6 +13,7 @@ package github const commitsTemplate = `
+ {{if .HasCommits}}
Commits
-

There are {{len .BranchCommits}} commits by {{.NumContributors}} contributors across {{.RepoCount}} +

diff --git a/core/section/github/issues.go b/core/section/github/issues.go index c41c5118..9495306a 100644 --- a/core/section/github/issues.go +++ b/core/section/github/issues.go @@ -106,6 +106,10 @@ func wrapLabels(labels []gogithub.Label) (l string, labelNames []string, labelCo func getIssues(client *gogithub.Client, config *githubConfig) ([]githubIssue, error) { + if !config.ShowIssues { + return nil, nil + } + ret := []githubIssue{} hadRepo := make(map[string]bool) @@ -183,6 +187,11 @@ func getIssues(client *gogithub.Client, config *githubConfig) ([]githubIssue, er } func refreshIssues(gr *githubRender, config *githubConfig, client *gogithub.Client) (err error) { + + if !config.ShowIssues { + return nil + } + gr.Issues, err = getIssues(client, config) if err != nil { log.Error("unable to get github issues (cmd)", err) diff --git a/core/section/github/issues_template.go b/core/section/github/issues_template.go index b6905d2a..284544cb 100644 --- a/core/section/github/issues_template.go +++ b/core/section/github/issues_template.go @@ -30,14 +30,14 @@ const (
{{if .HasIssues}}
Issues
-

+

diff --git a/core/section/github/milestones.go b/core/section/github/milestones.go index 2e6fd6c0..fedc1abe 100644 --- a/core/section/github/milestones.go +++ b/core/section/github/milestones.go @@ -79,6 +79,10 @@ func init() { func getMilestones(client *gogithub.Client, config *githubConfig) ([]githubMilestone, error) { + if !config.ShowMilestones { + return nil, nil + } + ret := []githubMilestone{} hadRepo := make(map[string]bool) @@ -156,6 +160,10 @@ func getMilestones(client *gogithub.Client, config *githubConfig) ([]githubMiles func refreshMilestones(gr *githubRender, config *githubConfig, client *gogithub.Client) (err error) { + if !config.ShowMilestones { + return nil + } + gr.Milestones, err = getMilestones(client, config) if err != nil { log.Error("unable to get github milestones", err) @@ -176,6 +184,11 @@ func refreshMilestones(gr *githubRender, config *githubConfig, client *gogithub. } func renderMilestones(payload *githubRender, c *githubConfig) error { + + if !c.ShowMilestones { + return nil + } + hadRepo := make(map[string]bool) payload.RepoCount = 0 for _, orb := range payload.List { diff --git a/core/section/github/milestones_template.go b/core/section/github/milestones_template.go index b8765876..06e5de52 100644 --- a/core/section/github/milestones_template.go +++ b/core/section/github/milestones_template.go @@ -31,7 +31,7 @@ const (
{{if .HasMilestones}}
Milestones
-

+

diff --git a/core/section/github/model.go b/core/section/github/model.go index 0c826314..521beb8b 100644 --- a/core/section/github/model.go +++ b/core/section/github/model.go @@ -84,21 +84,24 @@ type githubLabel struct { } type githubConfig struct { - Token string `json:"-"` // NOTE very important that the secret Token is not leaked to the client side, so "-" - UserID string `json:"userId"` - PageID string `json:"pageId"` - Owner string `json:"owner_name"` - BranchSince string `json:"branchSince,omitempty"` - SincePtr *time.Time `json:"-"` - Since string `json:"-"` - BranchLines int `json:"branchLines,omitempty,string"` - OwnerInfo githubOwner `json:"owner"` - ClientID string `json:"clientId"` - CallbackURL string `json:"callbackUrl"` - Lists []githubBranch `json:"lists,omitempty"` - ReportOrder []string `json:"-"` - DateMessage string `json:"-"` - UserNames map[string]string `json:"UserNames"` + Token string `json:"-"` // NOTE very important that the secret Token is not leaked to the client side, so "-" + UserID string `json:"userId"` + PageID string `json:"pageId"` + Owner string `json:"owner_name"` + BranchSince string `json:"branchSince,omitempty"` + SincePtr *time.Time `json:"-"` + Since string `json:"-"` + BranchLines int `json:"branchLines,omitempty,string"` + OwnerInfo githubOwner `json:"owner"` + ClientID string `json:"clientId"` + CallbackURL string `json:"callbackUrl"` + Lists []githubBranch `json:"lists,omitempty"` + ReportOrder []string `json:"-"` + DateMessage string `json:"-"` + UserNames map[string]string `json:"UserNames"` + ShowMilestones bool `json:"showMilestones,omitempty"` + ShowIssues bool `json:"showIssues,omitempty"` + ShowCommits bool `json:"showCommits,omitempty"` } func (c *githubConfig) Clean() { @@ -125,7 +128,18 @@ func (c *githubConfig) Clean() { } c.Since = (*c.SincePtr).Format(issuesTimeFormat) - c.ReportOrder = []string{tagSummaryData, tagMilestonesData, tagIssuesData, tagCommitsData} + c.ReportOrder = []string{tagSummaryData} + + if c.ShowMilestones { + c.ReportOrder = append(c.ReportOrder, tagMilestonesData) + } + if c.ShowIssues { + c.ReportOrder = append(c.ReportOrder, tagIssuesData) + } + if c.ShowCommits { + c.ReportOrder = append(c.ReportOrder, tagCommitsData) + } + c.BranchLines = 100 // overide any existing value with maximum allowable in one call sort.Sort(branchesToSort(c.Lists)) // get the configured branches in a sensible order for display diff --git a/core/section/github/summary_template.go b/core/section/github/summary_template.go index 82d3abac..e738a3da 100644 --- a/core/section/github/summary_template.go +++ b/core/section/github/summary_template.go @@ -13,7 +13,7 @@ package github const summaryTemplate = `
-

Activity since {{.Config.Since}}{{.Config.DateMessage}} for {{.Config.Owner}} repositories: +

Activity since {{.Config.Since}}{{.Config.DateMessage}} for {{.Config.Owner}} repository {{range $data := .Config.Lists}} {{if $data.Included}} @@ -23,6 +23,7 @@ const summaryTemplate = ` {{end}}

+
`