diff --git a/_site/content/posts/modules/jira.md b/_site/content/posts/modules/jira.md
index 008db39a..0f40d4b3 100644
--- a/_site/content/posts/modules/jira.md
+++ b/_site/content/posts/modules/jira.md
@@ -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.
Values: `true`, `false`.
+`jql`
+_Optional_
+Custom JQL to be appended to the search query.
+Values: See Search Jira like a boss with JQL for details.
+
`position`
Defines where in the grid this module's widget will be displayed.
diff --git a/docs/index.xml b/docs/index.xml
index f5186f07..26d7190e 100644
--- a/docs/index.xml
+++ b/docs/index.xml
@@ -108,7 +108,7 @@ Key: j Action: Select the next item in the list.
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:"lightblue"odd:"white"domain:"https://umbrellacorp.atlassian.net"email:"chriscummer@me.com"enabled:trueposition:top:4left:1height:1width:2project:"JIRA"refreshInterval:900username:"chris.cummer" Attributes colors.rows.even Define the foreground color for even-numbered rows. Values: Any X11 color name.
+Configuration jira:colors:rows:even:"lightblue"odd:"white"domain:"https://umbrellacorp.atlassian.net"email:"chriscummer@me.com"enabled:truejql:"issueType = Story"position:top:4left:1height:1width:2project:"JIRA"refreshInterval:900username:"chris.cummer" 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.
diff --git a/docs/posts/index.xml b/docs/posts/index.xml
index c41e936e..3550f945 100644
--- a/docs/posts/index.xml
+++ b/docs/posts/index.xml
@@ -108,7 +108,7 @@ Key: j Action: Select the next item in the list.
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:"lightblue"odd:"white"domain:"https://umbrellacorp.atlassian.net"email:"chriscummer@me.com"enabled:trueposition:top:4left:1height:1width:2project:"JIRA"refreshInterval:900username:"chris.cummer" Attributes colors.rows.even Define the foreground color for even-numbered rows. Values: Any X11 color name.
+Configuration jira:colors:rows:even:"lightblue"odd:"white"domain:"https://umbrellacorp.atlassian.net"email:"chriscummer@me.com"enabled:truejql:"issueType = Story"position:top:4left:1height:1width:2project:"JIRA"refreshInterval:900username:"chris.cummer" 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.
diff --git a/docs/posts/modules/jira/index.html b/docs/posts/modules/jira/index.html
index e5d77f88..98cea108 100644
--- a/docs/posts/modules/jira/index.html
+++ b/docs/posts/modules/jira/index.html
@@ -133,6 +133,7 @@
domain: "https://umbrellacorp.atlassian.net"
email: "chriscummer@me.com"
enabled: true
+ jql: "issueType = Story"
position:
top: 4
left: 1
@@ -165,6 +166,11 @@ Values: A valid email address string.
Determines whether or not this module is executed and if its data displayed onscreen.
Values: true
, false
.
+jql
+Optional
+Custom JQL to be appended to the search query.
+Values: See Search Jira like a boss with JQL for details.
+
position
Defines where in the grid this module’s widget will be displayed.
diff --git a/jira/client.go b/jira/client.go
index 0e140694..b7903018 100644
--- a/jira/client.go
+++ b/jira/client.go
@@ -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) {
diff --git a/jira/widget.go b/jira/widget.go
index 4c69e2da..ed3c11c3 100644
--- a/jira/widget.go
+++ b/jira/widget.go
@@ -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()