-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: edit Text components within content libraries [FC-0062] (#1240)
- Loading branch information
1 parent
9b61037
commit fd48fef
Showing
36 changed files
with
724 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import React from 'react'; | ||
import { useParams } from 'react-router-dom'; | ||
import { getConfig } from '@edx/frontend-platform'; | ||
|
||
import EditorPage from './EditorPage'; | ||
|
||
interface Props { | ||
/** Course ID or Library ID */ | ||
learningContextId: string; | ||
/** Event handler for when user cancels out of the editor page */ | ||
onClose?: () => void; | ||
/** Event handler called after when user saves their changes using an editor */ | ||
afterSave?: () => (newData: Record<string, any>) => void; | ||
} | ||
|
||
const EditorContainer: React.FC<Props> = ({ | ||
learningContextId, | ||
onClose, | ||
afterSave, | ||
}) => { | ||
const { blockType, blockId } = useParams(); | ||
if (blockType === undefined || blockId === undefined) { | ||
// istanbul ignore next - This shouldn't be possible; it's just here to satisfy the type checker. | ||
return <div>Error: missing URL parameters</div>; | ||
} | ||
if (!!onClose !== !!afterSave) { | ||
/* istanbul ignore next */ | ||
throw new Error('You must specify both onClose and afterSave or neither.'); | ||
// These parameters are a bit messy so I'm trying to help make it more | ||
// consistent here. For example, if you specify onClose, then returnFunction | ||
// is only called if the save is successful. But if you leave onClose | ||
// undefined, then returnFunction is called in either case, and with | ||
// different arguments. The underlying EditorPage should be refactored to | ||
// have more clear events like onCancel and onSaveSuccess | ||
} | ||
return ( | ||
<div className="editor-page"> | ||
<EditorPage | ||
courseId={learningContextId} | ||
blockType={blockType} | ||
blockId={blockId} | ||
studioEndpointUrl={getConfig().STUDIO_BASE_URL} | ||
lmsEndpointUrl={getConfig().LMS_BASE_URL} | ||
onClose={onClose} | ||
returnFunction={afterSave} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default EditorContainer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.