From 65ab77bed34a5133a1613a07a52777d3f80f8407 Mon Sep 17 00:00:00 2001 From: stvn Date: Fri, 15 May 2020 11:58:37 -0700 Subject: [PATCH 1/8] Cleanup PORT config --- .env.development | 2 +- .env.test | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.env.development b/.env.development index d5dca1ed..1e130d67 100644 --- a/.env.development +++ b/.env.development @@ -1,5 +1,4 @@ NODE_ENV='development' -PORT=2000 ACCESS_TOKEN_COOKIE_NAME='edx-jwt-cookie-header-payload' BASE_URL='localhost:2000' CREDENTIALS_BASE_URL='http://localhost:18150' @@ -11,6 +10,7 @@ LOGIN_URL='http://localhost:18000/login' LOGOUT_URL='http://localhost:18000/logout' MARKETING_SITE_BASE_URL='http://localhost:18000' ORDER_HISTORY_URL='localhost:1996/orders' +PORT=2000 REFRESH_ACCESS_TOKEN_ENDPOINT='http://localhost:18000/login_refresh' SEGMENT_KEY=null SITE_NAME='edX' diff --git a/.env.test b/.env.test index 4b8d98e0..9f2a03b7 100644 --- a/.env.test +++ b/.env.test @@ -9,6 +9,7 @@ LOGIN_URL='http://localhost:18000/login' LOGOUT_URL='http://localhost:18000/logout' MARKETING_SITE_BASE_URL='http://localhost:18000' ORDER_HISTORY_URL='localhost:1996/orders' +PORT=2000 REFRESH_ACCESS_TOKEN_ENDPOINT='http://localhost:18000/login_refresh' SEGMENT_KEY=null SITE_NAME='edX' From 93ccdf829b6be7c7c8316c912403d5b14db2bc92 Mon Sep 17 00:00:00 2001 From: stvn Date: Fri, 15 May 2020 11:59:07 -0700 Subject: [PATCH 2/8] Fix mismatched test BASE_URL --- .env.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.test b/.env.test index 9f2a03b7..effe1303 100644 --- a/.env.test +++ b/.env.test @@ -1,5 +1,5 @@ ACCESS_TOKEN_COOKIE_NAME='edx-jwt-cookie-header-payload' -BASE_URL='localhost:1995' +BASE_URL='localhost:2000' CREDENTIALS_BASE_URL='http://localhost:18150' CSRF_TOKEN_API_PATH='/csrf/api/v1/token' ECOMMERCE_BASE_URL='http://localhost:18130' From b2fa93af139136ed6a4abe481ff4932873eb17d4 Mon Sep 17 00:00:00 2001 From: stvn Date: Fri, 15 May 2020 11:59:22 -0700 Subject: [PATCH 3/8] Set NODE_ENV in the test environment --- .env.test | 1 + 1 file changed, 1 insertion(+) diff --git a/.env.test b/.env.test index effe1303..f6b129af 100644 --- a/.env.test +++ b/.env.test @@ -1,3 +1,4 @@ +NODE_ENV='test' ACCESS_TOKEN_COOKIE_NAME='edx-jwt-cookie-header-payload' BASE_URL='localhost:2000' CREDENTIALS_BASE_URL='http://localhost:18150' From fd951fb18a77b9b49d2c951f1a172fe4a5e92e96 Mon Sep 17 00:00:00 2001 From: stvn Date: Fri, 15 May 2020 12:05:08 -0700 Subject: [PATCH 4/8] Fix missing definition of unitId in InstructorToolbar.props --- src/courseware/course/InstructorToolbar.jsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/courseware/course/InstructorToolbar.jsx b/src/courseware/course/InstructorToolbar.jsx index ac10c698..c73462fb 100644 --- a/src/courseware/course/InstructorToolbar.jsx +++ b/src/courseware/course/InstructorToolbar.jsx @@ -39,10 +39,12 @@ function InstructorToolbar(props) { InstructorToolbar.propTypes = { activeUnitLmsWebUrl: PropTypes.string, + unitId: PropTypes.string, }; InstructorToolbar.defaultProps = { activeUnitLmsWebUrl: undefined, + unitId: undefined, }; const mapStateToProps = (state, props) => { From 5cb11189a755dc6812f6ec444a5b6845752f467a Mon Sep 17 00:00:00 2001 From: stvn Date: Fri, 15 May 2020 11:58:02 -0700 Subject: [PATCH 5/8] Create new config values for Insights/Studio URLs --- .env | 2 ++ .env.development | 1 + .env.test | 1 + src/index.jsx | 9 +++++++++ 4 files changed, 13 insertions(+) diff --git a/.env b/.env index 59fbc88a..3c0d416b 100644 --- a/.env +++ b/.env @@ -4,6 +4,7 @@ BASE_URL=null CREDENTIALS_BASE_URL=null CSRF_TOKEN_API_PATH=null ECOMMERCE_BASE_URL=null +INSIGHTS_BASE_URL= LANGUAGE_PREFERENCE_COOKIE_NAME=null LMS_BASE_URL=null LOGIN_URL=null @@ -13,4 +14,5 @@ ORDER_HISTORY_URL=null REFRESH_ACCESS_TOKEN_ENDPOINT=null SEGMENT_KEY=null SITE_NAME=null +STUDIO_BASE_URL= USER_INFO_COOKIE_NAME=null diff --git a/.env.development b/.env.development index 1e130d67..2bc0c1c1 100644 --- a/.env.development +++ b/.env.development @@ -14,4 +14,5 @@ PORT=2000 REFRESH_ACCESS_TOKEN_ENDPOINT='http://localhost:18000/login_refresh' SEGMENT_KEY=null SITE_NAME='edX' +STUDIO_BASE_URL='http://localhost:18010' USER_INFO_COOKIE_NAME='edx-user-info' diff --git a/.env.test b/.env.test index f6b129af..3fae7f5b 100644 --- a/.env.test +++ b/.env.test @@ -14,4 +14,5 @@ PORT=2000 REFRESH_ACCESS_TOKEN_ENDPOINT='http://localhost:18000/login_refresh' SEGMENT_KEY=null SITE_NAME='edX' +STUDIO_BASE_URL='http://localhost:18010' USER_INFO_COOKIE_NAME='edx-user-info' diff --git a/src/index.jsx b/src/index.jsx index 21f3461d..d8491164 100755 --- a/src/index.jsx +++ b/src/index.jsx @@ -3,6 +3,7 @@ import 'regenerator-runtime/runtime'; import { APP_INIT_ERROR, APP_READY, subscribe, initialize, + mergeConfig, } from '@edx/frontend-platform'; import { AppProvider, ErrorPage } from '@edx/frontend-platform/react'; import React from 'react'; @@ -51,6 +52,14 @@ subscribe(APP_INIT_ERROR, (error) => { }); initialize({ + handlers: { + config: () => { + mergeConfig({ + INSIGHTS_BASE_URL: process.env.INSIGHTS_BASE_URL || null, + STUDIO_BASE_URL: process.env.STUDIO_BASE_URL || null, + }, 'LearnerAppConfig'); + }, + }, // TODO: Remove this once the course blocks api supports unauthenticated // access and we are prepared to support public courses in this app. requireAuthenticatedUser: true, From 7bef14c32996fa38d848b3087664dced548d7f34 Mon Sep 17 00:00:00 2001 From: stvn Date: Fri, 15 May 2020 12:05:42 -0700 Subject: [PATCH 6/8] Add courseId to InstructorToolbar props --- src/courseware/course/Course.jsx | 1 + src/courseware/course/InstructorToolbar.jsx | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/courseware/course/Course.jsx b/src/courseware/course/Course.jsx index d294a046..a02bba89 100644 --- a/src/courseware/course/Course.jsx +++ b/src/courseware/course/Course.jsx @@ -72,6 +72,7 @@ function Course({ /> {isStaff && ( )} diff --git a/src/courseware/course/InstructorToolbar.jsx b/src/courseware/course/InstructorToolbar.jsx index c73462fb..5b160714 100644 --- a/src/courseware/course/InstructorToolbar.jsx +++ b/src/courseware/course/InstructorToolbar.jsx @@ -39,11 +39,13 @@ function InstructorToolbar(props) { InstructorToolbar.propTypes = { activeUnitLmsWebUrl: PropTypes.string, + courseId: PropTypes.string, unitId: PropTypes.string, }; InstructorToolbar.defaultProps = { activeUnitLmsWebUrl: undefined, + courseId: undefined, unitId: undefined, }; From ab544b5d2b17f4fa55007e914cbd54210c8e17af Mon Sep 17 00:00:00 2001 From: stvn Date: Fri, 15 May 2020 12:02:06 -0700 Subject: [PATCH 7/8] Add new Studio/insights links to InstructorToolbar --- src/courseware/course/InstructorToolbar.jsx | 61 ++++++++++++++++++--- 1 file changed, 54 insertions(+), 7 deletions(-) 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 (
@@ -29,9 +62,23 @@ function InstructorToolbar(props) {
- + {urlLms && ( + + )} +   + {urlStudio && ( + + )} +   + {urlInsights && ( + + )}
); From e2f37ff20e5f65875989fea32987f7d2240c2cac Mon Sep 17 00:00:00 2001 From: stvn Date: Fri, 15 May 2020 12:03:34 -0700 Subject: [PATCH 8/8] Remove explanatory paragraph --- src/courseware/course/InstructorToolbar.jsx | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/courseware/course/InstructorToolbar.jsx b/src/courseware/course/InstructorToolbar.jsx index 9f440d14..0fbe5362 100644 --- a/src/courseware/course/InstructorToolbar.jsx +++ b/src/courseware/course/InstructorToolbar.jsx @@ -1,7 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; -import { Collapsible } from '@edx/paragon'; import { getConfig } from '@edx/frontend-platform'; @@ -45,22 +44,7 @@ function InstructorToolbar(props) {
- - You are currently previewing the new learning sequence experience. - - - More info → - - - - This preview is to allow for early content testing, especially for custom content blocks, with the goal of ensuring it renders as expected in the next experience. You can learn more through the following Partner Portal post. Please report any issues or provide feedback using the linked form. - - - Close × - - - - +  
{urlLms && (