diff --git a/src/courseware/course/InstructorToolbar.jsx b/src/courseware/course/InstructorToolbar.jsx index 5b160714..9f440d14 100644 --- a/src/courseware/course/InstructorToolbar.jsx +++ b/src/courseware/course/InstructorToolbar.jsx @@ -3,11 +3,44 @@ import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import { Collapsible } from '@edx/paragon'; -function InstructorToolbar(props) { - if (!props.activeUnitLmsWebUrl) { - return null; - } +import { getConfig } from '@edx/frontend-platform'; +function getInsightsUrl(courseId) { + const urlBase = getConfig().INSIGHTS_BASE_URL; + let urlFull; + if (urlBase) { + urlFull = `${urlBase}/courses`; + // This shouldn't actually be missing, at present, + // but we're providing a reasonable fallback, + // in case of either error or extension. + if (courseId) { + urlFull += `/${courseId}`; + } + } + return urlFull; +} + +function getStudioUrl(courseId, unitId) { + const urlBase = getConfig().STUDIO_BASE_URL; + let urlFull; + if (urlBase) { + if (unitId) { + urlFull = `${urlBase}/container/${unitId}`; + } else if (courseId) { + urlFull = `{$urlBase}/course/${courseId}`; + } + } + return urlFull; +} + +function InstructorToolbar(props) { + const { + courseId, + unitId, + } = props; + const urlInsights = getInsightsUrl(courseId); + const urlLms = props.activeUnitLmsWebUrl; + const urlStudio = getStudioUrl(courseId, unitId); return (