From 17a102d5cf261ac3ce486be61cbd52f5f1176684 Mon Sep 17 00:00:00 2001 From: Ghassan Maslamani Date: Tue, 6 Dec 2022 12:16:23 +0200 Subject: [PATCH] fix: fix tabs urls on progress tab This fix does fixes the url links by getting them from the state simliar to how tabs navigation gets them. This would allow it work for PUBLIC_PATH is not '/', i.e. in tutor. This was reported in openedx/build-test-release-wg/issues/222 --- .../grades/detailed-grades/DetailedGrades.jsx | 26 ++++++++++++------- .../related-links/RelatedLinks.jsx | 14 ++++++++-- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/course-home/progress-tab/grades/detailed-grades/DetailedGrades.jsx b/src/course-home/progress-tab/grades/detailed-grades/DetailedGrades.jsx index 8a7f45508d..62c0e1d5da 100644 --- a/src/course-home/progress-tab/grades/detailed-grades/DetailedGrades.jsx +++ b/src/course-home/progress-tab/grades/detailed-grades/DetailedGrades.jsx @@ -19,6 +19,7 @@ function DetailedGrades({ intl }) { } = useSelector(state => state.courseHome); const { org, + tabs, } = useModel('courseHomeMeta', courseId); const { gradesFeatureIsFullyLocked, @@ -36,11 +37,14 @@ function DetailedGrades({ intl }) { }); }; - const outlineLink = ( + const overviewTab = tabs.find(tab => tab.slug === 'outline'); + const overviewTabUrl = overviewTab && overviewTab.url; + + const outlineLink = overviewTabUrl && ( @@ -63,14 +67,16 @@ function DetailedGrades({ intl }) { {!hasSectionScores && (

{intl.formatMessage(messages.detailedGradesEmpty)}

)} -

- -

+ {overviewTabUrl && ( +

+ +

+ )} ); } diff --git a/src/course-home/progress-tab/related-links/RelatedLinks.jsx b/src/course-home/progress-tab/related-links/RelatedLinks.jsx index ac514d0d6b..2392e9e138 100644 --- a/src/course-home/progress-tab/related-links/RelatedLinks.jsx +++ b/src/course-home/progress-tab/related-links/RelatedLinks.jsx @@ -15,6 +15,7 @@ function RelatedLinks({ intl }) { } = useSelector(state => state.courseHome); const { org, + tabs, } = useModel('courseHomeMeta', courseId); const { administrator } = getAuthenticatedUser(); @@ -27,22 +28,31 @@ function RelatedLinks({ intl }) { }); }; + const overviewTab = tabs.find(tab => tab.slug === 'outline'); + const overviewTabUrl = overviewTab && overviewTab.url; + const datesTab = tabs.find(tab => tab.slug === 'dates'); + const datesTabUrl = datesTab && datesTab.url; + return (

{intl.formatMessage(messages.relatedLinks)}

    + {datesTabUrl && (
  • - logLinkClicked('dates')}> + logLinkClicked('dates')}> {intl.formatMessage(messages.datesCardLink)}

    {intl.formatMessage(messages.datesCardDescription)}

  • + )} + {overviewTabUrl && (
  • - logLinkClicked('course_outline')}> + logLinkClicked('course_outline')}> {intl.formatMessage(messages.outlineCardLink)}

    {intl.formatMessage(messages.outlineCardDescription)}

  • + )}
);