1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Merge branch 'sherodtaylor-more-advanced-jira'

This commit is contained in:
Chris Cummer 2018-06-01 18:33:12 -07:00
commit c43db75561
6 changed files with 41 additions and 5 deletions

View File

@ -34,6 +34,7 @@ jira:
domain: "https://umbrellacorp.atlassian.net"
email: "chriscummer@me.com"
enabled: true
jql: "issueType = Story"
position:
top: 4
left: 1
@ -68,6 +69,11 @@ Values: A valid email address string.
Determines whether or not this module is executed and if its data displayed onscreen. <br />
Values: `true`, `false`.
`jql` <br />
_Optional_ <br />
Custom JQL to be appended to the search query. <br />
Values: See <a href="https://confluence.atlassian.com/jiracore/blog/2015/07/search-jira-like-a-boss-with-jql">Search Jira like a boss with JQL</a> for details.
`position` <br />
Defines where in the grid this module's widget will be displayed. <br />

View File

@ -108,7 +108,7 @@ Key: j Action: Select the next item in the list.</description>
<description>Displays all Jira issues assigned to you for the specified project.
Source Code wtf/jira/ Required ENV Variables Key: WTF_JIRA_API_KEY Value: Your Jira API key.
Keyboard Commands None.
Configuration jira:colors:rows:even:&amp;#34;lightblue&amp;#34;odd:&amp;#34;white&amp;#34;domain:&amp;#34;https://umbrellacorp.atlassian.net&amp;#34;email:&amp;#34;chriscummer@me.com&amp;#34;enabled:trueposition:top:4left:1height:1width:2project:&amp;#34;JIRA&amp;#34;refreshInterval:900username:&amp;#34;chris.cummer&amp;#34; Attributes colors.rows.even Define the foreground color for even-numbered rows. Values: Any X11 color name.
Configuration jira:colors:rows:even:&amp;#34;lightblue&amp;#34;odd:&amp;#34;white&amp;#34;domain:&amp;#34;https://umbrellacorp.atlassian.net&amp;#34;email:&amp;#34;chriscummer@me.com&amp;#34;enabled:truejql:&amp;#34;issueType = Story&amp;#34;position:top:4left:1height:1width:2project:&amp;#34;JIRA&amp;#34;refreshInterval:900username:&amp;#34;chris.cummer&amp;#34; Attributes colors.rows.even Define the foreground color for even-numbered rows. Values: Any X11 color name.
colors.rows.odd Define the foreground color for odd-numbered rows. Values: Any X11 color name.
domain Your Jira corporate domain. Values: A valid URI.
email The email address associated with your Jira account.</description>

View File

@ -108,7 +108,7 @@ Key: j Action: Select the next item in the list.</description>
<description>Displays all Jira issues assigned to you for the specified project.
Source Code wtf/jira/ Required ENV Variables Key: WTF_JIRA_API_KEY Value: Your Jira API key.
Keyboard Commands None.
Configuration jira:colors:rows:even:&amp;#34;lightblue&amp;#34;odd:&amp;#34;white&amp;#34;domain:&amp;#34;https://umbrellacorp.atlassian.net&amp;#34;email:&amp;#34;chriscummer@me.com&amp;#34;enabled:trueposition:top:4left:1height:1width:2project:&amp;#34;JIRA&amp;#34;refreshInterval:900username:&amp;#34;chris.cummer&amp;#34; Attributes colors.rows.even Define the foreground color for even-numbered rows. Values: Any X11 color name.
Configuration jira:colors:rows:even:&amp;#34;lightblue&amp;#34;odd:&amp;#34;white&amp;#34;domain:&amp;#34;https://umbrellacorp.atlassian.net&amp;#34;email:&amp;#34;chriscummer@me.com&amp;#34;enabled:truejql:&amp;#34;issueType = Story&amp;#34;position:top:4left:1height:1width:2project:&amp;#34;JIRA&amp;#34;refreshInterval:900username:&amp;#34;chris.cummer&amp;#34; Attributes colors.rows.even Define the foreground color for even-numbered rows. Values: Any X11 color name.
colors.rows.odd Define the foreground color for odd-numbered rows. Values: Any X11 color name.
domain Your Jira corporate domain. Values: A valid URI.
email The email address associated with your Jira account.</description>

View File

@ -133,6 +133,7 @@
</span><span class="w"> </span>domain<span class="p">:</span><span class="w"> </span><span class="s2">&#34;https://umbrellacorp.atlassian.net&#34;</span><span class="w">
</span><span class="w"> </span>email<span class="p">:</span><span class="w"> </span><span class="s2">&#34;chriscummer@me.com&#34;</span><span class="w">
</span><span class="w"> </span>enabled<span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="w">
</span><span class="w"> </span>jql<span class="p">:</span><span class="w"> </span><span class="s2">&#34;issueType = Story&#34;</span><span class="w">
</span><span class="w"> </span>position<span class="p">:</span><span class="w">
</span><span class="w"> </span>top<span class="p">:</span><span class="w"> </span><span class="m">4</span><span class="w">
</span><span class="w"> </span>left<span class="p">:</span><span class="w"> </span><span class="m">1</span><span class="w">
@ -165,6 +166,11 @@ Values: A valid email address string.</p>
Determines whether or not this module is executed and if its data displayed onscreen. <br />
Values: <code>true</code>, <code>false</code>.</p>
<p><code>jql</code> <br />
<em>Optional</em> <br />
Custom JQL to be appended to the search query. <br />
Values: See <a href="https://confluence.atlassian.com/jiracore/blog/2015/07/search-jira-like-a-boss-with-jql">Search Jira like a boss with JQL</a> for details.</p>
<p><code>position</code> <br />
Defines where in the grid this module&rsquo;s widget will be displayed. <br /></p>

View File

@ -7,11 +7,31 @@ import (
"io"
"io/ioutil"
"net/http"
"net/url"
"os"
"strings"
)
func IssuesFor(username string) (*SearchResult, error) {
url := fmt.Sprintf("/rest/api/2/search?jql=assignee=%s", username)
func IssuesFor(username string, project string, jql string) (*SearchResult, error) {
query := []string{}
if project != "" {
query = append(query, buildJql("project", project))
}
if username != "" {
query = append(query, buildJql("assignee", username))
}
if jql != "" {
query = append(query, jql)
}
v := url.Values{}
v.Set("jql", strings.Join(query, " AND "))
url := fmt.Sprintf("/rest/api/2/search?%s", v.Encode())
resp, err := jiraRequest(url)
if err != nil {
@ -24,6 +44,10 @@ func IssuesFor(username string) (*SearchResult, error) {
return searchResult, nil
}
func buildJql(key string, value string) string {
return fmt.Sprintf("%s = \"%s\"", key, value)
}
/* -------------------- Unexported Functions -------------------- */
func jiraRequest(path string) (*http.Response, error) {

View File

@ -29,7 +29,7 @@ func (widget *Widget) Refresh() {
return
}
searchResult, err := IssuesFor(Config.UString("wtf.mods.jira.username"))
searchResult, err := IssuesFor(Config.UString("wtf.mods.jira.username"), Config.UString("wtf.mods.jira.project", ""), Config.UString("wtf.mods.jira.jql", ""))
widget.UpdateRefreshedAt()
widget.View.Clear()