Skip to content
This repository was archived by the owner on Feb 14, 2025. It is now read-only.

Commit ac2444c

Browse files
author
kenclary
authored
Merge pull request #347 from openedx/kenclary/TNL-10742
feat: v2 xblocks should use v2 url. TNL-10742
2 parents 665a53a + ffd3118 commit ac2444c

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/editors/data/services/cms/urls.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ export const returnUrl = ({ studioEndpointUrl, unitUrl, learningContextId }) =>
1616
};
1717

1818
export const block = ({ studioEndpointUrl, blockId }) => (
19-
`${studioEndpointUrl}/xblock/${blockId}`
19+
blockId.includes('block-v1')
20+
? `${studioEndpointUrl}/xblock/${blockId}`
21+
: `${studioEndpointUrl}/api/xblock/v2/xblocks/${blockId}`
2022
);
2123

2224
export const blockAncestor = ({ studioEndpointUrl, blockId }) => (

src/editors/data/services/cms/urls.test.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ import {
2121

2222
describe('cms url methods', () => {
2323
const studioEndpointUrl = 'urLgoeStOstudiO';
24-
const blockId = 'blOckIDTeST123';
24+
const blockId = 'block-v1-blOckIDTeST123';
25+
const v2BlockId = 'blOckIDTeST123';
2526
const learningContextId = 'lEarnIngCOntextId123';
2627
const courseId = 'course-v1:courseId123';
2728
const libraryV1Id = 'library-v1:libaryId123';
@@ -62,10 +63,14 @@ describe('cms url methods', () => {
6263
});
6364
});
6465
describe('block', () => {
65-
it('returns url with studioEndpointUrl and blockId', () => {
66+
it('returns v1 url with studioEndpointUrl and blockId', () => {
6667
expect(block({ studioEndpointUrl, blockId }))
6768
.toEqual(`${studioEndpointUrl}/xblock/${blockId}`);
6869
});
70+
it('returns v2 url with studioEndpointUrl and v2BlockId', () => {
71+
expect(block({ studioEndpointUrl, blockId: v2BlockId }))
72+
.toEqual(`${studioEndpointUrl}/api/xblock/v2/xblocks/${v2BlockId}`);
73+
});
6974
});
7075
describe('blockAncestor', () => {
7176
it('returns url with studioEndpointUrl, blockId and ancestor query', () => {

0 commit comments

Comments
 (0)