refactor: migrate Studio Home caller to standardized v3 API (FC-0118)#3140
refactor: migrate Studio Home caller to standardized v3 API (FC-0118)#3140taimoor-ahmed-1 wants to merge 1 commit into
Conversation
FC-0118 (ADR 0028/0037): point the Studio Home landing + libraries-tab reads at the new standardized `/api/contentstore/v3/home/` endpoint instead of v1. The v3 `HomeViewSet` is served by a DRF DefaultRouter, so the URLs now carry the required trailing slash: - `getStudioHomeData` → GET `…/v3/home/` (list action) - `getStudioHomeLibraries` → GET `…/v3/home/libraries/` (libraries action) `getStudioHomeApiUrl()` now returns the trailing-slash base, and `getStudioHomeLibraries` builds `…home/libraries/` off it (no leading slash). The default (full) response shape is unchanged between v1 and v3 (ADR 0036 `?fields=` presets are opt-in and default to the full payload), so this is a behaviour-preserving swap. Test mocks that reference `getStudioHomeApiUrl()` update automatically; the one hardcoded libraries URL in `api.test.js` is bumped to the v3 path. Refs openedx#3127 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Thanks for the pull request, @taimoor-ahmed-1! 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. 🔘 Update the status of your PRYour PR is currently marked as a draft. After completing the steps above, update its status by clicking "Ready for Review", or removing "WIP" from the title, as appropriate. 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:
💡 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 #3140 +/- ##
==========================================
+ Coverage 95.76% 95.77% +0.01%
==========================================
Files 1396 1396
Lines 33308 33399 +91
Branches 7820 7855 +35
==========================================
+ Hits 31897 31988 +91
- Misses 1352 1367 +15
+ Partials 59 44 -15 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
⛔ Draft — blocked by #2540 (do not merge yet)
This PR is intentionally opened as a draft. It is item #2 of the FC-0118
Studio-API caller migration tracked in #3127,
and it is on hold pending #2540 (the "Studio Home" Redux → React Query +
Context refactor). #2540 intends to break the kitchen-sink Studio Home state
(course list, library list, permissions, feature flags, branding) into smaller,
purpose-specific queries; versioning this endpoint as-is would entrench a payload
shape we plan to remove. Do not merge until #2540's direction is settled.
Merge order / dependencies
v2 → v4PR (item adds transifex config and test string #3 ofMigrate Studio API callers to standardized v3/v4 endpoints (FC-0118) #3127) also edits
src/studio-home/data/api.ts. Suggested order: this PR(Course Home [BD-03] [BB-2542] ]Add discussions configuration UI wireframe in MFE #2) first, then Home Courses adds transifex config and test string #3 rebases on top.
Description
Migrates the Studio Home landing page and libraries tab reads from the
v1 endpoint to the standardized v3 endpoint (FC-0118, ADR 0028/0037):
getStudioHomeApiUrl()now targets…/api/contentstore/v3/home/instead of…/v1/home. The v3HomeViewSetis served by a DRFDefaultRouter, so theURL now carries the required trailing slash.
getStudioHomeData→GET …/v3/home/(the aggregatedlistaction).getStudioHomeLibraries→GET …/v3/home/libraries/(thelibrariesaction). The helper builds
home/libraries/off the trailing-slash base.The default (full) response shape is unchanged between v1 and v3 (ADR 0036
?fields=presets are opt-in and default to the full payload), so this is abehaviour-preserving swap.
Supporting information
HomeViewSetregistered athomeviaDefaultRouterin
cms/djangoapps/contentstore/rest_api/v3/urls.py; exposesGET /home/(list),/home/courses/, and/home/libraries/.Testing instructions
npm cinpx jest src/studio-homeand that the network tab shows requests to
/api/contentstore/v3/home/and/api/contentstore/v3/home/libraries/.Other information
src/studio-home/data/api.ts— v3 base URL + trailing slash;libraries/concatenation fixed for the trailing-slash base.
src/studio-home/data/api.test.js— bump the hardcoded libraries mock to v3.getStudioHomeApiUrl()reference it byfunction, so they track the new URL automatically.
src/studio-home(113 tests) passes;dprint checkis clean. The onlylibrary-authoring failures in a broad run are pre-existing, date-dependent
flakes on
master(identical failure set with and without this change).