Skip to content

Commit

Permalink
feat: make the text editor work with content libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
bradenmacdonald committed Aug 29, 2024
1 parent 735d978 commit dde8385
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
3 changes: 1 addition & 2 deletions src/editors/data/redux/app/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ export const returnUrl = createSelector(

export const isInitialized = createSelector(
[
module.simpleSelectors.unitUrl,
module.simpleSelectors.blockValue,
],
(unitUrl, blockValue) => !!(unitUrl && blockValue),
(blockValue) => !!(blockValue),
);

export const displayTitle = createSelector(
Expand Down
11 changes: 9 additions & 2 deletions src/editors/data/redux/thunkActions/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ export const initialize = (data) => (dispatch) => {
const editorType = data.blockType;
dispatch(actions.app.initialize(data));
dispatch(module.fetchBlock());
dispatch(module.fetchUnit());
if (data.blockId.startsWith('block-v1:')) {
dispatch(module.fetchUnit());
}
switch (editorType) {
case 'problem':
dispatch(module.fetchImages({ pageNumber: 0 }));
Expand All @@ -100,7 +102,12 @@ export const initialize = (data) => (dispatch) => {
dispatch(module.fetchCourseDetails());
break;
case 'html':
dispatch(module.fetchImages({ pageNumber: 0 }));
if (data.learningContextId.startsWith('lib:')) {
// eslint-disable-next-line no-console
console.log('Not fetching image assets - not implemented yet for content libraries.');
} else {
dispatch(module.fetchImages({ pageNumber: 0 }));
}
break;
default:
break;
Expand Down
6 changes: 1 addition & 5 deletions src/editors/data/services/cms/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ export const blockAncestor = ({ studioEndpointUrl, blockId }) => {
if (blockId.includes('block-v1')) {
return `${block({ studioEndpointUrl, blockId })}?fields=ancestorInfo`;
}
// this url only need to get info to build the return url, which isn't used by V2 blocks
// (temporary) don't throw error, just return empty url. it will fail it's network connection but otherwise
// the app will run
// throw new Error('Block ancestor not available (and not needed) for V2 blocks');
return '';
throw new Error('Block ancestor not available (and not needed) for V2 blocks');
};

export const blockStudioView = ({ studioEndpointUrl, blockId }) => (
Expand Down

0 comments on commit dde8385

Please sign in to comment.