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

feat: adds sort widget to search manager and library component page [FC-0059] #1147

Merged

Conversation

pomegranited
Copy link
Contributor

@pomegranited pomegranited commented Jul 10, 2024

Description

Adds a widget to the library component search manager which sorts the search results based on the selected option.

image

Plus the Recently Modified components section from open-craft#52.

Supporting information

Part of #1038

Blocked by:

Private-ref: FAL-3758

Testing instructions

Run the latest master branch in Studio/CMS

  1. Reindex studio to update the index settings: tutor dev run cms ./manage.py cms reindex_studio --experimental

  2. Create a new library

  3. Add components to the library.

  4. From the shell, publish the library:

    from openedx.core.djangoapps.content_libraries import api, models
    library = models.ContentLibrary.objects.get(slug='<your library slug>')
    api.publish_changes(library.library_key)
    
  5. Add more components, but leave them unpublished.

To test this change:

  1. Navigate to the new library from http://apps.local.edly.io:2001/course-authoring/libraries/
  2. Check that the Recently Modified section shows your recently modified components in order of most recent.
  3. Change the sort options and note changes in the Components list.
    The Recently Modified section should not change when sort options change.
  4. Click on the Components tab, and note sort option stays the same as previously selected.
  5. Change sort options and note changes in the components list.
  6. Select "Recently Published" -- should omit unpublished components from the list.

@pomegranited pomegranited requested a review from a team as a code owner July 10, 2024 09:05
@openedx-webhooks
Copy link

openedx-webhooks commented Jul 10, 2024

Thanks for the pull request, @pomegranited!

What's next?

Please work through the following steps to get your changes ready for engineering review:

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.

🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads

🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

🔘 Let us know that your PR is ready for review:

Who will review my changes?

This repository is currently maintained by @openedx/2u-tnl. Tag them in a comment and let them know that your changes are ready for review.

Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Jul 10, 2024
Copy link

codecov bot commented Jul 10, 2024

Codecov Report

Attention: Patch coverage is 99.09910% with 1 line in your changes missing coverage. Please review.

Project coverage is 92.88%. Comparing base (649863d) to head (2d1b213).
Report is 2 commits behind head on master.

Files Patch % Lines
src/search-manager/data/apiHooks.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1147      +/-   ##
==========================================
+ Coverage   92.82%   92.88%   +0.05%     
==========================================
  Files         747      750       +3     
  Lines       13372    13468      +96     
  Branches     2856     2880      +24     
==========================================
+ Hits        12413    12510      +97     
+ Misses        924      923       -1     
  Partials       35       35              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@open-craft-grove
Copy link

Sandbox deployment failed 💥
Please check the settings and requirements.
Retry deployment by pushing a new commit or updating the requirements/settings in the pull request's description.
📜 Failure Logs
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment failed 💥
Please check the settings and requirements.
Retry deployment by pushing a new commit or updating the requirements/settings in the pull request's description.
📜 Failure Logs
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment failed 💥
Please check the settings and requirements.
Retry deployment by pushing a new commit or updating the requirements/settings in the pull request's description.
📜 Failure Logs
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment failed 💥
Please check the settings and requirements.
Retry deployment by pushing a new commit or updating the requirements/settings in the pull request's description.
📜 Failure Logs
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment failed 💥
Please check the settings and requirements.
Retry deployment by pushing a new commit or updating the requirements/settings in the pull request's description.
📜 Failure Logs
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment failed 💥
Please check the settings and requirements.
Retry deployment by pushing a new commit or updating the requirements/settings in the pull request's description.
📜 Failure Logs
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment failed 💥
Please check the settings and requirements.
Retry deployment by pushing a new commit or updating the requirements/settings in the pull request's description.
📜 Failure Logs
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

pomegranited and others added 2 commits July 26, 2024 07:26
* feat: Add Recently Modified library section
* feat: Add "View All" to library sections
  The "View All" action appears on sections that pass in a view all action and contain content that exceeds the defined preview limit, which defaults to 4.
* feat: Use intl library section titles
* test: Update tests
@pomegranited pomegranited force-pushed the jill/FAL-3758-sort-components branch from 19c869a to f1389e3 Compare July 25, 2024 22:22
@pomegranited
Copy link
Contributor Author

pomegranited commented Jul 25, 2024

@bradenmacdonald @rpenido CC @yusuf-musleh

  1. Select "Recently Published" -- should omit unpublished components from the list.

I'm having trouble filtering out "unpublished" components from the search results? I think there's two problems, but I can't work out how to fix them. Can you help?

  1. When "Recently Published" is selected sort option, I add an extraFilter with last_published IS NOT EMPTY, which shows up fine in the meilisearch POST request:
    image

But it fails to filter out components with last_published: null from the response :(

If we can't work out how to make this happen with the filter query, I could add another boolean field for not_published, but it seems like we should be able to do this with just last_published?
2. The last_published date for the XBlock doesn't always seem to be updated when we publish the library?
My tests should have covered this, but when I manually publish the library (using the PR test instructions), it doesn't update all of the library components last_published values.
I'm testing using blocks imported to my library from the Demo Course, and some of these have their last_published set, but some don't, and I don't understand why..

Thanks in advance for any advice you have!

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@rpenido
Copy link
Contributor

rpenido commented Jul 26, 2024

But it fails to filter out components with last_published: null from the response :(

I think meilisearch treats null and empty differently

Meilisearch does not treat null values as empty. To match null fields, use the IS NULL operator.

I'll check tomorrow and update here!

const sort: SearchSortOption[] = (searchSortOrderToUse === defaultSortOption ? [] : [searchSortOrderToUse]);
// Selecting SearchSortOption.RECENTLY_PUBLISHED also excludes unpublished components.
if (searchSortOrderToUse === SearchSortOption.RECENTLY_PUBLISHED) {
extraFilter.push('last_published IS NOT EMPTY');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try this @pomegranited?

Suggested change
extraFilter.push('last_published IS NOT EMPTY');
extraFilter.push('last_published IS NOT NULL');

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♀️ That was totally it.. Thank you @rpenido !

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And re the last_published date stored in the index, I think I've found the problem, but am not sure how to address it, so have asked Dave.

}
const renderEmptyState = () => {
if (componentCount === 0) {
return searchKeywords === '' ? <NoComponents /> : <NoSearchResults />;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a small bug here.

image

If we use the Recently Published sort and don't have any published components we have componentCount === 0 with searchKeywords === '', rendering the wrong state.

Maybe we should add an isFiltered flag inside our search context to check this condition and use it here.

Copy link
Contributor Author

@pomegranited pomegranited Jul 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Maybe we can adjust the message.. have asked Product.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed with 94ac0a1.

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

This handles the case where "Recently Published" sort is selected, which
filters out published components.
@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@pomegranited pomegranited requested a review from rpenido July 28, 2024 19:07
Copy link
Contributor

@rpenido rpenido left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍
Thank you for your work, @pomegranited!
I left a comment about the defaultProps (but it is not blocking, in my opinion).

  • I tested this using the instructions from the PR instructions
  • I read through the code
  • I checked for accessibility issues
  • Includes documentation

src/search-manager/ClearFiltersButton.tsx Outdated Show resolved Hide resolved
src/search-manager/ClearFiltersButton.tsx Outdated Show resolved Hide resolved
src/search-manager/ClearFiltersButton.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@bradenmacdonald bradenmacdonald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! I can merge tomorrow if you address the minor comments from me and @rpenido

@@ -50,6 +50,21 @@ const returnEmptyResult = (_url, req) => {
return mockEmptyResult;
};

const returnLowNumberResults = (_url, req) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment explaining what this function is doing; it's not obvious to me from the name.

src/search-manager/SearchManager.ts Outdated Show resolved Hide resolved
* use only a single state value (searchParams)
* wrap returnSetter in useCallback to ensure the setter remains constant
* don't modify searchParams directly -- copy and use setter only.
@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@bradenmacdonald bradenmacdonald merged commit 4f88948 into openedx:master Jul 30, 2024
7 checks passed
@openedx-webhooks
Copy link

@pomegranited 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

@bradenmacdonald bradenmacdonald deleted the jill/FAL-3758-sort-components branch July 30, 2024 16:41
@mphilbrick211 mphilbrick211 added the FC Relates to an Axim Funded Contribution project label Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
create-sandbox open-craft-grove should create a sandbox environment from this PR FC Relates to an Axim Funded Contribution project open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

7 participants