From 1bb5510e0e70ec4037f73168a956ba305a11b661 Mon Sep 17 00:00:00 2001 From: Muhammad Faraz Maqsood Date: Fri, 27 Jun 2025 17:39:49 +0500 Subject: [PATCH 1/6] fix: publish btn doesn't show after component edit When we edit & save the component, publish button doesn't show up until we refresh the page manualy or open this unit by opening previous unit and coming back to this unit again. In this commit, we are dispatching a storage event whenever we edit the component, it'll refresh the page & show the publish button as expected. --- src/course-unit/hooks.jsx | 18 ++++++++++++++++++ src/editors/data/redux/thunkActions/app.js | 10 ++++++++++ .../data/redux/thunkActions/app.test.js | 6 +++++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/course-unit/hooks.jsx b/src/course-unit/hooks.jsx index 7ab5eb5918..f707bae452 100644 --- a/src/course-unit/hooks.jsx +++ b/src/course-unit/hooks.jsx @@ -217,6 +217,24 @@ export const useCourseUnit = ({ courseId, blockId }) => { } }, [isMoveModalOpen]); + useEffect(() => { + const handlePageRefreshUsingStorage = (event) => { + // ignoring tests for if block, because it triggers when someone + // edits the component using editor which has a separate store + /* istanbul ignore next */ + if (event.key === 'courseRefreshTriggerOnComponentEditSave') { + dispatch(fetchCourseSectionVerticalData(blockId, sequenceId)); + dispatch(fetchCourseVerticalChildrenData(blockId, isSplitTestType)); + localStorage.removeItem(event.key); + } + }; + + window.addEventListener('storage', handlePageRefreshUsingStorage); + return () => { + window.removeEventListener('storage', handlePageRefreshUsingStorage); + }; + }, [blockId, sequenceId, isSplitTestType]); + return { sequenceId, courseUnit, diff --git a/src/editors/data/redux/thunkActions/app.js b/src/editors/data/redux/thunkActions/app.js index 8da9f24b71..4c5079a5a9 100644 --- a/src/editors/data/redux/thunkActions/app.js +++ b/src/editors/data/redux/thunkActions/app.js @@ -125,6 +125,16 @@ export const saveBlock = (content, returnToUnit) => (dispatch) => { content, onSuccess: (response) => { dispatch(actions.app.setSaveResponse(response)); + const parsedData = JSON.parse(response.config.data); + if (parsedData?.has_changes) { + const storageKey = 'courseRefreshTriggerOnComponentEditSave'; + localStorage.setItem(storageKey, Date.now()); + + window.dispatchEvent(new StorageEvent('storage', { + key: storageKey, + newValue: Date.now().toString(), + })); + } returnToUnit(response.data); }, })); diff --git a/src/editors/data/redux/thunkActions/app.test.js b/src/editors/data/redux/thunkActions/app.test.js index 35debc7f3c..3f8dc10c9e 100644 --- a/src/editors/data/redux/thunkActions/app.test.js +++ b/src/editors/data/redux/thunkActions/app.test.js @@ -352,7 +352,11 @@ describe('app thunkActions', () => { }); it('dispatches actions.app.setSaveResponse with response and then calls returnToUnit', () => { dispatch.mockClear(); - const response = 'testRESPONSE'; + const mockParsedData = { has_changes: true }; + const response = { + config: { data: JSON.stringify(mockParsedData) }, + data: {}, + }; calls[1][0].saveBlock.onSuccess(response); expect(dispatch).toHaveBeenCalledWith(actions.app.setSaveResponse(response)); expect(returnToUnit).toHaveBeenCalled(); From 1bf98f2bafac50d3c7bdf99f2a5a850ffcff3111 Mon Sep 17 00:00:00 2001 From: Asad Ali Date: Tue, 9 Sep 2025 08:45:27 +0500 Subject: [PATCH 2/6] fix: allow thumbnail upload on Videos page if no thumbnail (#2388) (#2434) * fix: allow thumbnail upload if no thumbnail * fix: improve thumbnail upload impl * test: fix tests * test: fix tests * fix: do not show thumbnail upload if not allowed * test: fix coverage * test: add thumbnail test * fix: display thumbnail overlay when video status is success --- .../videos-page/VideoThumbnail.jsx | 27 ++++++++++------ .../videos-page/VideoThumbnail.test.jsx | 32 +++++++++++++++++++ 2 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 src/files-and-videos/videos-page/VideoThumbnail.test.jsx diff --git a/src/files-and-videos/videos-page/VideoThumbnail.jsx b/src/files-and-videos/videos-page/VideoThumbnail.jsx index 2929c6d32d..fb7bf62054 100644 --- a/src/files-and-videos/videos-page/VideoThumbnail.jsx +++ b/src/files-and-videos/videos-page/VideoThumbnail.jsx @@ -48,21 +48,30 @@ const VideoThumbnail = ({ const isFailed = VIDEO_FAILURE_STATUSES.includes(status); const failedMessage = intl.formatMessage(messages.failedCheckboxLabel); - const showThumbnail = allowThumbnailUpload && thumbnail && isUploaded; + const showThumbnail = allowThumbnailUpload && isUploaded; return (
- {allowThumbnailUpload && showThumbnail &&
} + {allowThumbnailUpload && isUploaded &&
} {showThumbnail && !thumbnailError && pageLoadStatus === RequestStatus.SUCCESSFUL ? ( <>
- {intl.formatMessage(messages.thumbnailAltMessage, setThumbnailError(true)} - /> + { thumbnail ? ( + {intl.formatMessage(messages.thumbnailAltMessage, setThumbnailError(true)} + /> + ) : ( +
+ +
+ )}