1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-21 14:19:43 +02:00

github for single repos only, with selectable sub-sections

This commit is contained in:
Elliott Stoneham 2016-09-28 14:42:55 +01:00
parent 7bf9901c9a
commit 6e362c0eac
10 changed files with 104 additions and 28 deletions

View file

@ -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);
}
},

View file

@ -7,18 +7,30 @@
<div class="pull-left width-45">
<div class="input-form">
<div class="heading">
<div class="title">Select Repositories</div>
<div class="title">Select Repository</div>
<div class="tip">Choose source of code information to be displayed</div>
</div>
<div class="input-control">
<label>Organization or User</label>
<div class="tip">Select organization or username whose repositories you want to show</div>
<div class="tip">Select organization or username whose repository you want to show</div>
{{ui-select id="owners-dropdown" content=owners action=(action 'onOwnerChange') optionValuePath="id" optionLabelPath="name" selection=config.owner}}
</div>
<div class="input-control">
<label>Show items since (default 7 days ago)</label>
{{input id="branch-since" value=config.branchSince type="text" }}<br>
</div>
<div class="input-control">
<label>Show Milestones</label>
{{input id="show-milestone" checked=config.showMilestones type="checkbox"}}<br>
</div>
<div class="input-control">
<label>Show Issues</label>
{{input id="show-issues" checked=config.showIssues type="checkbox"}}<br>
</div>
<div class="input-control">
<label>Show Commits</label>
{{input id="show-commits" checked=config.showCommits type="checkbox" }}<br>
</div>
</div>
</div>
@ -28,7 +40,7 @@
<div class="input-form">
<div class="input-control">
<label>Repositories</label>
<div class="tip">Select the repositories to show</div>
<div class="tip">Select the repository to show</div>
<div class="github-board">
{{#each config.lists as |list|}}
<div class="github-list" {{action 'onListCheckbox' list.id}}>

View file

@ -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++

View file

@ -13,6 +13,7 @@ package github
const commitsTemplate = `
<div class="section-github-render">
<!--
{{if .HasAuthorStats}}
<div class="heading">Contributors</div>
<p>
@ -58,12 +59,13 @@ const commitsTemplate = `
</tbody>
</table>
{{end}}
-->
{{if .HasCommits}}
<div class="heading">Commits</div>
<p>There are {{len .BranchCommits}} commits by {{.NumContributors}} contributors across {{.RepoCount}}
<!-- <p>There are {{len .BranchCommits}} commits by {{.NumContributors}} contributors across {{.RepoCount}}
{{if eq 1 .RepoCount}} repository. {{else}} repositories. {{end}}
</p>
</p> -->
<div class="margin-top-20"></div>
<table class="github-table">
<tbody>

View file

@ -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)

View file

@ -30,14 +30,14 @@ const (
<div class="section-github-render">
{{if .HasIssues}}
<div class="heading">Issues</div>
<p>
<!-- <p>
There are {{.ClosedIssues}} closed
{{if eq 1 .ClosedIssues}}issue{{else}}issues{{end}}
and {{.OpenIssues}} open
{{if eq 1 .OpenIssues}}issue{{else}}issues{{end}}
across {{.RepoCount}}
{{if eq 1 .RepoCount}} repository. {{else}} repositories. {{end}}
</p>
</p> -->
<div class="margin-top-20"></div>
<table class="github-table">

View file

@ -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 {

View file

@ -31,7 +31,7 @@ const (
<div class="section-github-render">
{{if .HasMilestones}}
<div class="heading">Milestones</div>
<p>
<!-- <p>
There are
{{.ClosedMS}}
{{if eq 1 .ClosedMS}} milestone {{else}} milestones {{end}}
@ -39,7 +39,7 @@ const (
{{if eq 1 .OpenMS}} milestone {{else}} milestones {{end}}
open across {{.RepoCount}}
{{if eq 1 .RepoCount}} repository. {{else}} repositories. {{end}}
</p>
</p> -->
<div class="margin-top-20"></div>
<table class="github-table">
<tbody>

View file

@ -99,6 +99,9 @@ type githubConfig struct {
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

View file

@ -13,7 +13,7 @@ package github
const summaryTemplate = `
<div class="section-github-render">
<p>Activity since {{.Config.Since}}{{.Config.DateMessage}} for {{.Config.Owner}} repositories:
<p>Activity since {{.Config.Since}}{{.Config.DateMessage}} for {{.Config.Owner}} repository
{{range $data := .Config.Lists}}
{{if $data.Included}}
<a class="link" href="{{$data.URL}}">
@ -23,6 +23,7 @@ const summaryTemplate = `
{{end}}
</p>
<!--
{{if .HasSharedLabels}}
<div class="heading">Labels</div>
<p>There
@ -42,5 +43,6 @@ const summaryTemplate = `
</tbody>
</table>
{{end}}
-->
</div>
`