Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'issue_23_no_search_results' into dev

  • Loading branch information...
commit 9dae8a9cb244f17fde180fe9164680a22e2c1472 2 parents f89407e + 857ae98
@stomlinson stomlinson authored
View
8 data/issues.html
@@ -73,7 +73,13 @@
{{/issues}}
{{^issues}}
- This repo has no issues.
+ {{#search_term}}
+ No issues match "{{search_term}}"
+ {{/search_term}}
+
+ {{^search_term}}
+ This repo has no issues.
+ {{/search_term}}
{{/issues}}
</script>
View
12 data/issues.js
@@ -8,8 +8,8 @@ self.port.on("initialize", function(data) {
newIssue.setAttribute("href", "https://github.com/" + data.repo_url + "/issues/new");
});
-self.port.on("show_issues", function(arg) {
- displayIssues(arg.issues || []);
+self.port.on("show_issues", function(data) {
+ displayIssues(data);
attachListeners();
});
@@ -30,8 +30,8 @@ self.port.on("not_last_page", function() {
});
-function displayIssues(issues) {
- var view = { issues: issues };
+function displayIssues(data) {
+ var view = { issues: data.issues || [], search_term: data.search_term };
var template = document.querySelector("#templateIssue").innerHTML;
var html = Mustache.render(template, view);
@@ -51,6 +51,10 @@ form.addEventListener("submit", function(event) {
if(searchTerm) {
self.port.emit("search", { search: searchTerm });
}
+ else {
+ // If no search term, assume no search and go to the "all" label.
+ self.port.emit("open_link", { href: "#label/all" });
+ }
});
self.port.on("show_labels", function(data) {
View
46 lib/issues.js
@@ -55,29 +55,33 @@ function search(search_term, callback) {
}
function convertV2toV3(issues, callback) {
- Labels.get(function(labels) {
- let labelsHash = getLabelsHash(labels);
- // Issues by default come back in chronological order
- issues = issues.reverse();
- issues.forEach(function(issue) {
- issue.assignee = {
- avatar_url: "http://www.gravatar.com/avatar/" + issue.gravatar_id,
- login: issue.user
- };
-
- let labels = issue.labels || [],
- newLabels = [];
-
- issue.labels = newLabels;
-
- labels.forEach(function(label) {
- newLabels.push(labelsHash[label]);
+ if(issues && issues.length) {
+ Labels.get(function(labels) {
+ let labelsHash = getLabelsHash(labels);
+ // Issues by default come back in chronological order
+ issues = issues.reverse();
+ issues.forEach(function(issue) {
+ issue.assignee = {
+ avatar_url: "http://www.gravatar.com/avatar/" + issue.gravatar_id,
+ login: issue.user
+ };
+
+ let labels = issue.labels || [],
+ newLabels = [];
+
+ issue.labels = newLabels;
+
+ labels.forEach(function(label) {
+ newLabels.push(labelsHash[label]);
+ });
+
+ callback && callback(issues);
});
-
- callback && callback(issues);
});
- });
-
+ }
+ else {
+ callback && callback(issues);
+ }
}
function getLabelsHash(labels) {
View
13 lib/issues_panel.js
@@ -39,7 +39,7 @@ exports.get = function(config) {
};
panel.setFilter = function(opts) {
- getIssues(opts, showIssues.bind(null, panel));
+ getIssues(opts, showIssues.bind(null, panel, opts));
updateNextPrevious(panel);
};
@@ -48,16 +48,17 @@ exports.get = function(config) {
return panel;
}
-function showIssues(panel, issues) {
+function showIssues(panel, opts, issues) {
panel.port.emit("show_issues", {
- issues: Helpers.prepareItems(issues)
+ issues: Helpers.prepareItems(issues),
+ search_term: opts.search_term
});
}
function getIssues(opts, callback) {
// TODO - collapse these into a single call
- if(opts.search) {
- Issues.search(opts.search, callback);
+ if(opts.search_term) {
+ Issues.search(opts.search_term, callback);
}
else {
Issues.get(opts, callback);
@@ -92,7 +93,7 @@ function handleSearch(data) {
var searchTerm = data.search;
if(searchTerm) {
- this.setFilter({ search: data.search });
+ this.setFilter({ search_term: searchTerm });
}
else {
paging.setPage(1);
Please sign in to comment.
Something went wrong with that request. Please try again.