From 62dfb7516913ba8d856c38c659c6d52d6921e586 Mon Sep 17 00:00:00 2001 From: Jillian Date: Sat, 26 Oct 2024 13:20:04 +1030 Subject: [PATCH] fix: use absolute URL for Export Tags menu item Use absolute URL for Export Tags menu item so that the menu item works no matter where in the course it's used. Fix this issue: https://github.com/openedx/frontend-app-authoring/issues/1380 (cherry picked from commit 774728a9c0739fe006d0951252196b5dab6bea58) --- src/course-outline/CourseOutline.jsx | 5 +++-- src/header/hooks.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/course-outline/CourseOutline.jsx b/src/course-outline/CourseOutline.jsx index e7468e68f..fe428c1c7 100644 --- a/src/course-outline/CourseOutline.jsx +++ b/src/course-outline/CourseOutline.jsx @@ -125,7 +125,8 @@ const CourseOutline = ({ courseId }) => { const [toastMessage, setToastMessage] = useState(/** @type{null|string} */ (null)); useEffect(() => { - if (location.hash === '#export-tags') { + // Wait for the course data to load before exporting tags. + if (courseId && courseName && location.hash === '#export-tags') { setToastMessage(intl.formatMessage(messages.exportTagsCreatingToastMessage)); getTagsExportFile(courseId, courseName).then(() => { setToastMessage(intl.formatMessage(messages.exportTagsSuccessToastMessage)); @@ -136,7 +137,7 @@ const CourseOutline = ({ courseId }) => { // Delete `#export-tags` from location window.location.href = '#'; } - }, [location]); + }, [location, courseId, courseName]); const [sections, setSections] = useState(sectionsList); diff --git a/src/header/hooks.js b/src/header/hooks.js index 9bcbd29e4..d4ce5fd0e 100644 --- a/src/header/hooks.js +++ b/src/header/hooks.js @@ -90,7 +90,7 @@ export const useToolsMenuItems = courseId => { }, ...(getConfig().ENABLE_TAGGING_TAXONOMY_PAGES === 'true' ? [{ - href: '#export-tags', + href: `${studioBaseUrl}/course/${courseId}#export-tags`, title: intl.formatMessage(messages['header.links.exportTags']), }] : [] ),