-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Contributors List on the About Dialog #2934
Conversation
seems to work good but i have a suggestion maybe you could add a loading indicator if loading is currently in progress because it looks a bit strange when there is much empty space |
That empty space is created by the images. The dialog shows nothing until it receive the data from Github and then it populates the dialog with all the profile images and starts loading them. It could be good to add a loading indicator, but it might be as easy or useful just for the images load. |
@TomMalbran This looks great. Thanks for taking this on. I have a few requests before we can merge:
|
@adrocknaphobia Your welcome and thanks for the review.
|
data = []; | ||
|
||
// Save only the required data for the template | ||
$.each(contributorsInfo.data, function (index, element) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should use forEach() instead of $.each()
@TomMalbran Your solutions looks great.Criteria of the story is met, so once this get reviewed we can merge it! Thanks! |
Replaced $.each with forEach as Peter mentioned. |
} | ||
|
||
if (fetchData) { | ||
$.getJSON(brackets.config.contributors_url + "?callback=?", function (contributorsInfo) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because GitHub uses the Access-Control-Allow-Origin: *, would it be better to use a regular get
as opposed to a getJSON
which injects an unnecessary script element into the page?
$.get(brackets.config.contributors_url, function (contributorsInfo) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any difference in how getJSON would be any different to get, since actually getJSON is used with a dataType of JSONP. But you might know better and I could even simply make it a $.ajax
with a dataType: "jsonp"
setting if is a better solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's actually not $.get
vs $.getJSON
but rather the inclusion of ?callback=?
. This triggers the dataType: "jsonp"
which wraps the data in a callback on the server, and then includes a script element in the page, which is a) unnecessary in this case, and b) is significantly slower.
I put together a quick test at http://jsperf.com/get-vs-getjson-vs-ajax which shows the performance hit that dataType: "jsonp"
takes.
Hmmm, I'm not seeing the images at all on my Mac--I see the gray background rectangle, and then the outlines of the individual images fade in, but the actual images never load. If I look in the network tab in the inspector, it doesn't even seem to be trying to fetch the images, which seems odd. Any ideas? Regarding the gray background, I think it would look better if the images were just against the white background of the dialog--it would look weird to have gray in the spaces between them. If we need something to show that it's loading, you could just use the same small spinner we use in Find in Files--maybe just put it after the "Made with <3 and JavaScript" line, and then hide it once the images have loaded. (You could also still have the background div there at the beginning to prop open the space--just make it transparent.) |
Another thought--is there a reason we have to cache the data? It seems fine to just query the API each time you go into the About dialog--it's not like people will be doing it that often :)--or at least shorten the time between checks to an hour or so (two weeks seems excessive). Also, as a possibly silly point, I could imagine that a new contributor would be excited to see their name show up in the dialog after their first merge, and with the current logic they'd have to wait two weeks before it would show up. |
I'll try to get to a more detailed code review later today--in the meantime, it would be good if you could try to figure out why the images aren't loading (or give me a pointer as to what I should look at to debug it). |
I'll work on that and might be able to push this changes before your next review. (Including the suggested |
* @private | ||
* Gets a data structure that has the information for all the contributors of Brackets. | ||
* The information is fetched from brackets.config.contributors_url using the github API. | ||
* If more than 2 weeks have passed since the last fetch, or if cached data can't be found, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part of the comment is now out of date.
Dialogs.showModalDialogUsingTemplate(Mustache.render(AboutDialogTemplate, templateVars)); | ||
|
||
// Get all the project contributors and add them to the dialog | ||
_getContributorsInformation().done(function (contributorsInfo) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why this is, but there seems to be a long pause before the About dialog appears now (compared to master). I don't know why that should be, because the fetch of the contributor info is asynchronous, so it shouldn't actually block the dialog from appearing. Are you seeing that at all? If so, any ideas what could be happening?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Long pause seems to be gone.
Initial review complete. My only real concern is about the apparent delay before the dialog appears--let me know if you're not seeing that. I'm going to be out at an offsite tomorrow, but I'll let the team know someone else should take a look after you've made revisions so we can get it in this sprint if possible (the sprint ends on Friday). Thanks again for working on this! |
Ah, I wonder if that delay could be due to the issue that @TuckerWhitehouse mentioned. If the JSONP stuff is causing a |
@njx Thanks for the review. I just pushed the fixes for all your comments, and yes @TuckerWhitehouse was right, it does feel faster without the JSONP stuff. The only thing that I think is missing is maybe an error response when something went wrong. Just removing the spinner and filling the contributors space with an error message. |
function _getContributorsInformation() { | ||
var result = new $.Deferred(); | ||
|
||
$.getJSON(brackets.config.contributors_url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be simplified now to just return $.getJSON(brackets.config.contributors_url)
, I think (in fact, you probably don't really need this function anymore).
Re-reviewed. I agree we should have an error response, but I think we could go ahead and merge this without that--I can file a bug to get that in next sprint as well as clean up the other code review notice. But if you happen to be online now :), feel free to go ahead and push fixes. I'll wait a little bit before merging to see if you push any fixes. (Also, I'm not sure what's up with the Travis failure--it looks spurious to me. If you do another push, we'll see if it fails again.) |
I'm going to go ahead and merge--will file a bug for the remaining issues. Thanks again for working on this. |
Contributors List on the About Dialog
Followup bug filed as #3012 |
This pull request adds the functionality mentioned in https://trello.com/c/LmtuTQT9 adding every contributor to Brackets as github profile pictures in a grid with a link to their corresponding github profile and a title with their name. The data is also cached for 24 hours to make it load faster.