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: library home page bare bones [FC-0059] #1076

Conversation

rpenido
Copy link
Contributor

@rpenido rpenido commented Jun 6, 2024

Description

This PR adds a "Bare Bones" version of the Library Home and updates the SearchResult component to redirect to this new page.

image

image

More Info

Testing Instructions

  • Run your local stack on this branch
  • Make sure you have the studio.library_authoring_mfe waffle flag DISABLED
  • Go to the Studio Home and check the "Libraries" tab
  • Click on one library with components
  • Check if the component count is shown in the last card and the "Components" tab
  • Use the keyword search box and check if the component count is filtered accordingly
  • Navigate through the Home, Components and Collections tab and check if you can navigate back using the "Back" button from the brownser
  • Go back to the Studio Home and open a library WITHOUT components
  • You should see a message with a button that will allow the user to add new components (not implemented yet)
  • Go back to the Studio Home and open the search modal
  • Find a library v2 component and click on it. It should redirect to the new Library Home.

Private ref: FAL-3753

Settings

EDX_PLATFORM_REPOSITORY: https://github.com/open-craft/edx-platform.git
EDX_PLATFORM_VERSION: taxonomy-sandbox-20240614

GROVE_REDIRECTS:
 - domain: {{ LMS_HOST }}
 - domain: cms.{{ LMS_HOST }}
 - domain: app.{{ LMS_HOST }}
 - domain: meilsearch.{{ LMS_HOST }}

PLUGINS:
- mfe
- grove
- s3
- meilisearch

Tutor requirements

git+https://github.com/overhangio/tutor.git@nightly
git+https://github.com/overhangio/tutor-discovery.git@nightly
git+https://github.com/overhangio/tutor-ecommerce.git@nightly
git+https://github.com/overhangio/tutor-xqueue.git@nightly
git+https://github.com/overhangio/tutor-forum.git@nightly
git+https://gitlab.com/opencraft/dev/tutor-contrib-grove.git@main

git+https://github.com/open-craft/tutor-mfe.git@7d1e1e0dad2c0e4247a4fd8280c257f13ed28432
git+https://github.com/open-craft/tutor-contrib-s3.git@04c7491442fa231e79840995f1f8707eed6353fd

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

openedx-webhooks commented Jun 6, 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.

@rpenido rpenido force-pushed the rpenido/fal-3753-library-home-page-bare-bones branch 3 times, most recently from d212fa9 to d1b529c Compare June 6, 2024 19:55
Copy link

codecov bot commented Jun 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.68%. Comparing base (292663a) to head (624309d).
Report is 680 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1076      +/-   ##
==========================================
+ Coverage   92.67%   92.68%   +0.01%     
==========================================
  Files         696      693       -3     
  Lines       12392    12347      -45     
  Branches     2714     2694      -20     
==========================================
- Hits        11484    11444      -40     
+ Misses        876      872       -4     
+ Partials       32       31       -1     

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

@rpenido rpenido force-pushed the rpenido/fal-3753-library-home-page-bare-bones branch 11 times, most recently from 8ef4e0c to 72edfac Compare June 7, 2024 18:59
Comment on lines -18 to -40
const AppHeader = ({
courseNumber, courseOrg, courseTitle, courseId,
}) => (
<Header
courseNumber={courseNumber}
courseOrg={courseOrg}
courseTitle={courseTitle}
courseId={courseId}
/>
);

AppHeader.propTypes = {
courseId: PropTypes.string.isRequired,
courseNumber: PropTypes.string,
courseOrg: PropTypes.string,
courseTitle: PropTypes.string.isRequired,
};

AppHeader.defaultProps = {
courseNumber: null,
courseOrg: 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.

This component was just passing parameters to <Header />.

Comment on lines 14 to 20
contentId,
org,
number,
title,
isHiddenMainMenu,
isLibrary,
}) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are using the same Header for courses and libraries now.

/>
{ meiliSearchEnabled && (
<SearchModal
isOpen={isShowSearchModalOpen}
courseId={courseId}
courseId={isLibrary ? undefined : contentId}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ToDo: We can make the search modal aware of whether the current library is the same way we do with courses. The search will work out of the box, but we need to revisit the page to change some wording ("all courses", "current course", etc..)

Copy link
Contributor

Choose a reason for hiding this comment

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

For now, we want the modal to only search courses and we're not going to show "Search all Courses and Libraries" even though it's possible.

To search libraries, users will have to click on a specific library and use the new search UI we're building, which is not in a modal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack! @bradenmacdonald

For now, we want the modal to only search courses and we're not going to show "Search all Courses and Libraries" even though it's possible.

It is worth to mention that currently we show library blocks in the modal and redirect to the parent library if you click on a hit.

Would you like me to include a fix in this PR to limit it only to courses?

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, yes please - let's keep that functionality in the code but for now add an additional filter to limit the search modal results to courses. Thanks.

Comment on lines 20 to 52
/**
* Hook to fetch the count of components and collections in a library.
* @param {string} libraryId - The ID of the library to fetch.
* @param {string} searchKeywords - Keywords to search for.
*/
export const useLibraryComponentCount = (libraryId, searchKeywords) => {
// Meilisearch code to get Collection and Component counts
const { data: connectionDetails } = useContentSearchConnection();

const indexName = connectionDetails?.indexName;
const client = React.useMemo(() => {
if (connectionDetails?.apiKey === undefined || connectionDetails?.url === undefined) {
return undefined;
}
return new MeiliSearch({ host: connectionDetails.url, apiKey: connectionDetails.apiKey });
}, [connectionDetails?.apiKey, connectionDetails?.url]);

const libFilter = `context_key = "${libraryId}"`;

const { totalHits: componentCount } = useContentSearchResults({
client,
indexName,
searchKeywords,
extraFilter: [libFilter], // ToDo: Add filter for components when collection is implemented
});

const collectionCount = 0; // ToDo: Implement collections count

return {
componentCount,
collectionCount,
};
};
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 created this hook to get only the component count for the library. Maybe we should replace this with another instance of the SearchContext when we add other filters. @ChrisChV @bradenmacdonald

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, when we get there what I want to do is move most of the "generic" search code out of search-modal into somewhere like generic/search/ and then we can use it in both search-modal/SearchModal.tsx and src/library-authoring/LibraryHome.tsx etc.

Copy link
Contributor Author

@rpenido rpenido Jun 19, 2024

Choose a reason for hiding this comment

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

@bradenmacdonald
I was thinking of exporting this directly from our search-modal feature (as I did in this file here). I know the current name is not the best, but it would be our search-engine feature that exports both the modal and the provider to use the search engine elsewhere. Maybe rename this feature to search-engine to make it explicit.

Or do you think having two features (search-modal and search-engine) would work best?

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, just to confirm: we are moving to use the search index as the primary source for listing content, right?

We might need to move some indexing tasks to run sync because if we add or remove a library, we could refetch before the index update and end up with out of sync data.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, exactly. When we make changes to libraries / library content, we can update the search index synchronously.

It's fine to export from search-modal for now, but I do think it's better to separate the library (search manager) from the two use cases: library home UI, and search modal.

@yusuf-musleh
Copy link
Contributor

@rpenido I left a comment on the last commit here

@rpenido rpenido added the create-sandbox open-craft-grove should create a sandbox environment from this PR label Jun 19, 2024
@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

@rpenido rpenido force-pushed the rpenido/fal-3753-library-home-page-bare-bones branch 2 times, most recently from 18a8482 to 2d3be09 Compare June 20, 2024 02:22
@rpenido rpenido force-pushed the rpenido/fal-3753-library-home-page-bare-bones branch from d197577 to 905dbb5 Compare July 5, 2024 16:17
Copy link
Contributor

@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.

👍 @rpenido Looks good to me! Great work!

  • I tested this: I followed the testing instructions in the PR, and everything is working as expected.
  • I read through the code
  • I checked for accessibility issues
  • Includes documentation

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.

Just a few minor nits other than that it's good to go!

];
const outlineLink = `${studioBaseUrl}/course/${courseId}`;
] : [];
const outlineLink = !isLibrary ? `${studioBaseUrl}/course/${contentId}` : `/course-authoring/library/${contentId}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

The /course-authoring/ part is configurable. I'd recommend using generatePath from react router for this.

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: 9937a59

Comment on lines +12 to +14
<FormattedMessage {...messages.noComponents} />
<Button iconBefore={Add}>
<FormattedMessage {...messages.addComponent} />
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't specific to this code, but I've seen this pattern a lot and I don't personally see the value in it.

To me the advantage of using FormattedMessage is that you can see the actual text in the react code instead of looking at the messages file. In this case it's better to use intl.formatMessage instead. FormattedMessage just uses useIntl internally anyway.

Copy link
Contributor

Choose a reason for hiding this comment

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

Are you saying to write { intl.formatMessage(messages.addComponent) } ? That's totally fine, but requires changing this function to have a statement body to be able to include const intl = useIntl() in scope, so writing it this way uses one less line of code, and I think is just as simple.

Comment on lines 22 to 27
const TAB_LIST = {
home: '',
components: 'components',
collections: 'collections',
};

Copy link
Contributor

Choose a reason for hiding this comment

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

Since we're using TypeScript now, this could be an enum?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great! Done: 3b2a6ad

isHiddenMainMenu={isHiddenMainMenu}
mainMenuDropdowns={mainMenuDropdowns}
outlineLink={outlineLink}
searchButtonAction={meiliSearchEnabled && openSearchModal}
searchButtonAction={meiliSearchEnabled ? openSearchModal : undefined}
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's hide the search button for libraries please.

Copy link
Contributor Author

@rpenido rpenido Jul 9, 2024

Choose a reason for hiding this comment

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

I don't think we agree here. Shouldn't we have the "same" header on all pages? I thought the search modal was a quick jump to content from anywhere in the course authoring. Could you elaborate a bit more?

Currently, the search icon appears in "all" pages (i.e., Taxonomy pages). We would need to create a new parameter for our header to hide it. Let me know if you think we want to go to this route!

Copy link
Contributor

Choose a reason for hiding this comment

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

Well I think people will be confused that the search icon on the library pages doesn't search libraries. But we can leave it for now and see what the product/UX folks say later when they review and try it out on the sandbox. It's a bit of an issue that the UX for searching libraries and the UX for searching courses are so completely different.

@bradenmacdonald
Copy link
Contributor

bradenmacdonald commented Jul 9, 2024

This is a weird bug, but if I go to the "Libraries" tab, then click on any library, then click back, the "New Library" button disappears.

Edit: also, just refreshing the Studio Home makes the buttons disappear?

Edit: I think this bug is on master too, actually

Screenshot

src/library-authoring/LibraryAuthoringPage.test.tsx Outdated Show resolved Hide resolved
</QueryClientProvider>
</IntlProvider>
</AppProvider>
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Not for this PR, but we should really make a re-usable RootWrapper for all our test files instead of writing this out in each one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you @bradenmacdonald . I was a bit divided about this before.
This structure explicitly states what is needed for this particular component, but it also adds a lot of boilerplate to the tests.

For the next tests, I will add some helpers for this (and the meilisearch stuff).

src/library-authoring/LibraryAuthoringPage.tsx Outdated Show resolved Hide resolved

return (
<Stack gap={3}>
<Section title="Recently Modified">
Copy link
Contributor

Choose a reason for hiding this comment

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

These titles need i18n

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed: 2a63186

/**
* Hook to fetch the count of components and collections in a library.
*/
export const useLibraryComponentCount = (libraryId: string, searchKeywords: string) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is temporary right? In the future we should have a <SearchContextProvider> on the Library Home page, and there should be no need to initialize a Meilisearch client manually.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes! This was refactored here: #1141

@@ -0,0 +1,3 @@
// @ts-check
Copy link
Contributor

Choose a reason for hiding this comment

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

Just make this file .ts please. Or do we really need 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.

I think this is good for helping us avoid inter-feature import. We should not import from ./seach-modal/Something. We should always import from explicitly exported members from ./search-modal

@rpenido rpenido force-pushed the rpenido/fal-3753-library-home-page-bare-bones branch from 9565a4b to 3b2a6ad Compare July 9, 2024 15:02
@rpenido
Copy link
Contributor Author

rpenido commented Jul 9, 2024

This is a weird bug, but if I go to the "Libraries" tab, then click on any library, then click back, the "New Library" button disappears.

Edit: also, just refreshing the Studio Home makes the buttons disappear?

Edit: I think this bug is on master too, actually

This seems to fix the issue: 01e817a

@rpenido
Copy link
Contributor Author

rpenido commented Jul 10, 2024

Thank you for the reviews @bradenmacdonald and @xitij2000!
I addressed the issues and added a comment about the search button in the head bar.

This is ready for another round.

@bradenmacdonald
Copy link
Contributor

Nice work on addressing those comments, @rpenido. @xitij2000 did you want to look at this again before we merge it?

@bradenmacdonald bradenmacdonald merged commit f60ddb5 into openedx:master Jul 10, 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.

@rpenido rpenido deleted the rpenido/fal-3753-library-home-page-bare-bones branch July 12, 2024 12:08
@mphilbrick211 mphilbrick211 added the FC Relates to an Axim Funded Contribution project label Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FC Relates to an Axim Funded Contribution project open-source-contribution PR author is not from Axim or 2U
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Library Home Page - "Bare Bones"
7 participants