mirror of
https://github.com/documize/community.git
synced 2025-08-08 15:05:28 +02:00
improve issue display
This commit is contained in:
parent
afaf19f3c5
commit
b9ec7b9e51
4 changed files with 117 additions and 125 deletions
|
@ -28,9 +28,6 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
|
|||
showLabels: false,
|
||||
|
||||
didReceiveAttrs() {
|
||||
$.datetimepicker.setLocale('en');
|
||||
$('#branch-since').datetimepicker();
|
||||
|
||||
let self = this;
|
||||
let page = this.get('page');
|
||||
|
||||
|
@ -53,7 +50,6 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
|
|||
branchURL: "",
|
||||
branchSince: "",
|
||||
branchLines: "30",
|
||||
issueNum: "1"
|
||||
};
|
||||
|
||||
try {
|
||||
|
@ -64,7 +60,6 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
|
|||
config.lists = metaConfig.lists;
|
||||
config.branchSince = metaConfig.branchSince;
|
||||
config.branchLines = metaConfig.branchLines;
|
||||
config.issueNum = metaConfig.issueNum;
|
||||
} catch (e) {}
|
||||
|
||||
self.set('config', config);
|
||||
|
@ -161,11 +156,7 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
|
|||
};
|
||||
reports[1] = {
|
||||
id: "issues_data", // used as method for fetching Go data
|
||||
name: "Open Issues"
|
||||
};
|
||||
reports[2] = {
|
||||
id: "issuenum_data", // used as method for fetching Go data
|
||||
name: "Individual issue activity"
|
||||
name: "Issues"
|
||||
};
|
||||
|
||||
this.set("reports", reports);
|
||||
|
@ -187,6 +178,9 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
|
|||
|
||||
renderSwitch(thisReport) {
|
||||
|
||||
$.datetimepicker.setLocale('en');
|
||||
$('#branch-since').datetimepicker();
|
||||
|
||||
let bl = this.get('config.branchLines');
|
||||
if (is.undefined(bl) || bl === "" || bl <= 0) {
|
||||
this.set('config.branchLines', "30");
|
||||
|
@ -194,7 +188,6 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
|
|||
|
||||
this.set('showCommits', false);
|
||||
this.set('showLabels', false);
|
||||
this.set('showIssueNum', false);
|
||||
switch (thisReport.id) {
|
||||
case 'commits_data':
|
||||
this.set('showCommits', true);
|
||||
|
@ -204,10 +197,6 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
|
|||
this.set('showLabels', true);
|
||||
this.getLabelLists();
|
||||
break;
|
||||
case "issuenum_data":
|
||||
this.set('showIssueNum', true);
|
||||
this.set('busy', false);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -315,11 +304,6 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
|
|||
let lists = this.get('config.lists');
|
||||
let list = lists.findBy('id', id);
|
||||
|
||||
// restore the list of branches to the default state
|
||||
// lists.forEach(function(lst) {
|
||||
// Ember.set(lst, 'included', false);
|
||||
// });
|
||||
|
||||
if (list !== null) {
|
||||
Ember.set(list, 'included', !list.included);
|
||||
}
|
||||
|
@ -379,10 +363,6 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin,
|
|||
this.getReportLists();
|
||||
},
|
||||
|
||||
checkLinesChange(thisLines) {
|
||||
console.log("onLinesChange", thisLines);
|
||||
},
|
||||
|
||||
onCancel() {
|
||||
this.attrs.onCancel();
|
||||
},
|
||||
|
|
|
@ -36,9 +36,6 @@
|
|||
</div>
|
||||
Show items since {{input id="branch-since" value=config.branchSince type="text" }}<br>
|
||||
Number of items to show {{input id="branch-lines" value=config.branchLines type="number" min="1" step="1" max="100" }}<br>
|
||||
{{#if showIssueNum}}
|
||||
Issue Number: {{input id="issue-number" value=config.issueNum type="number" min="1" step="1" }}
|
||||
{{/if}}
|
||||
{{#if showCommits}}
|
||||
<div class="input-control">
|
||||
<label>Branches</label>
|
||||
|
@ -62,6 +59,8 @@
|
|||
<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}} >
|
||||
|
|
|
@ -142,16 +142,16 @@ func (t *Provider) Command(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
provider.WriteJSON(w, render)
|
||||
|
||||
case "issuenum_data":
|
||||
/*case "issuenum_data":
|
||||
|
||||
render, err := t.getIssueNum(client, config)
|
||||
if err != nil {
|
||||
log.Error("github getIssueNum:", err)
|
||||
provider.WriteError(w, "github", err)
|
||||
return
|
||||
}
|
||||
render, err := t.getIssueNum(client, config)
|
||||
if err != nil {
|
||||
log.Error("github getIssueNum:", err)
|
||||
provider.WriteError(w, "github", err)
|
||||
return
|
||||
}
|
||||
|
||||
provider.WriteJSON(w, render)
|
||||
provider.WriteJSON(w, render)*/
|
||||
|
||||
case "owners":
|
||||
|
||||
|
@ -290,6 +290,7 @@ func (*Provider) githubClient(config githubConfig) *gogithub.Client {
|
|||
return gogithub.NewClient(tc)
|
||||
}
|
||||
|
||||
/*
|
||||
func (*Provider) getIssueNum(client *gogithub.Client, config githubConfig) ([]githubIssueActivity, error) {
|
||||
|
||||
ret := []githubIssueActivity{}
|
||||
|
@ -301,8 +302,8 @@ func (*Provider) getIssueNum(client *gogithub.Client, config githubConfig) ([]gi
|
|||
a := ""
|
||||
p := issue.User
|
||||
if p != nil {
|
||||
if p.Name != nil {
|
||||
n = *p.Name
|
||||
if p.Login != nil {
|
||||
n = *p.Login
|
||||
}
|
||||
if p.AvatarURL != nil {
|
||||
a = *p.AvatarURL
|
||||
|
@ -310,24 +311,24 @@ func (*Provider) getIssueNum(client *gogithub.Client, config githubConfig) ([]gi
|
|||
}
|
||||
ret = append(ret, githubIssueActivity{
|
||||
Name: n,
|
||||
Event: "TITLE",
|
||||
Event: "created",
|
||||
Message: template.HTML(*issue.Title),
|
||||
Date: issue.UpdatedAt.Format("January 2 2006, 15:04"),
|
||||
Date: "on " + issue.UpdatedAt.Format("January 2 2006, 15:04"),
|
||||
Avatar: a,
|
||||
URL: template.URL(*issue.HTMLURL),
|
||||
})
|
||||
ret = append(ret, githubIssueActivity{
|
||||
Name: n,
|
||||
Event: "DESCRIPTION",
|
||||
Event: "described",
|
||||
Message: template.HTML(*issue.Body),
|
||||
Date: issue.UpdatedAt.Format("January 2 2006, 15:04"),
|
||||
Date: "on " + issue.UpdatedAt.Format("January 2 2006, 15:04"),
|
||||
Avatar: a,
|
||||
URL: template.URL(*issue.HTMLURL),
|
||||
})
|
||||
ret = append(ret, githubIssueActivity{
|
||||
Name: "",
|
||||
Event: "NOTE",
|
||||
Message: template.HTML("Issue timeline below is in reverse order"),
|
||||
Event: "Note",
|
||||
Message: template.HTML("the issue timeline below is in reverse order"),
|
||||
Date: "",
|
||||
Avatar: githubGravatar,
|
||||
URL: template.URL(*issue.HTMLURL),
|
||||
|
@ -371,8 +372,8 @@ func (*Provider) getIssueNum(client *gogithub.Client, config githubConfig) ([]gi
|
|||
u = *ic.HTMLURL
|
||||
p := ic.User
|
||||
if p != nil {
|
||||
if p.Name != nil {
|
||||
n = *p.Name
|
||||
if p.Login != nil {
|
||||
n = *p.Login
|
||||
}
|
||||
if p.AvatarURL != nil {
|
||||
a = *p.AvatarURL
|
||||
|
@ -385,7 +386,7 @@ func (*Provider) getIssueNum(client *gogithub.Client, config githubConfig) ([]gi
|
|||
Name: n,
|
||||
Event: *v.Event,
|
||||
Message: template.HTML(m),
|
||||
Date: v.CreatedAt.Format("January 2 2006, 15:04"),
|
||||
Date: "on " + v.CreatedAt.Format("January 2 2006, 15:04"),
|
||||
Avatar: a,
|
||||
URL: template.URL(u),
|
||||
})
|
||||
|
@ -395,11 +396,12 @@ func (*Provider) getIssueNum(client *gogithub.Client, config githubConfig) ([]gi
|
|||
return ret, nil
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
func (*Provider) getIssues(client *gogithub.Client, config githubConfig) ([]githubIssue, error) {
|
||||
|
||||
opts := &gogithub.IssueListByRepoOptions{
|
||||
Sort: "created",
|
||||
Sort: "updated",
|
||||
ListOptions: gogithub.ListOptions{PerPage: config.BranchLines}}
|
||||
|
||||
if config.SincePtr != nil {
|
||||
|
@ -436,9 +438,11 @@ func (*Provider) getIssues(client *gogithub.Client, config githubConfig) ([]gith
|
|||
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,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -537,18 +541,18 @@ func (t *Provider) Refresh(configJSON, data string) string {
|
|||
c.Clean()
|
||||
|
||||
switch c.ReportInfo.ID {
|
||||
case "issuenum_data":
|
||||
refreshed, err := t.getIssueNum(t.githubClient(c), c)
|
||||
if err != nil {
|
||||
log.Error("unable to get github issue number activity", err)
|
||||
return data
|
||||
}
|
||||
j, err := json.Marshal(refreshed)
|
||||
if err != nil {
|
||||
log.Error("unable to marshall github issue number activity", err)
|
||||
return data
|
||||
}
|
||||
return string(j)
|
||||
/*case "issuenum_data":
|
||||
refreshed, err := t.getIssueNum(t.githubClient(c), c)
|
||||
if err != nil {
|
||||
log.Error("unable to get github issue number activity", err)
|
||||
return data
|
||||
}
|
||||
j, err := json.Marshal(refreshed)
|
||||
if err != nil {
|
||||
log.Error("unable to marshall github issue number activity", err)
|
||||
return data
|
||||
}
|
||||
return string(j)*/
|
||||
|
||||
case "issues_data":
|
||||
refreshed, err := t.getIssues(t.githubClient(c), c)
|
||||
|
@ -602,31 +606,31 @@ func (p *Provider) Render(config, data string) string {
|
|||
}
|
||||
|
||||
switch c.ReportInfo.ID {
|
||||
case "issuenum_data":
|
||||
payload.IssueNum = c.IssueNum
|
||||
raw := []githubIssueActivity{}
|
||||
/* case "issuenum_data":
|
||||
payload.IssueNum = c.IssueNum
|
||||
raw := []githubIssueActivity{}
|
||||
|
||||
if len(data) > 0 {
|
||||
err = json.Unmarshal([]byte(data), &raw)
|
||||
if len(data) > 0 {
|
||||
err = json.Unmarshal([]byte(data), &raw)
|
||||
if err != nil {
|
||||
log.Error("unable to unmarshall github issue activity data", err)
|
||||
return "Documize internal github json umarshall issue activity data error: " + err.Error()
|
||||
}
|
||||
}
|
||||
|
||||
opt := &gogithub.MarkdownOptions{Mode: "gfm", Context: c.Owner + "/" + c.Repo}
|
||||
client := p.githubClient(c)
|
||||
for k, v := range raw {
|
||||
if v.Event == "commented" {
|
||||
output, _, err := client.Markdown(string(v.Message), opt)
|
||||
if err != nil {
|
||||
log.Error("unable to unmarshall github issue activity data", err)
|
||||
return "Documize internal github json umarshall issue activity data error: " + err.Error()
|
||||
log.Error("convert commented text to markdown", err)
|
||||
} else {
|
||||
raw[k].Message = template.HTML(output)
|
||||
}
|
||||
}
|
||||
|
||||
opt := &gogithub.MarkdownOptions{Mode: "gfm", Context: c.Owner + "/" + c.Repo}
|
||||
client := p.githubClient(c)
|
||||
for k, v := range raw {
|
||||
if v.Event == "commented" {
|
||||
output, _, err := client.Markdown(string(v.Message), opt)
|
||||
if err != nil {
|
||||
log.Error("convert commented text to markdown", err)
|
||||
} else {
|
||||
raw[k].Message = template.HTML(output)
|
||||
}
|
||||
}
|
||||
}
|
||||
payload.IssueNumActivity = raw
|
||||
}
|
||||
payload.IssueNumActivity = raw */
|
||||
|
||||
case "issues_data":
|
||||
raw := []githubIssue{}
|
||||
|
|
|
@ -20,17 +20,17 @@ import (
|
|||
)
|
||||
|
||||
type githubRender struct {
|
||||
Config githubConfig
|
||||
Repo githubRepo
|
||||
List []githubBranch
|
||||
ShowList bool
|
||||
BranchCommits []githubBranchCommits
|
||||
CommitCount int
|
||||
Issues []githubIssue
|
||||
IssueNum int
|
||||
IssueNumActivity []githubIssueActivity
|
||||
Limit int
|
||||
DateMessage string
|
||||
Config githubConfig
|
||||
Repo githubRepo
|
||||
List []githubBranch
|
||||
ShowList bool
|
||||
BranchCommits []githubBranchCommits
|
||||
CommitCount int
|
||||
Issues []githubIssue
|
||||
//IssueNum int
|
||||
//IssueNumActivity []githubIssueActivity
|
||||
Limit int
|
||||
DateMessage string
|
||||
}
|
||||
|
||||
var renderTemplates = map[string]string{
|
||||
|
@ -86,14 +86,20 @@ var renderTemplates = map[string]string{
|
|||
<li class="github-commit-item">
|
||||
<a class="link" href="{{$data.URL}}">
|
||||
<div class="issue-avatar">
|
||||
<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>
|
||||
</div>
|
||||
{{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>
|
||||
{{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>
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="github-commit-body">
|
||||
<div class="github-commit-title"><span class="label-name">{{$data.Message}}</span> {{$data.Labels}}</div>
|
||||
<div class="github-commit-meta">
|
||||
#{{$data.ID}} opened on {{$data.Date}} by {{$data.Name}}
|
||||
#{{$data.ID}} opened on {{$data.Date}} by {{$data.Name}}, last updated {{$data.Updated}}
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
|
@ -104,35 +110,34 @@ var renderTemplates = map[string]string{
|
|||
</div>
|
||||
</div>
|
||||
`,
|
||||
"issuenum_data": `
|
||||
<div class="section-github-render">
|
||||
<p>
|
||||
Activity for issue #{{.IssueNum}} in repository <a href="{{ .Repo.URL }}/issues">{{.Repo.Name}}.</a>
|
||||
Up to {{ .Limit }} items are shown{{ .DateMessage }}.
|
||||
</p>
|
||||
<div class="github-board">
|
||||
<ul class="github-list">
|
||||
{{range $data := .IssueNumActivity}}
|
||||
<li class="github-commit-item">
|
||||
<div class="github-avatar">
|
||||
<img alt="@{{$data.Name}}" src="{{$data.Avatar}}" height="36" width="36">
|
||||
</div>
|
||||
<div class="github-commit-body">
|
||||
<div class="github-commit-title">
|
||||
<a class="link" href="{{$data.URL}}">
|
||||
{{$data.Event}}:
|
||||
</a>
|
||||
{{$data.Message}}
|
||||
</div>
|
||||
<div class="github-commit-meta">{{$data.Name}} committed on {{$data.Date}}</div>
|
||||
</div>
|
||||
<div class="clearfix" />
|
||||
</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
/* "issuenum_data": `
|
||||
<div class="section-github-render">
|
||||
<p>
|
||||
Activity for issue #{{.IssueNum}} in repository <a href="{{ .Repo.URL }}/issues">{{.Repo.Name}}.</a>
|
||||
Up to {{ .Limit }} items are shown{{ .DateMessage }}.
|
||||
</p>
|
||||
<div class="github-board">
|
||||
<ul class="github-list">
|
||||
{{range $data := .IssueNumActivity}}
|
||||
<li class="github-commit-item">
|
||||
<div class="github-avatar">
|
||||
<img alt="@{{$data.Name}}" src="{{$data.Avatar}}" height="36" width="36">
|
||||
</div>
|
||||
<div class="github-commit-meta">
|
||||
{{$data.Name}} <a class="link" href="{{$data.URL}}">{{$data.Event}}</a> {{$data.Date}}
|
||||
</div>
|
||||
<div class="github-commit-body">
|
||||
<div class="github-commit-title">
|
||||
{{$data.Message}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix" />
|
||||
</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
`,*/
|
||||
}
|
||||
|
||||
type githubReport struct {
|
||||
|
@ -180,13 +185,16 @@ type githubCommit struct {
|
|||
type githubIssue struct {
|
||||
ID int `json:"id"`
|
||||
Date string `json:"date"`
|
||||
Updated string `json:"dated"`
|
||||
Message string `json:"message"`
|
||||
URL template.URL `json:"url"`
|
||||
Name string `json:"name"`
|
||||
Avatar string `json:"avatar"`
|
||||
Labels template.HTML `json:"labels"`
|
||||
IsOpen bool `json:"isopen"`
|
||||
}
|
||||
|
||||
/*
|
||||
type githubIssueActivity struct {
|
||||
Date string `json:"date"`
|
||||
Event string `json:"event"`
|
||||
|
@ -195,6 +203,7 @@ type githubIssueActivity struct {
|
|||
Name string `json:"name"`
|
||||
Avatar string `json:"avatar"`
|
||||
}
|
||||
*/
|
||||
|
||||
type githubConfig struct {
|
||||
AppKey string `json:"appKey"` // TODO keep?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue