Repository navigation
refactor: rename course catalog data to catalog data [FC-0137] - #174
brian-smith-tcril merged 11 commits into
Conversation
|
Thanks for the pull request, @rpenido! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo 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:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere 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:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #174 +/- ##
=======================================
Coverage 99.56% 99.56%
=======================================
Files 101 101
Lines 682 682
Branches 165 165
=======================================
Hits 679 679
Misses 2 2
Partials 1 1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| @@ -0,0 +1,251 @@ | |||
| ======================================== | |||
| 3. Use a Generic Catalog Search Endpoint | |||
| ======================================== | |||
There was a problem hiding this comment.
can you follow this guide for the rst headings? https://docs.openedx.org/en/latest/documentors/references/quick_reference.html#headings
(i know it seems trivial, but following these helps the ADRs build nicely into our docs site)
| "Categories" facet covering both courses and pathway types. | ||
|
|
||
| Changing the existing edx-search endpoint | ||
| ``/search/unstable/v0/course_list_search/`` in place would risk breaking its |
There was a problem hiding this comment.
the endpoint is named unstable/v0 and as far as I know there's only one consumer (frontend-app-catalog). why maintain the existing API contract?
and if we must continue maintaining this for some period of time, could it just be implemented as basically a ?category=course filter on top of the new endpoint?
There was a problem hiding this comment.
Agreed. No need to maintain two endpoints/indexes here. I updated the ADR here: 7fb99a9
The trade-off is that the catalog MFE and the backend have to ship together, which is now in Consequences.
|
|
||
| Add a new endpoint, POST ``/search/unstable/v0/catalog_list_search/``, | ||
| backed by one new mixed logical index, ``catalog_info``. The index name is | ||
| configurable via ``CATALOG_INFO_INDEX_NAME``; index metadata is never exposed |
There was a problem hiding this comment.
are you proposing to add CATALOG_INFO_INDEX_NAME as a django setting because we already have the COURSEWARE_INFO_INDEX_NAME setting?
the COURSEWARE_INFO_INDEX_NAME setting is broken--changing it to anything but the default doesn't actually propagate to all the the places that it would need to. And AFAICT there is no real reason to change the index name. let's not promise a new django setting in this ADR unless you see a strong reason for it.
There was a problem hiding this comment.
Agreed! Dropped CATALOG_INFO_INDEX_NAME in 7fb99a9
| existing consumer contract and the shared legacy internals it relies on stay | ||
| unchanged. | ||
|
|
||
| Add a new endpoint, POST ``/search/unstable/v0/catalog_list_search/``, |
There was a problem hiding this comment.
why unstable/v0 ? we're building a core feature. can we make it /search/v1/catalog_search ?
| Ownership: | ||
|
|
||
| * edx-platform owns course documents and normally pathway documents. | ||
| * An installed backend extension may own pathway documents instead. |
There was a problem hiding this comment.
why an extension? this is a core feature.
| Result type | ||
| ^^^^^^^^^^^ | ||
|
|
||
| ``result.type`` is solely the entity/rendering discriminator. There is no | ||
| separate type filter. |
There was a problem hiding this comment.
I don't understand what this means
There was a problem hiding this comment.
We use result.type to define whether we will render a pathway card or a course card, but the filters from the explore page shouldn't use it: we will filter using the category field (check the "Category" section below).
Since the information is redundant (and confusing), I'm dropping this section here: ead6afd
4ffa756 to
7fb99a9
Compare
|
Thanks for the review, @kdmccormick! I think I addressed all your comments. |
There was a problem hiding this comment.
Thanks @rpenido ! The ADR and the intent of the refactoring look great to me.
@brian-smith-tcril , could you also give just the code here a technical review pass?
|
Overall this is looking good! Couple things that stand out to me:
I think the answer to 1 will inform some of the naming decisions for 2. For the renames I'm thinking:
Edit: Looking at e87d4fd from #175 I see the name |
I renamed I kept |
brian-smith-tcril
left a comment
There was a problem hiding this comment.
Thanks for addressing my previous review so quickly, and sorry it took me so long to get back to this!
Great call on CoursesList! I 100% agree waiting for #176 makes sense there.
One thing that stood out to me that I didn't bring up in my previous review was
The public slot props
courseDataResultsLengthandtotalCourses, so existing site plugins keep working.
I'm super happy to see care being put into not breaking the slot API, but I do think we should put effort into moving away from names that no longer make sense. I wrote up a how-to guide in frontend-base (still just a PR at the moment: openedx/frontend-base#344) for handling this and other similar types of things.
In the process of that, I also realized the existing slots have slot props being built using types we aren't exporting (openedx/frontend-base#339 (comment))
With both of those in mind, I had Claude look through the PR and write up what it thinks makes sense to do here. Its write-up is below; I've read through it and agree with it.
This portion was written by Claude Code and reviewed before posting.
Types the slot props are built from
src/index.ts exports only the *SlotProps interfaces, and the package's exports map rules out deep imports, so a widget can't import any of the types those interfaces use. For the slots this PR touches, that is:
| Type | Declared in | Used by | Named in a README |
|---|---|---|---|
CatalogSearchResponse |
src/data/catalog-search/types.ts |
displayData on the data table and card view slots |
yes |
DataTableParams |
src/data/catalog-search/types.ts |
handleFetchData on the data table slot |
yes |
TableColumn |
CourseCatalogDataTableSlot/index.tsx |
tableColumns on the data table slot |
yes |
TableColumnFilterChoice |
CourseCatalogDataTableSlot/index.tsx |
TableColumn.filterChoices |
no |
What makes sense in this PR:
-
Export all four from
src/index.tsbeside the*SlotProps. -
Keep the old name beside the new one as a deprecated alias.
/** @deprecated Renamed to `CatalogSearchResponse`. */ export type CourseListSearchResponse = CatalogSearchResponse;
The two slot props, and the slot names
Renaming the two props would normally mean a v2 of each slot. Here it means a new identifier instead:
- ADR 0009 §2 bumps the version only "if it still make sense to use the same Identifier".
courseCatalog*stops making sense once the table holds pathways (#175) and a pathway card renders under it (#177).- So every slot in the family gets a new identifier with the prefix dropped, not a
v2.
Each slot should get exactly one new identifier across the stack, so the PR it happens in is the one where the slot's contract last changes:
| Slot today | New identifier | Props change | Last contract change | Lands in |
|---|---|---|---|---|
CourseCatalogIntroSlot |
catalog.catalogIntro.v1 |
courseDataResultsLength → resultsCount |
none after this PR | #174 |
CourseCatalogSearchFieldSlot |
catalog.catalogSearchField.v1 |
none | none after this PR | #174 |
CourseCatalogDataTableControlBarSlot |
catalog.catalogDataTableControlBar.v1 |
none | none after this PR | #174 |
CourseCatalogDataTableTableFooterSlot |
catalog.catalogDataTableTableFooter.v1 |
none | none after this PR | #174 |
CourseCatalogDataTableCourseCardSlot |
catalog.catalogDataTableCourseCard.v1 |
none (it is still a course card) | none after this PR | #174 |
CourseCatalogDataTableSlot |
catalog.catalogDataTable.v1 |
totalCourses → totalItems |
displayData's type becomes the course-or-pathway union |
#175 |
CourseCatalogDataTableCardViewSlot |
catalog.catalogDataTableCardView.v1 |
none | displayData's type becomes the union |
#175 |
| pathway card (new) | catalog.catalogDataTablePathwayCard.v1 |
— | born | #177 |
The data table and card view files are untouched by #175, but the type they name changes shape there, which is the how-to's "changing a prop's type" case, so #175 needs a new version of each anyway. Doing their renames there, born with the union type, gives each one bump instead of two.
The steps are the how-to's, with the new name standing in for the new version suffix. idAliases doesn't fit here: an alias would make old and new one slot with one props interface.
I'm open to other names (my goal was just "don't say 'Course Catalog' anymore"), and other thoughts on when to make new slots/slot versions (you have a better sense of what's yet-to-come than I do).
Let me know if you have any questions/concerns (or suggestions for how to improve the frontend-base docs I PR'd!)
I know this review has gotten a little bigger/gone a little deeper than either of us expected at first, so I want to say thank you for being so patient and understanding. Looking forward to getting this one landed!
4de357b to
1e1c048
Compare
|
Thanks for the review @brian-smith-tcril!
No need to apologise at all! The extra depth is genuinely useful, and catching the slot API issues now is much better than having to break them after release. I went ahead with the rename and deprecation for this PR. The commit is 1e1c048:
Note that we have a case still not covered by openedx/frontend-base#344: Since this is not a new version, we are deprecating one slot in favor of another. Since I renamed the old folder, I kept the older documentation as I will continue with the same approach for #175 and the following PRs, keeping the old ids, interfaces and props in place and deprecated. Let me know if you see anything you would like changed before I carry on. |
|
Thanks for the quick update!
Good catch! I updated the how-to in openedx/frontend-base#344 to include a few slot rename examples, and also made an issue to add "how to document slots" documentation to For the I also realized that some of these are "pure" renames (only the slot name is changing, not the props or anything else), so we can use Thanks again! |
1e1c048 to
9a5363a
Compare
Thanks @brian-smith-tcril, the pure rename example makes this clear (and the diff smaller). I updated here:
The commit is 9a5363a (I amended the last one). Please let me know if that matches what you had in mind. |
|
I made the category colors required here: 5e5d27e |
|
@brian-smith-tcril @kdmccormick Is there anything we can do to help this get merged? |
|
@rpenido I'm looking at this again this morning. |
brian-smith-tcril
left a comment
There was a problem hiding this comment.
This LGTM! I left a few non-blocking suggestions, mostly just some hard to find "course catalog" references.
It'd also be good to update the PR body, some of the lines in there are no longer true after the review changes.
Sorry for the delay!
This portion was written by Claude Code and reviewed before posting.
Two small things on lines that aren't part of the diff, so they are here as a patch and not as inline suggestions:
- A test title in
src/catalog/CatalogPage.test.tsxstill saystotalCourses, the page local this PR renamed tototalItems. - The other four renamed slot READMEs have the same "Course catalog" wording as
src/slots/CatalogIntroSlot/README.md; this is the same change as the inline suggestions there.
Patch (19 lines, applies with git apply --unidiff-zero)
--- a/src/catalog/CatalogPage.test.tsx
+++ b/src/catalog/CatalogPage.test.tsx
@@ -1193 +1193 @@
- it('should calculate pageCount as 0 when both total and totalCourses are 0', () => {
+ it('should calculate pageCount as 0 when both total and totalItems are 0', () => {
--- a/src/slots/CatalogSearchFieldSlot/README.md
+++ b/src/slots/CatalogSearchFieldSlot/README.md
@@ -16 +16 @@
-This slot is used to replace/modify/hide the entire Course catalog page search field.
+This slot is used to replace/modify/hide the entire Catalog page search field.
@@ -22 +22 @@
-
+
@@ -63 +63 @@
-
+
@@ -65 +65 @@
-Add the following to your site config to replace the Course catalog search field entirely (in this case with a centered "🔍" `h1` tag).
+Add the following to your site config to replace the Catalog search field entirely (in this case with a centered "🔍" `h1` tag).
@@ -95 +95 @@
-Add the following to your site config to replace the Course catalog search field with a floating-label input plus a row of "popular searches" chips that invoke `setSearchInput` / `handleSearch` when clicked.
+Add the following to your site config to replace the Catalog search field with a floating-label input plus a row of "popular searches" chips that invoke `setSearchInput` / `handleSearch` when clicked.
--- a/src/slots/CourseCatalogDataTableSlots/CatalogDataTableControlBarSlot/README.md
+++ b/src/slots/CourseCatalogDataTableSlots/CatalogDataTableControlBarSlot/README.md
@@ -15 +15 @@
-This slot is used to replace/modify/hide the entire Course catalog page data table control bar.
+This slot is used to replace/modify/hide the entire Catalog page data table control bar.
@@ -21 +21 @@
-
+
@@ -62 +62 @@
-
+
@@ -64 +64 @@
-Add the following to your site config to replace the Course catalog control bar entirely (in this case with a centered "🎛️" `h1` tag).
+Add the following to your site config to replace the Catalog control bar entirely (in this case with a centered "🎛️" `h1` tag).
@@ -94 +94 @@
-Add the following to your site config to replace the Course catalog control bar with an alert component that reads the slot's `currentPageResultsCount` and `totalResultsCount` props.
+Add the following to your site config to replace the Catalog control bar with an alert component that reads the slot's `currentPageResultsCount` and `totalResultsCount` props.
--- a/src/slots/CourseCatalogDataTableSlots/CatalogDataTableTableFooterSlot/README.md
+++ b/src/slots/CourseCatalogDataTableSlots/CatalogDataTableTableFooterSlot/README.md
@@ -10 +10 @@
-This slot is used to replace/modify/hide the entire Course catalog page data table footer.
+This slot is used to replace/modify/hide the entire Catalog page data table footer.
@@ -16 +16 @@
-
+
@@ -57 +57 @@
-
+
@@ -59 +59 @@
-Add the following to your site config to replace the Course catalog data table footer entirely (in this case with a centered "🦶" `h1` tag).
+Add the following to your site config to replace the Catalog data table footer entirely (in this case with a centered "🦶" `h1` tag).
--- a/src/slots/CourseCatalogDataTableSlots/CourseCatalogDataTableCardViewSlot/CatalogDataTableCourseCardSlot/README.md
+++ b/src/slots/CourseCatalogDataTableSlots/CourseCatalogDataTableCardViewSlot/CatalogDataTableCourseCardSlot/README.md
@@ -21 +21 @@
-This slot is used to replace/modify/hide the entire Course catalog page data table course card.
+This slot is used to replace/modify/hide the entire Catalog page data table course card.
@@ -27 +27 @@
-
+
@@ -72 +72 @@
-
+
@@ -102 +102 @@
-
+Co-authored-by: Brian Smith <112954497+brian-smith-tcril@users.noreply.github.com>
Thanks @brian-smith-tcril! I updated the PR body and applied the suggestions (657bde6) and the patch (016f943). |
Co-authored-by: Brian Smith <112954497+brian-smith-tcril@users.noreply.github.com>
|
🎉 This PR is included in version 1.0.0-alpha.5 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Description
This is the first PR of the catalog split from #169. It renames the catalog page's course-specific data layer, state and slot identifiers to "catalog", so the same code can later hold pathways without the name lying. There is no behavior change, no feature, and no UI change: it is mostly
git mvplus identifier renames, which is why the diff is large but mechanical.Renamed:
src/data/course-list-search/tosrc/data/catalog-search/fetchCourseListSearchtofetchCatalogSearch,useCourseListSearchtouseCatalogSearch,CourseListSearchHooktoCatalogSearchHook, andgetCourseListSearchUrltogetCatalogSearchUrlCourseListSearchResponsetoCatalogSearchResponseandCourseListSearchParamstoCatalogSearchParamsmockCourseListSearchResponsetomockCatalogSearchResponse, including the fixture filesrc/catalog/hooks/useCourseDatatouseCatalogData,UseCourseDataPropstoUseCatalogDataProps,previousCourseDatatopreviousCatalogData, andcourseDatatocatalogDatatotalCoursesandhasCoursestototalItemsandhasItemsGetPageTitleProps.courseDataResultsLengthtoresultsCountSlot identifiers:
catalogIntro.v1replacescourseCatalogIntro.v1and takesresultsCountinstead ofcourseDataResultsLength. The new slot still renders the oldcourseCatalogIntro.v1inside it, passingcourseDataResultsLength={resultsCount}, so existing widgets keep working. The old docs are kept asREADME.courseCatalogIntro.v1.mdand linked from the new README.catalogSearchField.v1,catalogDataTableControlBar.v1,catalogDataTableTableFooter.v1andcatalogDataTableCourseCard.v1are pure renames. They register the old ids throughidAliases, keep the old interface names as deprecated aliases, and carry a single README with the deprecation warning at the top.courseCatalogDataTable.v1andcourseCatalogDataTableCardView.v1keep their ids here. Their contract changes with the mixed result type in feat: support mixed course and pathway search responses [FC-0137] #175, so they get their new identifiers there.src/index.tsnow also exportsCatalogSearchParams,CatalogSearchResponse,DataTableParams,TableColumnandTableColumnFilterChoice, since the slot props are built from them and the package does not allow deep imports.CourseListSearchResponseandCourseListSearchParamsstay as deprecated aliases.Deliberately not renamed here:
.../course_list_search/, with a comment pointing at the ADR cutover. The endpoint is still course-only, sogetCatalogSearchUrl()still returns it.totalCourses, so existing site plugins keep working. feat: support mixed course and pathway search responses [FC-0137] #175 renames it tototalItemswith the mixed response._doccompatibility arm andENABLE_COURSE_SORTING_BY_START_DATE, which are removed with the endpoint cutover, not here.It also adds
docs/decisions/0003-use-a-generic-catalog-search-endpoint.rst(status: Proposed), documenting the backend contract for the planned genericcatalog_searchendpoint, the category registry, the required pathway category colors, and the future frontend cutover. The app does not call the new endpoint yet.Supporting information
Part of the catalog split from #169. Branch
rpenido/fal-4374/catalog-rename, based onmaster. The rest of the stack builds on this one.Testing instructions
.nvmrcand install dependencies withnpm ci.npm run devagainst a running Open edX instance and open http://apps.local.openedx.io:1998/catalog and http://apps.local.openedx.io:1998/catalog/courses.homeCourseCard,catalogDataTableCourseCardandcourseCatalogDataTableslots from a site config and verify the plugin renders.courseCatalogIntro,courseCatalogSearchField,courseCatalogDataTableControlBar,courseCatalogDataTableTableFooter,courseCatalogDataTableCourseCard) and verify those still render.AI disclosure: Use Claude to help with the split and drafting this pull request description.
Private ref: FAL-4374