Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit issues displayed on contributor page #1290

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions scripts/contributing.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/* global jQuery*/
/* global jQuery */

(function($){
var githubIssuesEndpoint;
var githubHTMLBeginnerFriendlyURL;
var githubHTMLHelpWantedURL;

var ISSUES_LIMIT = 5;

switch(window.location.pathname){
case "/contributing/babel":
githubIssuesEndpoint = 'https://api.github.com/repos/babel/babel/issues';
Expand Down Expand Up @@ -36,9 +38,11 @@
labels: 'beginner-friendly'
},
success: function(data){
for(var i = 0; i < data.length; i++){
$('.open-issues-section--beginner .issues').append('<li class="issue"><a href="' + data[i].html_url + '"><span class="issue__number">#' + data[i].number +'</span><span class="issue__title">' + data[i].title + '</span></a></li>');
}
var limitedData = data.slice(0, ISSUES_LIMIT);

limitedData.forEach(function(issue) {
$('.open-issues-section--beginner .issues').append(buildIssueRow(issue));
});
},
error : function(xhr, status, error){
$('.open-issues-section--beginner .issues').append('<li><a href="' + githubHTMLBeginnerFriendlyURL + '"><span>Failed to load issues. View Beginner-Friendly issues on Github.</span></a></li>');
Expand All @@ -52,9 +56,17 @@
labels: 'help wanted'
},
success: function(data){
for(var i = 0; i < data.length; i++){
$('.open-issues-section--help-wanted .issues').append('<li class="issue"><a href="' + data[i].html_url + '"><span class="issue__number">#' + data[i].number +'</span><span class="issue__title">' + data[i].title + '</span></a></li>');
}
var filteredData = data.filter(function(issue) {
return !_.find(issue.labels, function(label) {
return label.name === "beginner-friendly";
});
});

var limitedData = filteredData.slice(0, ISSUES_LIMIT);

limitedData.forEach(function(issue) {
$('.open-issues-section--help-wanted .issues').append(buildIssueRow(issue));
});
},
error: function(xhr, status, error){
$('.open-issues-section--help-wanted .issues').append('<li><a href="' + githubHTMLHelpWantedURL + '"><span>Failed to load issues. View Help-Wanted issues on Github.</span></a></li>');
Expand All @@ -63,4 +75,12 @@
}
);

function buildIssueRow(issue) {
var a = $('<a/>').attr('href', issue.html_url);
$('<span/>').addClass('issue__number').text('#' + issue.number).appendTo(a);
$('<span/>').addClass('issue__title').text(issue.title).appendTo(a);

return $('<li/>').addClass('issue').append(a);
}

})(jQuery);