From 2df8d3ca8b1ab08ba59ae08f4e81d6e5b95d3e4e Mon Sep 17 00:00:00 2001 From: Taimoor Ahmed Date: Thu, 16 Jul 2026 16:28:24 +0500 Subject: [PATCH] refactor: migrate Studio Home caller to standardized v3 API (FC-0118) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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/frontend-app-authoring#3127 Co-Authored-By: Claude Opus 4.8 --- src/studio-home/data/api.test.js | 2 +- src/studio-home/data/api.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/studio-home/data/api.test.js b/src/studio-home/data/api.test.js index febc5d07e2..4f47c9df86 100644 --- a/src/studio-home/data/api.test.js +++ b/src/studio-home/data/api.test.js @@ -69,7 +69,7 @@ describe('studio-home api calls', () => { }); it('should get studio v1 libraries data', async () => { - const apiLink = `${getApiBaseUrl()}/api/contentstore/v1/home/libraries`; + const apiLink = `${getApiBaseUrl()}/api/contentstore/v3/home/libraries/`; axiosMock.onGet(apiLink).reply(200, generateGetStudioHomeLibrariesApiResponse()); const result = await getStudioHomeLibraries(); const expected = generateGetStudioHomeLibrariesApiResponse(); diff --git a/src/studio-home/data/api.ts b/src/studio-home/data/api.ts index b9b43253d8..b1395e2282 100644 --- a/src/studio-home/data/api.ts +++ b/src/studio-home/data/api.ts @@ -2,7 +2,11 @@ import { camelCaseObject, snakeCaseObject, getConfig } from '@edx/frontend-platf import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth'; export const getApiBaseUrl = () => getConfig().STUDIO_BASE_URL; -export const getStudioHomeApiUrl = () => new URL('api/contentstore/v1/home', getApiBaseUrl()).href; +// FC-0118 (ADR 0028/0037): standardized v3 Studio Home endpoint. The trailing +// slash is required by the DRF DefaultRouter that serves the v3 `HomeViewSet` +// (the v1 route was a plain APIView). The aggregated home context lives at the +// `list` action `…/v3/home/`, and the library list at `…/v3/home/libraries/`. +export const getStudioHomeApiUrl = () => new URL('api/contentstore/v3/home/', getApiBaseUrl()).href; export const getRequestCourseCreatorUrl = () => new URL('request_course_creator', getApiBaseUrl()).href; export const getCourseNotificationUrl = (url) => new URL(url, getApiBaseUrl()).href; @@ -55,7 +59,9 @@ export interface LibrariesV1ListData { } export async function getStudioHomeLibraries(): Promise { - const { data } = await getAuthenticatedHttpClient().get(`${getStudioHomeApiUrl()}/libraries`); + // `getStudioHomeApiUrl()` already ends in a slash (`…/v3/home/`); the v3 + // library list is the `libraries` action at `…/v3/home/libraries/`. + const { data } = await getAuthenticatedHttpClient().get(`${getStudioHomeApiUrl()}libraries/`); return camelCaseObject(data); }