diff --git a/app/app/components/section/github/type-editor.js b/app/app/components/section/github/type-editor.js index 43c21823..ec7ceac2 100644 --- a/app/app/components/section/github/type-editor.js +++ b/app/app/components/section/github/type-editor.js @@ -50,6 +50,8 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, branchURL: "", branchSince: "", branchLines: "30", + state: null, + issues: "", }; try { @@ -60,6 +62,8 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, config.lists = metaConfig.lists; config.branchSince = metaConfig.branchSince; config.branchLines = metaConfig.branchLines; + config.state = metaConfig.state; + config.issues = metaConfig.issues; } catch (e) {} self.set('config', config); @@ -250,6 +254,33 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, let self = this; let page = this.get('page'); + let states = []; + states[0] = { + id: "open", + name: "Show Open Issues" + }; + states[1] = { + id: "closed", + name: "Show Closed Issues" + }; + states[2] = { + id: "all", + name: "Show All Issues" + }; + + this.set("states", states); + + let thisState = this.get('config.state'); + + if (is.null(thisState) || is.undefined(thisState)) { + thisState = states[0]; + this.set('config.state', thisState); + } else { + this.set('config.state', states.findBy('id', thisState.id)); + } + + this.set('state', thisState); + this.get('sectionService').fetch(page, "labels", self.get('config')) .then(function(lists) { let savedLists = self.get('config.lists'); @@ -363,6 +394,11 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, this.getReportLists(); }, + onStateChange(thisState) { + this.set('config.state', thisState); + }, + + onCancel() { this.attrs.onCancel(); }, diff --git a/app/app/templates/components/section/github/type-editor.hbs b/app/app/templates/components/section/github/type-editor.hbs index bcd2fdab..804a950e 100644 --- a/app/app/templates/components/section/github/type-editor.hbs +++ b/app/app/templates/components/section/github/type-editor.hbs @@ -56,11 +56,19 @@ {{/if}} {{#if showLabels}} +
+ +
Open, Closed or All issues
+ {{ui-select id="issue-state-dropdown" content=states action=(action 'onStateChange') optionValuePath="id" optionLabelPath="name" selection=config.state}} +
+
+ +
A comma separated list of issue numbers e.g. 12, 17, 42 (TODO only those below 100 work currently)
+ {{input id="github-issues" value=config.issues type="text" }} +
Select labels - an issue must have all labels to be shown, if no label is selected all issues are shown.
- TODO: Open/Closed
- TODO: Issue Numbers
{{#each config.lists as |list|}}
diff --git a/documize/section/github/github.go b/documize/section/github/github.go index a53267b0..0425ccb6 100644 --- a/documize/section/github/github.go +++ b/documize/section/github/github.go @@ -19,6 +19,7 @@ import ( "io/ioutil" "net/http" "net/url" + "strconv" "strings" "github.com/documize/community/documize/api/request" @@ -400,9 +401,22 @@ func (*Provider) getIssueNum(client *gogithub.Client, config githubConfig) ([]gi func (*Provider) getIssues(client *gogithub.Client, config githubConfig) ([]githubIssue, error) { + pp := config.BranchLines + isRequired := make(map[int]bool) + for _, s := range strings.Split(config.IssuesText, ",") { + i, err := strconv.Atoi(strings.TrimSpace(s)) + if err == nil { + isRequired[i] = true + } + } + if len(isRequired) > 0 { + pp = 100 + } + opts := &gogithub.IssueListByRepoOptions{ Sort: "updated", - ListOptions: gogithub.ListOptions{PerPage: config.BranchLines}} + State: config.IssueState.ID, + ListOptions: gogithub.ListOptions{PerPage: pp}} if config.SincePtr != nil { opts.Since = *config.SincePtr @@ -423,27 +437,29 @@ func (*Provider) getIssues(client *gogithub.Client, config githubConfig) ([]gith } for _, v := range guff { - n := "" - ptr := v.User - if ptr != nil { - if ptr.Login != nil { - n = *ptr.Login + if len(isRequired) == 0 || isRequired[*v.Number] { + n := "" + ptr := v.User + if ptr != nil { + if ptr.Login != nil { + n = *ptr.Login + } } + l := "" + for _, ll := range v.Labels { + l += `` + *ll.Name + ` ` + } + ret = append(ret, githubIssue{ + Name: n, + Message: *v.Title, + Date: v.CreatedAt.Format("January 2 2006, 15:04"), + Updated: v.UpdatedAt.Format("January 2 2006, 15:04"), + URL: template.URL(*v.HTMLURL), + Labels: template.HTML(l), + ID: *v.Number, + IsOpen: *v.State == "open", + }) } - l := "" - for _, ll := range v.Labels { - l += `` + *ll.Name + ` ` - } - ret = append(ret, githubIssue{ - Name: n, - Message: *v.Title, - Date: v.CreatedAt.Format("January 2 2006, 15:04"), - Updated: v.UpdatedAt.Format("January 2 2006, 15:04"), - URL: template.URL(*v.HTMLURL), - Labels: template.HTML(l), - ID: *v.Number, - IsOpen: v.ClosedAt == nil, - }) } return ret, nil diff --git a/documize/section/github/model.go b/documize/section/github/model.go index 913ba2eb..a60f3756 100644 --- a/documize/section/github/model.go +++ b/documize/section/github/model.go @@ -87,12 +87,12 @@ var renderTemplates = map[string]string{
{{if $data.IsOpen}} - - + + {{else}} - - + + {{end}}
@@ -221,7 +221,9 @@ type githubConfig struct { ClientID string `json:"clientId"` CallbackURL string `json:"callbackUrl"` Lists []githubBranch `json:"lists,omitempty"` - IssueNum int `json:"issueNum,omitempty,string"` + IssueState githubReport `json:"state,omitempty"` + IssuesText string `json:"issues,omitempty"` + //IssueNum int `json:"issueNum,omitempty,string"` } func (c *githubConfig) Clean() {