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: add content search modal [FC-0040] #928

Conversation

rpenido
Copy link
Contributor

@rpenido rpenido commented Mar 29, 2024

Description

This PR implements a front-end UI to the metasearch engine prototype. The modal is shown after clicking the new search icon button in the Studio Header.

The feature is only enabled if the MEILISEARCH_ENABLED env variable is set to true.

search_modal_

More Info

Testing Instructions

  1. Run your local stack on this branch
  2. Make sure you have meilisearch setup locally, follow the setup instructions here https://github.com/open-craft/tutor-contrib-meilisearch, but use the following branch for the plugin (https://github.com/rpenido/tutor-contrib-meilisearch/tree/rpenido/fal-3693-pass-meilisearch-enabled-env-to-mfe-config) to make sure the MEILISEARCH_ENABLED is configured in the MFEs.
  3. Make sure you also have some sample taxonomies/tags. You can add some from here: https://github.com/open-craft/taxonomy-sample-data
  4. Run tutor dev run cms bash and ./manage.py cms reindex_studio
  5. Click on the search icon in the Studio Header
  6. Search and refine.

NOTE: If you don't see the search icon in the header, check the following URL: http://local.edly.io:8000/api/mfe_config/v1

You must have the MEILISEARCH_ENABLED config as show below:
image
If you don't have this configuration, check step 2.


Private ref: FAL-3693

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

openedx-webhooks commented Mar 29, 2024

Thanks for the pull request, @rpenido! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

Copy link

codecov bot commented Mar 29, 2024

Codecov Report

Attention: Patch coverage is 96.15385% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 92.01%. Comparing base (7f3164b) to head (865c334).

Files Patch % Lines
src/header/Header.jsx 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #928      +/-   ##
==========================================
+ Coverage   92.00%   92.01%   +0.01%     
==========================================
  Files         612      616       +4     
  Lines       10745    10771      +26     
  Branches     2304     2312       +8     
==========================================
+ Hits         9886     9911      +25     
- Misses        830      831       +1     
  Partials       29       29              

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

package.json Outdated
@@ -43,7 +43,7 @@
"@edx/brand": "npm:@openedx/brand-openedx@^1.2.2",
"@edx/frontend-component-ai-translations": "^2.0.0",
"@edx/frontend-component-footer": "^13.0.2",
"@edx/frontend-component-header": "^5.0.2",
"@edx/frontend-component-header": "github:open-craft/frontend-component-header#rpenido/dist/fal-3693-add-search-menu-button",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done: 6f05189

@rpenido rpenido force-pushed the rpenido/fal-3693-open-search-modal-when-clicking-search-icon-in-header branch from 2da3cc8 to 493456c Compare March 29, 2024 03:54
@rpenido rpenido changed the title feat: add content search modal feat: add content search modal [FC-0040] Mar 29, 2024
Copy link
Member

@yusuf-musleh yusuf-musleh left a comment

Choose a reason for hiding this comment

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

👍 Great work on this @rpenido ! Everything looks good to me, just left a few comments on the test cases.

  • I tested this: I following the testing instruction in the PR, it works as expected
  • I read through the code
  • I checked for accessibility issues
  • Includes documentation

Comment on lines 85 to 88
it('should render Studio home title', () => {
render(<RootWrapper />);
screen.logTestingPlaygroundURL();
});
Copy link
Member

Choose a reason for hiding this comment

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

Is this testcase missing a check or testing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @yusuf-musleh! Thank you for the review.
Cleaned here: 0d58997

Comment on lines 263 to 279
it('should show search button and open search modal when button clicked, if search flag enabled', async () => {
setConfig({
...getConfig(),
MEILISEARCH_ENABLED: 'false',
});
const { queryByRole } = render(<RootWrapper />);
expect(queryByRole('button', { name: 'Search content' })).not.toBeInTheDocument();
});

it('should show search button if meilisearch flag disabled', async () => {
setConfig({
...getConfig(),
MEILISEARCH_ENABLED: 'false',
});
const { queryByRole } = render(<RootWrapper />);
expect(queryByRole('button', { name: 'Search content' })).not.toBeInTheDocument();
});
Copy link
Member

Choose a reason for hiding this comment

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

These 2 testcases seem to have the same test code? And it seems to be doing the opposite of what is described in the first case, and the second case should be "should not show" right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't check if the search button was showing in the header. This test was not working. I removed it here: 0d58997

Thank you for pointing out!

@rpenido rpenido force-pushed the rpenido/fal-3693-open-search-modal-when-clicking-search-icon-in-header branch 4 times, most recently from 85f4c4f to a017f13 Compare March 31, 2024 23:51
@rpenido rpenido force-pushed the rpenido/fal-3693-open-search-modal-when-clicking-search-icon-in-header branch from a017f13 to 0d58997 Compare April 1, 2024 00:02
@bradenmacdonald
Copy link
Contributor

@rpenido Now that the header changes have merged, I have pulled your changes here into #918 . Can you test that and let me know if it looks good? If you're happy with it, we can just close this PR. Or we can still merge it first, whichever is easier.

@rpenido
Copy link
Contributor Author

rpenido commented Apr 3, 2024

@rpenido Now that the header changes have merged, I have pulled your changes here into #918 . Can you test that and let me know if it looks good? If you're happy with it, we can just close this PR. Or we can still merge it first, whichever is easier.

@bradenmacdonald Sure! I'll test it first thing tomorrow!

Copy link
Contributor

@xitij2000 xitij2000 left a comment

Choose a reason for hiding this comment

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

I understand most of the UI is placeholder. So I haven't looked at it too deeply.

Sorry for the delay, but I had some difficulty getting everything running. Running tutor dev launch again fixed the API key issue, and the indexing command you mentioned fixed the missing index issue.

This is good to go.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done: beeaafa

Thank you for the review @xitij2000!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@xitij2000 Do you prefer to merge this or the @bradenmacdonald PR (#918)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Does that include all the changes from this?

Even so I think it's better to have smaller changes. Could you please fix the merge issues and I'll merge .

Copy link
Contributor Author

@rpenido rpenido Apr 5, 2024

Choose a reason for hiding this comment

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

@xitij2000 Yes, it does.

I updated it here with master changes and let npm install handle the conflicts in the package-lock.json file. I got a huge diff and some dependency package updates.

It seems the bot updates the package but not the dependencies..

Have I done something wrong?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think when you run npm install on a broken package-lock, it regenerates it from scratch which might resolve some dependencies differently. I think it should be OK.

Copy link
Contributor

Choose a reason for hiding this comment

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

To resolve issues with package-lock.json I normally recommend something like this:

  1. Checkout master and run npm ci so your package-lock.json matches master exactly.
  2. Checkout your branch, and reset any changes to package-lock.json, so there are only changes to package.json showing in git.
  3. Run npm install (inside the Tutor container, not on the host)

@rpenido rpenido marked this pull request as ready for review April 4, 2024 12:47
@rpenido rpenido requested a review from a team as a code owner April 4, 2024 12:47
@rpenido rpenido force-pushed the rpenido/fal-3693-open-search-modal-when-clicking-search-icon-in-header branch from fb25ce0 to 7fa6127 Compare April 5, 2024 14:37
@xitij2000 xitij2000 merged commit 2adff6e into openedx:master Apr 8, 2024
6 checks passed
@openedx-webhooks
Copy link

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

@xitij2000 xitij2000 deleted the rpenido/fal-3693-open-search-modal-when-clicking-search-icon-in-header branch April 8, 2024 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

[Course Search] Trigger Course Search Modal in Course Authoring MFE
5 participants