Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The current implementation of sorting does not match the Figma. Move the sort criteria to the top-right of the cards/list view, and combine into a single list of:
* Most installed (this is the default sort, descending obviously)
* Best Match (relevance/search score - ideally this only is an option if the keyword has been filled out)
* A-Z
* Z-A
Proposed resolution
- Update the component in the front-end Svelte side to match the design and the UI/options
- update the query being sent
- update the backend to return in the proper sorted order
- write tests for the sort order changes
Remaining tasks
- ✅ File an issue about this project
- ☐ Addition/Change/Update/Fix to this project
- ☐ Testing to ensure no regression
- ☐ Automated unit/functional testing coverage
- ☐ Developer Documentation support on feature change/addition
- ☐ User Guide Documentation support on feature change/addition
- ☐ Code review from 1 Drupal core team member
- ☐ Full testing and approval
- ☐ Credit contributors
- ☐ Review with the product owner
- ☐ Release
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork project_browser-3277260
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
bakulahluwaliaComment #3
bakulahluwaliaI am working on this issue.
Comment #5
bakulahluwaliaProgress on hold as the new designs should follow claro admin theme components. Designs are under review.
Comment #8
srishtiiee CreditAttribution: srishtiiee at Acquia commented✅ Most installed
Todo: Best Match
✅ A-Z
✅ Z-A
Comment #9
narendraROverall looks good to me. Some nits suggested above.
@chrisfromredfin: Currently no data is shown in case of
Best Match
sorting. Do you want it the same way or should we show supposeProject Usage
data until api is ready?It is observed during testing that data is not shown correctly in case of A-Z sorting for some of the initial modules due to extra space at the start of module title. I will create another ticket to handle that.
Tests still needs to be written as scope of this tickets proposed solution.
Comment #10
tim.plunkettComment #11
srishtiiee CreditAttribution: srishtiiee at Acquia commentedThe test can be made more robust once we have the test fixture ready (https://www.drupal.org/project/project_browser/issues/3280721)
Comment #12
narendraRChangs looks good to me. One last thing to address is that now
direction
is obsolete and should be removed from front-end and backend.Comment #13
fjgarlin CreditAttribution: fjgarlin as a volunteer and at Drupal Association commentedSorting criteria is also changing here https://www.drupal.org/project/project_browser/issues/3280176 as we should no longer tie things up to the mockapi data, because we could and should consider other sources of information.
I think that these two issues are connected and that we should have an agreed "sorting options" that all plugins stick to. That "agreement" is layed out in the MR for that other issue.
Comment #14
narendraRMarking this issue as NR so that someone else can review it.
@fjgarlin: Please let me know if something needs to be done as part of this ticket here.
@chrisfromredfin: Best match sort is still not implemented.
Comment #15
fjgarlin CreditAttribution: fjgarlin as a volunteer and at Drupal Association commented@narendraR - I made a few comments in the MR. It's mostly about keeping the `direction` param, as that's pretty common in all api requests (and possible future options) and abstract it in the front-end. Thinks like "a_z" are just "title ASC" so they should be easily translatable.
I don't think that best match sorting needs implementing, you just pass "best_match" to the api and you let the api do the ranking.
I'm planning to have a version of https://www.drupal.org/project/project_browser/issues/3280176 ready for review today.
Comment #16
srishtiiee CreditAttribution: srishtiiee at Acquia commentedReverted commit #80d7b4a7 - Removed unused direction.
Comment #17
fjgarlin CreditAttribution: fjgarlin as a volunteer and at Drupal Association commentedThe related issue has been fixed and committed to the main branch. So work here can resume.
You might need to do a huge rebase as the mentioned issue changed A LOT of files. It might even be better to start off a fresh branch.
Also, sort options array now lives here: sveltejs/src/constants.js and it is somehow tied to src/Plugin/ProjectBrowserSourceInterface.php. For now that contract is done only via comments but we need to ensure that the changes are done/agreed in the front end and the possible plugins (not just the mock).
Thanks for waiting :-)
Comment #18
tim.plunkettComment #20
srishtiiee CreditAttribution: srishtiiee at Acquia commentedComment #21
fjgarlin CreditAttribution: fjgarlin as a volunteer and at Drupal Association commentedCode looks good. The only thing would be to update the comments in src/Plugin/ProjectBrowserSourceInterface.php so other plugins are aware of what they need to implement.
These are what I mean: https://git.drupalcode.org/project/project_browser/-/blob/1.0.x/src/Plug...
Comment #22
srishtiiee CreditAttribution: srishtiiee at Acquia commentedComment #23
fjgarlin CreditAttribution: fjgarlin as a volunteer and at Drupal Association commentedChanges look good and the functionality is working as expected too.
However, I do have a question about the processing of the sorting options and where that should live.
The way I see it is that plugins are API's and these usually do not adapt to specific implementations. For example: "a_z" is the way that we interpret "title ASC" in the front-end, and "z_a" is the way that we implement "title DESC", but with these changes we are taking/forcing the whole concept of "a_z" to the plugin, and therefore making it a requirement to be accepted that way.
I think a better approach would be to process that value in the controller, where we actually validate that information first, and then we can "translate" (in the controller) the "a_z" to "title ASC", which is actually more generic. The controller acts like the intermediary between the front-end and the plugins, and it should normally not be bypassed.
I'm happy to adapt the code slightly on the back-end to implement the above suggestion.
Comment #24
fjgarlin CreditAttribution: fjgarlin as a volunteer and at Drupal Association commentedAdded the logic to the controller instead of the plugin and simplified some comments.
I tested all the changes, but I guess I wouldn't RBTC myself as I did the last commit.
Comment #26
fjgarlin CreditAttribution: fjgarlin as a volunteer and at Drupal Association commentedComment #27
tim.plunkettNow that the test fixture landed, this can have automated tests.
Comment #28
srishtiiee CreditAttribution: srishtiiee at Acquia commentedComment #29
srishtiiee CreditAttribution: srishtiiee at Acquia commentedComment #30
srishtiiee CreditAttribution: srishtiiee at Acquia commentedComment #31
fjgarlin CreditAttribution: fjgarlin as a volunteer and at Drupal Association commentedChecked the test and all the front-end code. I only did some refactoring in this commit, but didn't alter any other part. So I think this can be marked as RTBC as we now have tests.
Comment #33
tim.plunkettMerged, thanks!