mirror of
https://github.com/documize/community.git
synced 2025-08-08 23:15:29 +02:00
issue filter hack
This commit is contained in:
parent
0009d714f9
commit
7e88297d06
4 changed files with 89 additions and 27 deletions
|
@ -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();
|
||||
},
|
||||
|
|
|
@ -56,11 +56,19 @@
|
|||
</div>
|
||||
{{/if}}
|
||||
{{#if showLabels}}
|
||||
<div class="input-control">
|
||||
<label>State</label>
|
||||
<div class="tip">Open, Closed or All issues</div>
|
||||
{{ui-select id="issue-state-dropdown" content=states action=(action 'onStateChange') optionValuePath="id" optionLabelPath="name" selection=config.state}}
|
||||
</div>
|
||||
<div class="input-control">
|
||||
<label>Issue numbers</label>
|
||||
<div class="tip">A comma separated list of issue numbers e.g. 12, 17, 42 (TODO only those below 100 work currently)</div>
|
||||
{{input id="github-issues" value=config.issues type="text" }}
|
||||
</div>
|
||||
<div class="input-control">
|
||||
<label>Labels</label>
|
||||
<div class="tip">Select labels - an issue must have all labels to be shown, if no label is selected all issues are shown.</div>
|
||||
TODO: Open/Closed<br>
|
||||
TODO: Issue Numbers<br>
|
||||
<div class="github-board">
|
||||
{{#each config.lists as |list|}}
|
||||
<div class="github-list" {{action 'onLabelCheckbox' list.id}} >
|
||||
|
|
|
@ -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 += `<span class="github-issue-label" style="background-color:#` + *ll.Color + `">` + *ll.Name + `</span> `
|
||||
}
|
||||
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 += `<span class="github-issue-label" style="background-color:#` + *ll.Color + `">` + *ll.Name + `</span> `
|
||||
}
|
||||
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
|
||||
|
|
|
@ -87,12 +87,12 @@ var renderTemplates = map[string]string{
|
|||
<a class="link" href="{{$data.URL}}">
|
||||
<div class="issue-avatar">
|
||||
{{if $data.IsOpen}}
|
||||
<span aria-label="Open issue">
|
||||
<svg aria-hidden="true" class="octicon octicon-issue-opened open" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg>
|
||||
<span title="Open issue">
|
||||
<svg height="16" version="1.1" viewBox="0 0 14 16" width="14"><path d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg>
|
||||
</span>
|
||||
{{else}}
|
||||
<span aria-label="Closed issue">
|
||||
<svg aria-hidden="true" class="octicon octicon-issue-closed closed" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M7 10h2v2H7v-2zm2-6H7v5h2V4zm1.5 1.5l-1 1L12 9l4-4.5-1-1L12 7l-1.5-1.5zM8 13.7A5.71 5.71 0 0 1 2.3 8c0-3.14 2.56-5.7 5.7-5.7 1.83 0 3.45.88 4.5 2.2l.92-.92A6.947 6.947 0 0 0 8 1C4.14 1 1 4.14 1 8s3.14 7 7 7 7-3.14 7-7l-1.52 1.52c-.66 2.41-2.86 4.19-5.48 4.19v-.01z"></path></svg>
|
||||
<span title="Closed issue">
|
||||
<svg height="16" version="1.1" viewBox="0 0 16 16" width="16"><path d="M7 10h2v2H7v-2zm2-6H7v5h2V4zm1.5 1.5l-1 1L12 9l4-4.5-1-1L12 7l-1.5-1.5zM8 13.7A5.71 5.71 0 0 1 2.3 8c0-3.14 2.56-5.7 5.7-5.7 1.83 0 3.45.88 4.5 2.2l.92-.92A6.947 6.947 0 0 0 8 1C4.14 1 1 4.14 1 8s3.14 7 7 7 7-3.14 7-7l-1.52 1.52c-.66 2.41-2.86 4.19-5.48 4.19v-.01z"></path></svg>
|
||||
</span>
|
||||
{{end}}
|
||||
</div>
|
||||
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue