-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Added Extension Sorting capability according to downloads and last published date #13080
Conversation
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.
Mostly LGTM, needs tests 👍
@@ -292,6 +292,20 @@ define(function (require, exports, module) { | |||
}); | |||
}; | |||
|
|||
ExtensionManagerViewModel.prototype._setSortedExtensionList = function (extensions, isTheme) { | |||
this.filterSet = this.sortedFullSet = registry_utils.sortRegistry(extensions, "registryInfo") | |||
.filter(function (entry) { |
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.
There seems to be some redundancy here, seems like same could be achieved with:
return entry.registryInfo && entry.registryInfo.metadata;
Do correct me if I am wrong 👍
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.
yeah that can be changed :)
Nice! I think @zaggino and @dnbard could have some opinions on this. I have two doubts:
|
@ficristo the installed tab is treated differently as we do not have the download count of the installed extensions in the installInfo, and also currently the sorting of installed extensions is done according to the update available. |
Great stuff @saurabh95! Some issues I spotted:
|
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.
Reviewed again, couple of small issues, otherwise LGTM 👍
PreferencesManager.set("extensions.sort", "downloadCount"); | ||
model._setSortedExtensionList(ExtensionManager.extensions, true); | ||
expect(model.filterSet).toEqual(["theme-2", "theme-1"]); | ||
}); |
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.
A simple check could be added that Brackets actually renders the totalDownloads
to the UI 👍
@@ -136,8 +136,16 @@ define(function (require, exports, module) { | |||
sortedEntries.push(registry[key]); | |||
}); | |||
sortedEntries.sort(function (entry1, entry2) { | |||
return getPublishTime((subkey && entry2[subkey]) || entry2) - | |||
getPublishTime((subkey && entry1[subkey]) || entry1); | |||
if (sortBy !== "publishedDate") { |
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.
Not a big deal, but in general I prefer if you spell out all cases:
if (sortBy === "downloadCount") {
} else if (sortBy === "publishedDate") {
} else {
console.error("Unknown sortBy " + sortBy ". Defaults to....")
}
Or something like this.
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 didn't test this so I trust @petetnt.
But in general seems good.
@petetnt I have added a test for checking downloadCount in view and also added a check for active tab on launch of Extension Manager to hide/show the sort option, regarding the download icon, I will replace it with an image. |
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.
Good stuff @saurabh95 👍
Merging Now with the new Icon. |
Now on opening the Extension Manager, a drop-down is shown on the left side of the search bar, which indicates the sorting of extensions according to the selected criteria(currently sort methods available are Last Updated and Download Count), on change of the selection we store the the changed selection in the preferences and if the Extension Manager is invoked again, then we use the same sorting criteria which was selected by user earlier. The sorting is available for Available and Theme Extensions.
I have attached a snapshot of the feature in use where the sort order and the download count has been highlighted for illustration.