-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Course unit - Rendering xblocks in iframes #201
Conversation
c6da976
to
4595dec
Compare
dd8a0f9
to
509070d
Compare
9a76daf
to
65f02cc
Compare
Do you mind issuing this PR to the openedx org? That way it's clearer what's being changed in relation to master. |
@arbrandes I don't mind, thank you |
88821ab
to
839ce39
Compare
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## ts-develop #201 +/- ##
=============================================
Coverage ? 88.02%
=============================================
Files ? 647
Lines ? 10988
Branches ? 2280
=============================================
Hits ? 9672
Misses ? 1256
Partials ? 60 ☔ View full report in Codecov by Sentry. |
839ce39
to
b12ba83
Compare
@@ -34,12 +42,17 @@ const CourseXBlock = ({ | |||
const courseId = useSelector(getCourseId); | |||
const canEdit = useSelector(getCanEdit); | |||
const intl = useIntl(); | |||
const iframeUrl = getIFrameUrl({ blockId: id }); | |||
const xblockIframeHtmlAndResources = useSelector(getXBlockIframeHtmlAndResources); | |||
const xblockInstanceHtmlAndResources = find(xblockIframeHtmlAndResources, { xblockId: id }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could explain more in detail how does xblockIframeHtmlAndResources
look like?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}; | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export const getHandlerUrl = async (blockId) => getXBlockHandlerUrl(blockId, 'handler_name'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two functions maybe we should move to the api.js
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[question] Do we need to create a wrapper function instead of a single function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thanks
It makes sence
* The IFrame is resized responsively so that it fits the content height. | ||
* | ||
* We use an IFrame so that the XBlock code, including user-authored HTML, | ||
* cannot access things like the user's cookies, nor can it make GET/POST |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this comment is not relevant. Maybe to reduce the size of it or just remove.
We can use user's cookies using our workaround.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
}; | ||
const iframeRef = useRef(null); | ||
const [html, setHtml] = useState(null); | ||
const [iFrameHeight, setIFrameHeight] = useState(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const [iFrameHeight, setIFrameHeight] = useState(0); | |
const [iframeHeight, setIFrameHeight] = useState(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
const iframeRef = useRef(null); | ||
const [html, setHtml] = useState(null); | ||
const [iFrameHeight, setIFrameHeight] = useState(0); | ||
const [iframeKey, setIframeKey] = useState(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const [iframeKey, setIframeKey] = useState(0); | |
const [iframeKey, setIFrameKey] = useState(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
src/course-unit/data/api.js
Outdated
* @param {string} itemId - The ID of the XBlock item. | ||
* @returns {Promise<Object>} A Promise that resolves with the XBlock iframe data. | ||
*/ | ||
export async function getXBlockIframeData(itemId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export async function getXBlockIframeData(itemId) { | |
export async function getXBlockIFrameData(itemId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
src/course-unit/data/selectors.js
Outdated
@@ -14,6 +14,7 @@ export const getSequenceId = (state) => state.courseUnit.sequenceId; | |||
export const getCourseVerticalChildren = (state) => state.courseUnit.courseVerticalChildren; | |||
export const getClipboardData = (state) => state.courseUnit.clipboardData; | |||
const getLoadingStatuses = (state) => state.courseUnit.loadingStatus; | |||
export const getXBlockIframeHtmlAndResources = (state) => state.courseUnit.xblockIframeHtmlAndResources; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export const getXBlockIframeHtmlAndResources = (state) => state.courseUnit.xblockIframeHtmlAndResources; | |
export const getXBlockIFrameHtmlAndResources = (state) => state.courseUnit.xblockIframeHtmlAndResources; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected
src/course-unit/data/slice.js
Outdated
@@ -21,6 +21,7 @@ const slice = createSlice({ | |||
courseVerticalChildren: {}, | |||
clipboardData: null, | |||
staticFileNotices: {}, | |||
xblockIframeHtmlAndResources: [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xblockIframeHtmlAndResources: [], | |
xblockIFrameHtmlAndResources: [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
src/course-unit/data/slice.js
Outdated
@@ -115,6 +116,9 @@ const slice = createSlice({ | |||
// This avoids the need to copy the array beforehand | |||
state.courseVerticalChildren.children.sort((a, b) => (indexMap.get(a.id) || 0) - (indexMap.get(b.id) || 0)); | |||
}, | |||
fetchXBlockIframeResources: (state, { payload }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fetchXBlockIframeResources: (state, { payload }) => { | |
fetchXBlockIFrameResources: (state, { payload }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
src/course-unit/data/slice.js
Outdated
@@ -115,6 +116,9 @@ const slice = createSlice({ | |||
// This avoids the need to copy the array beforehand | |||
state.courseVerticalChildren.children.sort((a, b) => (indexMap.get(a.id) || 0) - (indexMap.get(b.id) || 0)); | |||
}, | |||
fetchXBlockIframeResources: (state, { payload }) => { | |||
state.xblockIframeHtmlAndResources.push(payload); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
state.xblockIframeHtmlAndResources.push(payload); | |
state.xblockIFrameHtmlAndResources.push(payload); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And in all other cases either iframe
or somethingIFrame
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
package.json
Outdated
@@ -88,7 +88,8 @@ | |||
"regenerator-runtime": "0.13.7", | |||
"universal-cookie": "^4.0.4", | |||
"uuid": "^3.4.0", | |||
"yup": "0.31.1" | |||
"yup": "0.31.1", | |||
"querystring": "0.2.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[question] Do we need to install this package because I can't find usage of them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes you are right
We don't use this package
Successfully deleted
}; | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export const getHandlerUrl = async (blockId) => getXBlockHandlerUrl(blockId, 'handler_name'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[question] Do we need to create a wrapper function instead of a single function?
dispatch(showProcessingNotification(NOTIFICATION_MESSAGES.adding)); | ||
|
||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dispatch(showProcessingNotification(NOTIFICATION_MESSAGES.adding)); | |
try { | |
dispatch(showProcessingNotification(NOTIFICATION_MESSAGES.adding)); | |
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have this indentation in all sleds in this file
Do we need to delete it specifically in fetchXBlockIframeHtmlAndResourcesQuery
?
@PKulkoRaccoonGang [question] Should we cover our feature with unit tests in this PR? |
23003ab
to
1f8eafc
Compare
@ihor-romaniuk Thank you for your attention 💯 We decided there will be no test coverage for now. |
* feat: added xblock render engine * feat: connected iframe template * feat: CSS and JS transfering * feat: show video xblock * feat: added multiply xblocks * feat: rendering advanced components * fix: add solution for request from within the iframe * feat: iframe height * refactor: code refactoring * fix: fixed platform ajax prefix * refactor: global refactoring * refactor: show LTI xblock * refactor: removed old xblock-content * refactor: code refactoring * refactor: some refactoring * refactor: refactoring * refactor: code refactoring * refactor: refactoring after review --------- Co-authored-by: monteri <lansevermore>
* feat: added xblock render engine * feat: connected iframe template * feat: CSS and JS transfering * feat: show video xblock * feat: added multiply xblocks * feat: rendering advanced components * fix: add solution for request from within the iframe * feat: iframe height * refactor: code refactoring * fix: fixed platform ajax prefix * refactor: global refactoring * refactor: show LTI xblock * refactor: removed old xblock-content * refactor: code refactoring * refactor: some refactoring * refactor: refactoring * refactor: code refactoring * refactor: refactoring after review --------- Co-authored-by: monteri <lansevermore>
* feat: added xblock render engine * feat: connected iframe template * feat: CSS and JS transfering * feat: show video xblock * feat: added multiply xblocks * feat: rendering advanced components * fix: add solution for request from within the iframe * feat: iframe height * refactor: code refactoring * fix: fixed platform ajax prefix * refactor: global refactoring * refactor: show LTI xblock * refactor: removed old xblock-content * refactor: code refactoring * refactor: some refactoring * refactor: refactoring * refactor: code refactoring * refactor: refactoring after review --------- Co-authored-by: monteri <lansevermore>
* feat: added xblock render engine * feat: connected iframe template * feat: CSS and JS transfering * feat: show video xblock * feat: added multiply xblocks * feat: rendering advanced components * fix: add solution for request from within the iframe * feat: iframe height * refactor: code refactoring * fix: fixed platform ajax prefix * refactor: global refactoring * refactor: show LTI xblock * refactor: removed old xblock-content * refactor: code refactoring * refactor: some refactoring * refactor: refactoring * refactor: code refactoring * refactor: refactoring after review --------- Co-authored-by: monteri <lansevermore>
* feat: added xblock render engine * feat: connected iframe template * feat: CSS and JS transfering * feat: show video xblock * feat: added multiply xblocks * feat: rendering advanced components * fix: add solution for request from within the iframe * feat: iframe height * refactor: code refactoring * fix: fixed platform ajax prefix * refactor: global refactoring * refactor: show LTI xblock * refactor: removed old xblock-content * refactor: code refactoring * refactor: some refactoring * refactor: refactoring * refactor: code refactoring * refactor: refactoring after review --------- Co-authored-by: monteri <lansevermore>
fix: [AXIMST-27] Unit page - change iframe pararm for display xblock content (#151) feat: [AXIMST-52] display unit and xblock render errors (#191) * feat: [AXIMST-52] display unit and xblock render errors * fix: after discussion * fix: after review feat: Course unit - Rendering xblocks in iframes (#201) * feat: added xblock render engine * feat: connected iframe template * feat: CSS and JS transfering * feat: show video xblock * feat: added multiply xblocks * feat: rendering advanced components * fix: add solution for request from within the iframe * feat: iframe height * refactor: code refactoring * fix: fixed platform ajax prefix * refactor: global refactoring * refactor: show LTI xblock * refactor: removed old xblock-content * refactor: code refactoring * refactor: some refactoring * refactor: refactoring * refactor: code refactoring * refactor: refactoring after review --------- Co-authored-by: monteri <lansevermore> feat: [AXIMST-739] added xblock actions (#218) * feat: [AXIMST-739] added xblock actions * refactor: code refactoring * refactor: refactoring after review fix: after cherru-pick fix: after cherry-pick refactor: removed canEdit mock (#224) fix: [AXIMST-655] fixed position of the view-port after loading the unit page (#217) fix: [AXIMST-719] Course unit - Xblock problems (#213) * fix: [AXIMST-719] fixed xblock problems * fix: added asset and static replacer * feat: added style extractor * refactor: code refactoring * refactor: after review fix: [AXIMST-718] Course unit - Created logic for getting CSRF token (#226) * fix: created logic for getting csrf token * fix: usage of csrfTokenData * refactor: code refactoring --------- Co-authored-by: monteri <lansevermore> fix: [AXIMST-745] added studioBaseUrl for static paths (#228) refactor: [AXIMST-746] Unit page performance refactoring (#229) Co-authored-by: Kyrylo Hudym-Levkovych <[email protected]> fix: [AXIMST-785] fixed discard logic (#232) feat: [AXIMST-800] Course unit - Added Collapse and Expand all buttons for xblocks (#234) * feat: [AXIMST-800] added Collapse and Expand all buttons for xblocks * feat: added tests refactor: code refactoring
* feat: added xblock render engine * feat: connected iframe template * feat: CSS and JS transfering * feat: show video xblock * feat: added multiply xblocks * feat: rendering advanced components * fix: add solution for request from within the iframe * feat: iframe height * refactor: code refactoring * fix: fixed platform ajax prefix * refactor: global refactoring * refactor: show LTI xblock * refactor: removed old xblock-content * refactor: code refactoring * refactor: some refactoring * refactor: refactoring * refactor: code refactoring * refactor: refactoring after review --------- Co-authored-by: monteri <lansevermore>
Dependencies
Edx-platform ts-develop branch
Description
This PR demonstrates the xblock content display functionality for the course unit page. The current implementation is a demonstration. Work on refactoring and displaying the Drag and Drop block continues.
The primary features were implemented:
Developer notes
Testing instructions
contentstore.new_studio_mfe.use_new_unit_page
in the CMS admin panel.ENABLE_UNIT_PAGE=true
is enabled.Screen.Recording.2024-03-15.at.12.01.47.mov