@edx/frontend-plugin-learner-dashboard 3.1.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/.github/workflows/ci.yml +2 -2
  2. package/.github/workflows/release.yml +2 -2
  3. package/.nvmrc +1 -1
  4. package/dist/dynamic-experience-slot/DynamicExperienceSlot.js +81 -0
  5. package/dist/dynamic-experience-slot/DynamicExperienceSlot.js.map +1 -0
  6. package/dist/dynamic-experience-slot/index.js +10 -0
  7. package/dist/dynamic-experience-slot/index.js.map +1 -0
  8. package/dist/index.js +27 -6
  9. package/dist/index.js.map +1 -1
  10. package/dist/no-courses-view/index.js +64 -0
  11. package/dist/no-courses-view/index.js.map +1 -0
  12. package/dist/no-courses-view/index.scss +13 -0
  13. package/dist/no-courses-view/messages.js +31 -0
  14. package/dist/no-courses-view/messages.js.map +1 -0
  15. package/dist/package.json +5 -2
  16. package/dist/tracking/trackers/exploreCourses.js +56 -0
  17. package/dist/tracking/trackers/exploreCourses.js.map +1 -0
  18. package/dist/ucl-wrapper/UclWrapper.js +42 -0
  19. package/dist/ucl-wrapper/UclWrapper.js.map +1 -0
  20. package/dist/ucl-wrapper/index.js +10 -0
  21. package/dist/ucl-wrapper/index.js.map +1 -0
  22. package/package.json +6 -3
  23. package/src/dashboard-modal/EnterpriseDashboardModalWrapper.test.jsx +2 -1
  24. package/src/dynamic-experience-slot/DynamicExperienceSlot.jsx +54 -0
  25. package/src/dynamic-experience-slot/DynamicExperienceSlot.test.jsx +108 -0
  26. package/src/dynamic-experience-slot/index.jsx +3 -0
  27. package/src/index.jsx +7 -1
  28. package/src/no-courses-view/index.jsx +60 -0
  29. package/src/no-courses-view/index.scss +13 -0
  30. package/src/no-courses-view/index.test.jsx +63 -0
  31. package/src/no-courses-view/messages.js +26 -0
  32. package/src/tracking/trackers/exploreCourses.js +49 -0
  33. package/src/ucl-wrapper/UclWrapper.jsx +43 -0
  34. package/src/ucl-wrapper/UclWrapper.test.jsx +17 -0
  35. package/src/ucl-wrapper/index.jsx +3 -0
@@ -12,11 +12,11 @@ jobs:
12
12
 
13
13
  steps:
14
14
  - name: Checkout
15
- uses: actions/checkout@v4
15
+ uses: actions/checkout@v6
16
16
  with:
17
17
  fetch-depth: 0
18
18
  - name: Setup Nodejs
19
- uses: actions/setup-node@v4
19
+ uses: actions/setup-node@v6
20
20
  with:
21
21
  node-version-file: '.nvmrc'
22
22
  - name: Install dependencies
@@ -9,10 +9,10 @@ jobs:
9
9
  runs-on: ubuntu-latest
10
10
  steps:
11
11
  - name: Checkout
12
- uses: actions/checkout@v4
12
+ uses: actions/checkout@v6
13
13
 
14
14
  - name: Setup Node.js
15
- uses: actions/setup-node@v4
15
+ uses: actions/setup-node@v6
16
16
  with:
17
17
  node-version-file: '.nvmrc'
18
18
 
package/.nvmrc CHANGED
@@ -1 +1 @@
1
- 20
1
+ 24
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = require("react");
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _jsxRuntime = require("react/jsx-runtime");
10
+ const _excluded = ["widgetName"];
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
15
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
16
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
17
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
18
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
19
+ function useUCL(timeout = 5000) {
20
+ const [ucl, setUcl] = (0, _react.useState)(() => window.UCL);
21
+ (0, _react.useEffect)(() => {
22
+ if (ucl) {
23
+ return undefined;
24
+ }
25
+ const start = Date.now();
26
+ const id = setInterval(() => {
27
+ if (window.UCL) {
28
+ setUcl(window.UCL);
29
+ clearInterval(id);
30
+ } else if (Date.now() - start > timeout) {
31
+ clearInterval(id);
32
+ }
33
+ }, 100);
34
+ return () => clearInterval(id);
35
+ }, [ucl, timeout]);
36
+ return ucl;
37
+ }
38
+ class RenderFallbackSignal extends Error {
39
+ constructor() {
40
+ super('Render fallback requested by widget');
41
+ this.name = 'RenderFallbackSignal';
42
+ }
43
+ }
44
+ const DynamicExperienceSlot = _ref => {
45
+ let {
46
+ widgetName
47
+ } = _ref,
48
+ rest = _objectWithoutProperties(_ref, _excluded);
49
+ const ref = (0, _react.useRef)(null);
50
+ const UCL = useUCL();
51
+ const [shouldThrow, setShouldThrow] = (0, _react.useState)(false);
52
+ const [error, setError] = (0, _react.useState)(null);
53
+ (0, _react.useEffect)(() => {
54
+ const refCurrent = ref.current;
55
+ if (!refCurrent || !UCL) {
56
+ return undefined;
57
+ }
58
+ try {
59
+ UCL.mount(widgetName, refCurrent, _objectSpread(_objectSpread({}, rest), {}, {
60
+ onFallbackShouldRender: setShouldThrow
61
+ }));
62
+ } catch (e) {
63
+ setError(e);
64
+ }
65
+ return () => UCL.unmount(refCurrent);
66
+ }, [widgetName, UCL, rest]);
67
+ if (error) {
68
+ throw error;
69
+ }
70
+ if (shouldThrow) {
71
+ throw new RenderFallbackSignal();
72
+ }
73
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
74
+ ref: ref
75
+ });
76
+ };
77
+ DynamicExperienceSlot.propTypes = {
78
+ widgetName: _propTypes.default.string.isRequired
79
+ };
80
+ var _default = exports.default = DynamicExperienceSlot;
81
+ //# sourceMappingURL=DynamicExperienceSlot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DynamicExperienceSlot.js","names":["_react","require","_propTypes","_interopRequireDefault","_jsxRuntime","_excluded","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","_objectWithoutProperties","_objectWithoutPropertiesLoose","n","indexOf","propertyIsEnumerable","hasOwnProperty","useUCL","timeout","ucl","setUcl","useState","window","UCL","useEffect","undefined","start","Date","now","id","setInterval","clearInterval","RenderFallbackSignal","Error","constructor","name","DynamicExperienceSlot","_ref","widgetName","rest","ref","useRef","shouldThrow","setShouldThrow","error","setError","refCurrent","current","mount","onFallbackShouldRender","unmount","jsx","propTypes","PropTypes","string","isRequired","_default","exports"],"sources":["../../src/dynamic-experience-slot/DynamicExperienceSlot.jsx"],"sourcesContent":["import { useState, useEffect, useRef } from 'react';\nimport PropTypes from 'prop-types';\n\nfunction useUCL(timeout = 5000) {\n const [ucl, setUcl] = useState(() => window.UCL);\n useEffect(() => {\n if (ucl) { return undefined; }\n const start = Date.now();\n const id = setInterval(() => {\n if (window.UCL) {\n setUcl(window.UCL);\n clearInterval(id);\n } else if (Date.now() - start > timeout) {\n clearInterval(id);\n }\n }, 100);\n return () => clearInterval(id);\n }, [ucl, timeout]);\n return ucl;\n}\nclass RenderFallbackSignal extends Error {\n constructor() {\n super('Render fallback requested by widget');\n this.name = 'RenderFallbackSignal';\n }\n}\nconst DynamicExperienceSlot = ({ widgetName, ...rest }) => {\n const ref = useRef(null);\n const UCL = useUCL();\n const [shouldThrow, setShouldThrow] = useState(false);\n const [error, setError] = useState(null);\n useEffect(() => {\n const refCurrent = ref.current;\n if (!refCurrent || !UCL) { return undefined; }\n try {\n UCL.mount(widgetName, refCurrent, {\n ...rest,\n onFallbackShouldRender: setShouldThrow,\n });\n } catch (e) {\n setError(e);\n }\n return () => UCL.unmount(refCurrent);\n }, [widgetName, UCL, rest]);\n if (error) { throw error; }\n if (shouldThrow) { throw new RenderFallbackSignal(); }\n return <div ref={ref} />;\n};\n\nDynamicExperienceSlot.propTypes = {\n widgetName: PropTypes.string.isRequired,\n};\n\nexport default DynamicExperienceSlot;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAmC,IAAAG,WAAA,GAAAH,OAAA;AAAA,MAAAI,SAAA;AAAA,SAAAF,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,QAAAH,CAAA,EAAAI,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAP,CAAA,OAA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;EACxC,IAAAG,gBAAS,EAAC,MAAM;IACd,MAAMsB,UAAU,GAAGN,GAAG,CAACO,OAAO;IAC9B,IAAI,CAACD,UAAU,IAAI,CAACvB,GAAG,EAAE;MAAE,OAAOE,SAAS;IAAE;IAC7C,IAAI;MACFF,GAAG,CAACyB,KAAK,CAACV,UAAU,EAAEQ,UAAU,EAAAvD,aAAA,CAAAA,aAAA,KAC3BgD,IAAI;QACPU,sBAAsB,EAAEN;MAAc,EACvC,CAAC;IACJ,CAAC,CAAC,OAAOnE,CAAC,EAAE;MACVqE,QAAQ,CAACrE,CAAC,CAAC;IACb;IACA,OAAO,MAAM+C,GAAG,CAAC2B,OAAO,CAACJ,UAAU,CAAC;EACtC,CAAC,EAAE,CAACR,UAAU,EAAEf,GAAG,EAAEgB,IAAI,CAAC,CAAC;EAC3B,IAAIK,KAAK,EAAE;IAAE,MAAMA,KAAK;EAAE;EAC1B,IAAIF,WAAW,EAAE;IAAE,MAAM,IAAIV,oBAAoB,CAAC,CAAC;EAAE;EACrD,oBAAO,IAAA1D,WAAA,CAAA6E,GAAA;IAAKX,GAAG,EAAEA;EAAI,CAAE,CAAC;AAC1B,CAAC;AAEDJ,qBAAqB,CAACgB,SAAS,GAAG;EAChCd,UAAU,EAAEe,kBAAS,CAACC,MAAM,CAACC;AAC/B,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA/E,OAAA,GAEa0D,qBAAqB","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _DynamicExperienceSlot = _interopRequireDefault(require("./DynamicExperienceSlot"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ var _default = exports.default = _DynamicExperienceSlot.default;
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_DynamicExperienceSlot","_interopRequireDefault","require","e","__esModule","default","_default","exports","DynamicExperienceSlot"],"sources":["../../src/dynamic-experience-slot/index.jsx"],"sourcesContent":["import DynamicExperienceSlot from './DynamicExperienceSlot';\n\nexport default DynamicExperienceSlot;\n"],"mappings":";;;;;;AAAA,IAAAA,sBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA4D,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAE7CG,8BAAqB","ignoreList":[]}
package/dist/index.js CHANGED
@@ -15,6 +15,12 @@ Object.defineProperty(exports, "CourseBanner", {
15
15
  return _courseBanner.default;
16
16
  }
17
17
  });
18
+ Object.defineProperty(exports, "DynamicExperienceSlot", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _dynamicExperienceSlot.default;
22
+ }
23
+ });
18
24
  Object.defineProperty(exports, "EnterpriseDashboardModal", {
19
25
  enumerable: true,
20
26
  get: function () {
@@ -27,10 +33,22 @@ Object.defineProperty(exports, "HelpChatbot", {
27
33
  return _index3.default;
28
34
  }
29
35
  });
36
+ Object.defineProperty(exports, "NoCoursesView", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _noCoursesView.default;
40
+ }
41
+ });
30
42
  Object.defineProperty(exports, "NoticesRedirect", {
31
43
  enumerable: true,
32
44
  get: function () {
33
- return _index6.default;
45
+ return _index4.default;
46
+ }
47
+ });
48
+ Object.defineProperty(exports, "UclWrapper", {
49
+ enumerable: true,
50
+ get: function () {
51
+ return _uclWrapper.default;
34
52
  }
35
53
  });
36
54
  Object.defineProperty(exports, "UpgradeButton", {
@@ -42,22 +60,25 @@ Object.defineProperty(exports, "UpgradeButton", {
42
60
  Object.defineProperty(exports, "UserCareerMenu", {
43
61
  enumerable: true,
44
62
  get: function () {
45
- return _index4.default;
63
+ return _index5.default;
46
64
  }
47
65
  });
48
66
  Object.defineProperty(exports, "UserDashboardMenu", {
49
67
  enumerable: true,
50
68
  get: function () {
51
- return _index5.default;
69
+ return _index6.default;
52
70
  }
53
71
  });
54
72
  var _index = _interopRequireDefault(require("./cohesion-wrapper/index"));
55
73
  var _courseBanner = _interopRequireDefault(require("./course-banner"));
74
+ var _dynamicExperienceSlot = _interopRequireDefault(require("./dynamic-experience-slot"));
56
75
  var _index2 = _interopRequireDefault(require("./dashboard-modal/index"));
57
76
  var _index3 = _interopRequireDefault(require("./chatbot/index"));
77
+ var _uclWrapper = _interopRequireDefault(require("./ucl-wrapper"));
78
+ var _noCoursesView = _interopRequireDefault(require("./no-courses-view"));
79
+ var _index4 = _interopRequireDefault(require("./notices-redirect/index"));
58
80
  var _upgradeButton = _interopRequireDefault(require("./upgrade-button"));
59
- var _index4 = _interopRequireDefault(require("./career-menu/index"));
60
- var _index5 = _interopRequireDefault(require("./dashboard-menu/index"));
61
- var _index6 = _interopRequireDefault(require("./notices-redirect/index"));
81
+ var _index5 = _interopRequireDefault(require("./career-menu/index"));
82
+ var _index6 = _interopRequireDefault(require("./dashboard-menu/index"));
62
83
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
63
84
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_index","_interopRequireDefault","require","_courseBanner","_index2","_index3","_upgradeButton","_index4","_index5","_index6","e","__esModule","default"],"sources":["../src/index.jsx"],"sourcesContent":["import CohesionWrapper from './cohesion-wrapper/index';\nimport CourseBanner from './course-banner';\nimport EnterpriseDashboardModal from './dashboard-modal/index';\nimport HelpChatbot from './chatbot/index';\nimport UpgradeButton from './upgrade-button';\nimport UserCareerMenu from './career-menu/index';\nimport UserDashboardMenu from './dashboard-menu/index';\nimport NoticesRedirect from './notices-redirect/index';\n\nexport {\n CohesionWrapper,\n CourseBanner,\n EnterpriseDashboardModal,\n HelpChatbot,\n NoticesRedirect,\n UpgradeButton,\n UserCareerMenu,\n UserDashboardMenu,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,OAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,cAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,OAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,OAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,OAAA,GAAAR,sBAAA,CAAAC,OAAA;AAAuD,SAAAD,uBAAAS,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_index","_interopRequireDefault","require","_courseBanner","_dynamicExperienceSlot","_index2","_index3","_uclWrapper","_noCoursesView","_index4","_upgradeButton","_index5","_index6","e","__esModule","default"],"sources":["../src/index.jsx"],"sourcesContent":["import CohesionWrapper from './cohesion-wrapper/index';\nimport CourseBanner from './course-banner';\nimport DynamicExperienceSlot from './dynamic-experience-slot';\nimport EnterpriseDashboardModal from './dashboard-modal/index';\nimport HelpChatbot from './chatbot/index';\nimport UclWrapper from './ucl-wrapper';\nimport NoCoursesView from './no-courses-view';\nimport NoticesRedirect from './notices-redirect/index';\nimport UpgradeButton from './upgrade-button';\nimport UserCareerMenu from './career-menu/index';\nimport UserDashboardMenu from './dashboard-menu/index';\n\nexport {\n CohesionWrapper,\n CourseBanner,\n DynamicExperienceSlot,\n EnterpriseDashboardModal,\n HelpChatbot,\n NoCoursesView,\n NoticesRedirect,\n UclWrapper,\n UpgradeButton,\n UserCareerMenu,\n UserDashboardMenu,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,sBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,OAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,OAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,WAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,cAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,OAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,cAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,OAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,OAAA,GAAAX,sBAAA,CAAAC,OAAA;AAAuD,SAAAD,uBAAAY,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA","ignoreList":[]}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactRouter = require("react-router");
9
+ var _i18n = require("@edx/frontend-platform/i18n");
10
+ var _paragon = require("@openedx/paragon");
11
+ var _icons = require("@openedx/paragon/icons");
12
+ var _urls = require("data/services/lms/urls");
13
+ var _emptyCourse = _interopRequireDefault(require("assets/empty-course.svg"));
14
+ var _hooks = require("hooks");
15
+ var _exploreCourses = require("../tracking/trackers/exploreCourses");
16
+ var _messages = _interopRequireDefault(require("./messages"));
17
+ require("./index.scss");
18
+ var _jsxRuntime = require("react/jsx-runtime");
19
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
20
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
21
+ /* eslint-disable import/no-unresolved */
22
+
23
+ const NoCoursesView = () => {
24
+ const {
25
+ formatMessage
26
+ } = (0, _i18n.useIntl)();
27
+ const {
28
+ courseSearchUrl
29
+ } = _hooks.reduxHooks.usePlatformSettingsData();
30
+ const location = (0, _reactRouter.useLocation)();
31
+ const fullUrl = (0, _urls.baseAppUrl)(location.pathname);
32
+ const pageTitle = document.title;
33
+ const handleExploreCoursesViewed = (0, _react.useCallback)(() => {
34
+ (0, _exploreCourses.exploreCoursesViewedCohesion)(pageTitle, fullUrl);
35
+ }, [pageTitle, fullUrl]);
36
+ const handleExploreCoursesClick = () => {
37
+ (0, _exploreCourses.exploreCoursesClickedCohesion)(pageTitle, fullUrl);
38
+ };
39
+ (0, _react.useEffect)(() => {
40
+ handleExploreCoursesViewed();
41
+ }, [handleExploreCoursesViewed]);
42
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
43
+ id: "no-courses-content-view",
44
+ className: "d-flex align-items-center justify-content-center mb-4.5",
45
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_paragon.Image, {
46
+ src: _emptyCourse.default,
47
+ alt: formatMessage(_messages.default.bannerAlt)
48
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("h3", {
49
+ className: "h1",
50
+ children: formatMessage(_messages.default.lookingForChallengePrompt)
51
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
52
+ children: formatMessage(_messages.default.exploreCoursesPrompt)
53
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_paragon.Button, {
54
+ variant: "brand",
55
+ as: "a",
56
+ onClick: handleExploreCoursesClick,
57
+ href: (0, _urls.baseAppUrl)(courseSearchUrl),
58
+ iconBefore: _icons.Search,
59
+ children: formatMessage(_messages.default.exploreCoursesButton)
60
+ })]
61
+ });
62
+ };
63
+ var _default = exports.default = NoCoursesView;
64
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_react","_interopRequireWildcard","require","_reactRouter","_i18n","_paragon","_icons","_urls","_emptyCourse","_interopRequireDefault","_hooks","_exploreCourses","_messages","_jsxRuntime","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","NoCoursesView","formatMessage","useIntl","courseSearchUrl","reduxHooks","usePlatformSettingsData","location","useLocation","fullUrl","baseAppUrl","pathname","pageTitle","document","title","handleExploreCoursesViewed","useCallback","exploreCoursesViewedCohesion","handleExploreCoursesClick","exploreCoursesClickedCohesion","useEffect","jsxs","id","className","children","jsx","Image","src","emptyCourseSVG","alt","messages","bannerAlt","lookingForChallengePrompt","exploreCoursesPrompt","Button","variant","as","onClick","href","iconBefore","Search","exploreCoursesButton","_default","exports"],"sources":["../../src/no-courses-view/index.jsx"],"sourcesContent":["/* eslint-disable import/no-unresolved */\nimport React, { useCallback, useEffect } from 'react';\nimport { useLocation } from 'react-router';\nimport { useIntl } from '@edx/frontend-platform/i18n';\nimport { Button, Image } from '@openedx/paragon';\nimport { Search } from '@openedx/paragon/icons';\nimport { baseAppUrl } from 'data/services/lms/urls';\n\nimport emptyCourseSVG from 'assets/empty-course.svg';\nimport { reduxHooks } from 'hooks';\nimport { exploreCoursesViewedCohesion, exploreCoursesClickedCohesion } from '../tracking/trackers/exploreCourses';\n\nimport messages from './messages';\nimport './index.scss';\n\nconst NoCoursesView = () => {\n const { formatMessage } = useIntl();\n const { courseSearchUrl } = reduxHooks.usePlatformSettingsData();\n const location = useLocation();\n const fullUrl = baseAppUrl(location.pathname);\n const pageTitle = document.title;\n\n const handleExploreCoursesViewed = useCallback(() => {\n exploreCoursesViewedCohesion(pageTitle, fullUrl);\n }, [pageTitle, fullUrl]);\n\n const handleExploreCoursesClick = () => {\n exploreCoursesClickedCohesion(pageTitle, fullUrl);\n };\n\n useEffect(() => {\n handleExploreCoursesViewed();\n }, [handleExploreCoursesViewed]);\n\n return (\n <div\n id=\"no-courses-content-view\"\n className=\"d-flex align-items-center justify-content-center mb-4.5\"\n >\n <Image src={emptyCourseSVG} alt={formatMessage(messages.bannerAlt)} />\n <h3 className=\"h1\">\n {formatMessage(messages.lookingForChallengePrompt)}\n </h3>\n <p>\n {formatMessage(messages.exploreCoursesPrompt)}\n </p>\n <Button\n variant=\"brand\"\n as=\"a\"\n onClick={handleExploreCoursesClick}\n href={baseAppUrl(courseSearchUrl)}\n iconBefore={Search}\n >\n {formatMessage(messages.exploreCoursesButton)}\n </Button>\n </div>\n );\n};\n\nexport default NoCoursesView;\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAEA,IAAAM,YAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,eAAA,GAAAT,OAAA;AAEA,IAAAU,SAAA,GAAAH,sBAAA,CAAAP,OAAA;AACAA,OAAA;AAAsB,IAAAW,WAAA,GAAAX,OAAA;AAAA,SAAAO,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAb,wBAAAa,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAA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AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA3D,OAAA,GAEaiB,aAAa","ignoreList":[]}
@@ -0,0 +1,13 @@
1
+ #no-courses-content-view {
2
+ border: 2px solid var(--pgn-color-light-400);
3
+ flex-direction: column;
4
+ padding-bottom: var(--pgn-spacing-spacer-5);
5
+ padding-top: var(--pgn-spacing-spacer-5);
6
+ height: 100%;
7
+
8
+ & > * {
9
+ margin-top: var(--pgn-spacing-spacer-3);
10
+ margin-bottom: var(--pgn-spacing-spacer-3);
11
+ }
12
+ }
13
+
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _i18n = require("@edx/frontend-platform/i18n");
8
+ const messages = (0, _i18n.defineMessages)({
9
+ lookingForChallengePrompt: {
10
+ id: 'Dashboard.NoCoursesView.lookingForChallengePrompt',
11
+ defaultMessage: 'Looking for a new challenge?',
12
+ description: 'Prompt user for new challenge'
13
+ },
14
+ exploreCoursesPrompt: {
15
+ id: 'Dashboard.NoCoursesView.exploreCoursesPrompt',
16
+ defaultMessage: 'Explore our courses to add them to your dashboard.',
17
+ description: 'Prompt user to explore more courses'
18
+ },
19
+ exploreCoursesButton: {
20
+ id: 'Dashboard.NoCoursesView.exploreCoursesButton',
21
+ defaultMessage: 'Explore courses',
22
+ description: 'Button to explore more courses'
23
+ },
24
+ bannerAlt: {
25
+ id: 'Dashboard.NoCoursesView.bannerAlt',
26
+ defaultMessage: 'No Courses view banner',
27
+ description: 'No Courses view basnner'
28
+ }
29
+ });
30
+ var _default = exports.default = messages;
31
+ //# sourceMappingURL=messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.js","names":["_i18n","require","messages","defineMessages","lookingForChallengePrompt","id","defaultMessage","description","exploreCoursesPrompt","exploreCoursesButton","bannerAlt","_default","exports","default"],"sources":["../../src/no-courses-view/messages.js"],"sourcesContent":["import { defineMessages } from '@edx/frontend-platform/i18n';\n\nconst messages = defineMessages({\n lookingForChallengePrompt: {\n id: 'Dashboard.NoCoursesView.lookingForChallengePrompt',\n defaultMessage: 'Looking for a new challenge?',\n description: 'Prompt user for new challenge',\n },\n exploreCoursesPrompt: {\n id: 'Dashboard.NoCoursesView.exploreCoursesPrompt',\n defaultMessage: 'Explore our courses to add them to your dashboard.',\n description: 'Prompt user to explore more courses',\n },\n exploreCoursesButton: {\n id: 'Dashboard.NoCoursesView.exploreCoursesButton',\n defaultMessage: 'Explore courses',\n description: 'Button to explore more courses',\n },\n bannerAlt: {\n id: 'Dashboard.NoCoursesView.bannerAlt',\n defaultMessage: 'No Courses view banner',\n description: 'No Courses view basnner',\n },\n});\n\nexport default messages;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAEA,MAAMC,QAAQ,GAAG,IAAAC,oBAAc,EAAC;EAC9BC,yBAAyB,EAAE;IACzBC,EAAE,EAAE,mDAAmD;IACvDC,cAAc,EAAE,8BAA8B;IAC9CC,WAAW,EAAE;EACf,CAAC;EACDC,oBAAoB,EAAE;IACpBH,EAAE,EAAE,8CAA8C;IAClDC,cAAc,EAAE,oDAAoD;IACpEC,WAAW,EAAE;EACf,CAAC;EACDE,oBAAoB,EAAE;IACpBJ,EAAE,EAAE,8CAA8C;IAClDC,cAAc,EAAE,iBAAiB;IACjCC,WAAW,EAAE;EACf,CAAC;EACDG,SAAS,EAAE;IACTL,EAAE,EAAE,mCAAmC;IACvCC,cAAc,EAAE,wBAAwB;IACxCC,WAAW,EAAE;EACf;AACF,CAAC,CAAC;AAAC,IAAAI,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEYX,QAAQ","ignoreList":[]}
package/dist/package.json CHANGED
@@ -48,8 +48,10 @@
48
48
  "@testing-library/jest-dom": "^6.6.3",
49
49
  "@testing-library/react": "^16.2.0",
50
50
  "jest": "30.2.0",
51
+ "react-error-boundary": "^6.1.0",
51
52
  "rosie": "2.1.1",
52
- "semantic-release": "^24.0.0"
53
+ "semantic-release": "^25.0.0",
54
+ "ts-jest": "^29.1.4"
53
55
  },
54
56
  "peerDependencies": {
55
57
  "@edx/frontend-platform": "^8.3.1",
@@ -57,6 +59,7 @@
57
59
  "moment": "^2.30.1",
58
60
  "prop-types": "15.8.1",
59
61
  "react": "^18.3.1",
60
- "react-dom": "^18.3.1"
62
+ "react-dom": "^18.3.1",
63
+ "react-router": "^6.30.1"
61
64
  }
62
65
  }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.exploreCoursesViewedCohesion = exports.exploreCoursesClickedCohesion = void 0;
7
+ var _logging = require("@edx/frontend-platform/logging");
8
+ const exploreCoursesViewedCohesion = (pageTitle, fullUrl) => {
9
+ if (window.tagular && typeof window.tagular === 'function') {
10
+ window.tagular?.('beam', {
11
+ '@type': 'redventures.usertracking.v3.ElementViewed',
12
+ metadata: {
13
+ page: {
14
+ title: pageTitle,
15
+ url: fullUrl,
16
+ pageType: 'Learner Home'
17
+ },
18
+ webElement: {
19
+ elementType: 'BUTTON',
20
+ htmlId: 'explore-courses',
21
+ location: 'recommendation-panel-legacy',
22
+ name: 'explore-courses-RD-cta',
23
+ text: 'Explore courses'
24
+ }
25
+ }
26
+ });
27
+ } else {
28
+ (0, _logging.logError)('Cohesion script failed to load before CTA was shown');
29
+ }
30
+ };
31
+ exports.exploreCoursesViewedCohesion = exploreCoursesViewedCohesion;
32
+ const exploreCoursesClickedCohesion = (pageTitle, fullUrl) => {
33
+ if (window.tagular && typeof window.tagular === 'function') {
34
+ window.tagular?.('beam', {
35
+ '@type': 'redventures.usertracking.v3.ElementClicked',
36
+ metadata: {
37
+ page: {
38
+ title: pageTitle,
39
+ url: fullUrl,
40
+ pageType: 'Learner Home'
41
+ },
42
+ webElement: {
43
+ elementType: 'BUTTON',
44
+ htmlId: 'explore-courses',
45
+ location: 'recommendation-panel-legacy',
46
+ name: 'explore-courses-RD-cta',
47
+ text: 'Explore courses'
48
+ }
49
+ }
50
+ });
51
+ } else {
52
+ (0, _logging.logError)('Cohesion script failed to load before CTA was clicked');
53
+ }
54
+ };
55
+ exports.exploreCoursesClickedCohesion = exploreCoursesClickedCohesion;
56
+ //# sourceMappingURL=exploreCourses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exploreCourses.js","names":["_logging","require","exploreCoursesViewedCohesion","pageTitle","fullUrl","window","tagular","metadata","page","title","url","pageType","webElement","elementType","htmlId","location","name","text","logError","exports","exploreCoursesClickedCohesion"],"sources":["../../../src/tracking/trackers/exploreCourses.js"],"sourcesContent":["import { logError } from '@edx/frontend-platform/logging';\n\nexport const exploreCoursesViewedCohesion = (pageTitle, fullUrl) => {\n if (window.tagular && typeof window.tagular === 'function') {\n window.tagular?.('beam', {\n '@type': 'redventures.usertracking.v3.ElementViewed',\n metadata: {\n page: {\n title: pageTitle,\n url: fullUrl,\n pageType: 'Learner Home',\n },\n webElement: {\n elementType: 'BUTTON',\n htmlId: 'explore-courses',\n location: 'recommendation-panel-legacy',\n name: 'explore-courses-RD-cta',\n text: 'Explore courses',\n },\n },\n });\n } else {\n logError('Cohesion script failed to load before CTA was shown');\n }\n};\n\nexport const exploreCoursesClickedCohesion = (pageTitle, fullUrl) => {\n if (window.tagular && typeof window.tagular === 'function') {\n window.tagular?.('beam', {\n '@type': 'redventures.usertracking.v3.ElementClicked',\n metadata: {\n page: {\n title: pageTitle,\n url: fullUrl,\n pageType: 'Learner Home',\n },\n webElement: {\n elementType: 'BUTTON',\n htmlId: 'explore-courses',\n location: 'recommendation-panel-legacy',\n name: 'explore-courses-RD-cta',\n text: 'Explore courses',\n },\n },\n });\n } else {\n logError('Cohesion script failed to load before CTA was clicked');\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAEO,MAAMC,4BAA4B,GAAGA,CAACC,SAAS,EAAEC,OAAO,KAAK;EAClE,IAAIC,MAAM,CAACC,OAAO,IAAI,OA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+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = require("react");
8
+ var _logging = require("@edx/frontend-platform/logging");
9
+ const UclWrapper = () => {
10
+ const [isLoaded, setLoaded] = (0, _react.useState)(false);
11
+
12
+ // eslint-disable-next-line no-underscore-dangle
13
+ window._UCL = {
14
+ identity: '2u-edx-learner-dashboard'
15
+ };
16
+ (0, _react.useEffect)(() => {
17
+ if (isLoaded) {
18
+ return;
19
+ }
20
+ const head = document.getElementsByTagName('head')[0];
21
+ const script = document.createElement('script');
22
+ script.src = 'https://affiliate-bundle.api.highereducation.com/latest/UCL.adapter.js';
23
+ script.dataset.testId = 'ucl-test';
24
+ script.async = true;
25
+ script.onload = () => {
26
+ if (window.UCL && typeof window.UCL === 'function') {
27
+ (0, _logging.logInfo)('UCL script loaded successfully!');
28
+ } else {
29
+ // in the case that the script successfully loaded but UCL is still not found
30
+ (0, _logging.logError)('window.UCL not found after UCL script load.');
31
+ }
32
+ };
33
+ script.onerror = e => {
34
+ (0, _logging.logError)('UCL script failed to load', e);
35
+ };
36
+ head.appendChild(script);
37
+ setLoaded(true);
38
+ }, [isLoaded]);
39
+ return null;
40
+ };
41
+ var _default = exports.default = UclWrapper;
42
+ //# sourceMappingURL=UclWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UclWrapper.js","names":["_react","require","_logging","UclWrapper","isLoaded","setLoaded","useState","window","_UCL","identity","useEffect","head","document","getElementsByTagName","script","createElement","src","dataset","testId","async","onload","UCL","logInfo","logError","onerror","e","appendChild","_default","exports","default"],"sources":["../../src/ucl-wrapper/UclWrapper.jsx"],"sourcesContent":["import { useState, useEffect } from 'react';\nimport { logError, logInfo } from '@edx/frontend-platform/logging';\n\nconst UclWrapper = () => {\n const [isLoaded, setLoaded] = useState(false);\n\n // eslint-disable-next-line no-underscore-dangle\n window._UCL = {\n identity: '2u-edx-learner-dashboard',\n };\n\n useEffect(() => {\n if (isLoaded) {\n return;\n }\n\n const head = document.getElementsByTagName('head')[0];\n const script = document.createElement('script');\n script.src = 'https://affiliate-bundle.api.highereducation.com/latest/UCL.adapter.js';\n script.dataset.testId = 'ucl-test';\n script.async = true;\n\n script.onload = () => {\n if (window.UCL && typeof window.UCL === 'function') {\n logInfo('UCL script loaded successfully!');\n } else {\n // in the case that the script successfully loaded but UCL is still not found\n logError('window.UCL not found after UCL script load.');\n }\n };\n\n script.onerror = (e) => {\n logError('UCL script failed to load', e);\n };\n\n head.appendChild(script);\n setLoaded(true);\n }, [isLoaded]);\n\n return null;\n};\n\nexport default UclWrapper;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,MAAME,UAAU,GAAGA,CAAA,KAAM;EACvB,MAAM,CAACC,QAAQ,EAAEC,SAAS,CAAC,GAAG,IAAAC,eAAQ,EAAC,KAAK,CAAC;;EAE7C;EACAC,MAAM,CAACC,IAAI,GAAG;IACZC,QAAQ,EAAE;EACZ,CAAC;EAED,IAAAC,gBAAS,EAAC,MAAM;IACd,IAAIN,QAAQ,EAAE;MACZ;IACF;IAEA,MAAMO,IAAI,GAAGC,QAAQ,CAACC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACrD,MAAMC,MAAM,GAAGF,QAAQ,CAACG,aAAa,CAAC,QAAQ,CAAC;IAC/CD,MAAM,CAACE,GAAG,GAAG,wEAAwE;IACrFF,MAAM,CAACG,OAAO,CAACC,MAAM,GAAG,UAAU;IAClCJ,MAAM,CAACK,KAAK,GAAG,IAAI;IAEnBL,MAAM,CAACM,MAAM,GAAG,MAAM;MACpB,IAAIb,MAAM,CAACc,GAAG,IAAI,OAAOd,MAAM,CAACc,GAAG,KAAK,UAAU,EAAE;QAClD,IAAAC,gBAAO,EAAC,iCAAiC,CAAC;MAC5C,CAAC,MAAM;QACL;QACA,IAAAC,iBAAQ,EAAC,6CAA6C,CAAC;MACzD;IACF,CAAC;IAEDT,MAAM,CAACU,OAAO,GAAIC,CAAC,IAAK;MACtB,IAAAF,iBAAQ,EAAC,2BAA2B,EAAEE,CAAC,CAAC;IAC1C,CAAC;IAEDd,IAAI,CAACe,WAAW,CAACZ,MAAM,CAAC;IACxBT,SAAS,CAAC,IAAI,CAAC;EACjB,CAAC,EAAE,CAACD,QAAQ,CAAC,CAAC;EAEd,OAAO,IAAI;AACb,CAAC;AAAC,IAAAuB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEa1B,UAAU","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _UclWrapper = _interopRequireDefault(require("./UclWrapper"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ var _default = exports.default = _UclWrapper.default;
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_UclWrapper","_interopRequireDefault","require","e","__esModule","default","_default","exports","UclWrapper"],"sources":["../../src/ucl-wrapper/index.jsx"],"sourcesContent":["import UclWrapper from './UclWrapper';\n\nexport default UclWrapper;\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAsC,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAEvBG,mBAAU","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edx/frontend-plugin-learner-dashboard",
3
- "version": "3.1.0",
3
+ "version": "3.3.0",
4
4
  "description": "Repository for Learner Dashboard MFE frontend plugins",
5
5
  "main": "dist/index.js",
6
6
  "repository": {
@@ -48,8 +48,10 @@
48
48
  "@testing-library/jest-dom": "^6.6.3",
49
49
  "@testing-library/react": "^16.2.0",
50
50
  "jest": "30.2.0",
51
+ "react-error-boundary": "^6.1.0",
51
52
  "rosie": "2.1.1",
52
- "semantic-release": "^24.0.0"
53
+ "semantic-release": "^25.0.0",
54
+ "ts-jest": "^29.1.4"
53
55
  },
54
56
  "peerDependencies": {
55
57
  "@edx/frontend-platform": "^8.3.1",
@@ -57,6 +59,7 @@
57
59
  "moment": "^2.30.1",
58
60
  "prop-types": "15.8.1",
59
61
  "react": "^18.3.1",
60
- "react-dom": "^18.3.1"
62
+ "react-dom": "^18.3.1",
63
+ "react-router": "^6.30.1"
61
64
  }
62
65
  }
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable import/no-named-as-default-member */
2
2
  import { shallow } from '@edx/react-unit-test-utils';
3
- import { render, screen } from '@testing-library/react';
3
+ import { screen } from '@testing-library/react';
4
+ import render from '../setupTest';
4
5
 
5
6
  import EnterpriseDashboardModalWrapper from './EnterpriseDashboardModalWrapper';
6
7
  import { useEnterpriseDashboardData, useHasAvailableDashboards } from '../data/redux/hooks';
@@ -0,0 +1,54 @@
1
+ import { useState, useEffect, useRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+
4
+ function useUCL(timeout = 5000) {
5
+ const [ucl, setUcl] = useState(() => window.UCL);
6
+ useEffect(() => {
7
+ if (ucl) { return undefined; }
8
+ const start = Date.now();
9
+ const id = setInterval(() => {
10
+ if (window.UCL) {
11
+ setUcl(window.UCL);
12
+ clearInterval(id);
13
+ } else if (Date.now() - start > timeout) {
14
+ clearInterval(id);
15
+ }
16
+ }, 100);
17
+ return () => clearInterval(id);
18
+ }, [ucl, timeout]);
19
+ return ucl;
20
+ }
21
+ class RenderFallbackSignal extends Error {
22
+ constructor() {
23
+ super('Render fallback requested by widget');
24
+ this.name = 'RenderFallbackSignal';
25
+ }
26
+ }
27
+ const DynamicExperienceSlot = ({ widgetName, ...rest }) => {
28
+ const ref = useRef(null);
29
+ const UCL = useUCL();
30
+ const [shouldThrow, setShouldThrow] = useState(false);
31
+ const [error, setError] = useState(null);
32
+ useEffect(() => {
33
+ const refCurrent = ref.current;
34
+ if (!refCurrent || !UCL) { return undefined; }
35
+ try {
36
+ UCL.mount(widgetName, refCurrent, {
37
+ ...rest,
38
+ onFallbackShouldRender: setShouldThrow,
39
+ });
40
+ } catch (e) {
41
+ setError(e);
42
+ }
43
+ return () => UCL.unmount(refCurrent);
44
+ }, [widgetName, UCL, rest]);
45
+ if (error) { throw error; }
46
+ if (shouldThrow) { throw new RenderFallbackSignal(); }
47
+ return <div ref={ref} />;
48
+ };
49
+
50
+ DynamicExperienceSlot.propTypes = {
51
+ widgetName: PropTypes.string.isRequired,
52
+ };
53
+
54
+ export default DynamicExperienceSlot;
@@ -0,0 +1,108 @@
1
+ /* eslint-disable react/prop-types */
2
+ import React from 'react';
3
+ import { render, screen, act } from '@testing-library/react';
4
+ import '@testing-library/jest-dom';
5
+ import { ErrorBoundary } from 'react-error-boundary';
6
+ import DynamicExperienceSlot from './DynamicExperienceSlot';
7
+
8
+ // Helper to catch the custom error signals thrown by the component
9
+ const ErrorFallback = ({ error }) => (
10
+ <span>Fallback Triggered: {error.name}</span>
11
+ );
12
+
13
+ describe('DynamicExperienceSlot', () => {
14
+ let mockUcl;
15
+
16
+ beforeEach(() => {
17
+ jest.useFakeTimers();
18
+ // Reset window.UCL before each test
19
+ delete window.UCL;
20
+
21
+ mockUcl = {
22
+ mount: jest.fn(),
23
+ unmount: jest.fn(),
24
+ };
25
+ });
26
+
27
+ afterEach(() => {
28
+ jest.runOnlyPendingTimers();
29
+ jest.useRealTimers();
30
+ });
31
+
32
+ test('waits for window.UCL and calls mount when available', async () => {
33
+ render(<DynamicExperienceSlot widgetName="test-widget" />);
34
+
35
+ // Initially UCL is undefined, so mount shouldn't be called
36
+ expect(mockUcl.mount).not.toHaveBeenCalled();
37
+
38
+ // Simulate UCL loading onto the window
39
+ window.UCL = mockUcl;
40
+
41
+ // Advance timers to trigger the setInterval in useUCL
42
+ act(() => {
43
+ jest.advanceTimersByTime(100);
44
+ });
45
+
46
+ expect(mockUcl.mount).toHaveBeenCalledWith(
47
+ 'test-widget',
48
+ expect.any(HTMLDivElement),
49
+ expect.objectContaining({
50
+ onFallbackShouldRender: expect.any(Function),
51
+ }),
52
+ );
53
+ });
54
+
55
+ test('passes additional props through to UCL.mount', () => {
56
+ window.UCL = mockUcl;
57
+
58
+ // We pass 'theme' and 'userId' which should end up in the 'rest' object
59
+ render(
60
+ <DynamicExperienceSlot
61
+ widgetName="test-widget"
62
+ theme="dark"
63
+ userId="12345"
64
+ />,
65
+ );
66
+
67
+ expect(mockUcl.mount).toHaveBeenCalledWith(
68
+ 'test-widget',
69
+ expect.any(HTMLDivElement),
70
+ expect.objectContaining({
71
+ theme: 'dark',
72
+ userId: '12345',
73
+ onFallbackShouldRender: expect.any(Function),
74
+ }),
75
+ );
76
+ });
77
+
78
+ test('triggers fallback signal when requested by widget', () => {
79
+ window.UCL = mockUcl;
80
+ let triggerFallback;
81
+
82
+ mockUcl.mount.mockImplementation((name, el, props) => {
83
+ triggerFallback = props.onFallbackShouldRender;
84
+ });
85
+
86
+ render(
87
+ // You use their component instead of writing your own class
88
+ <ErrorBoundary FallbackComponent={ErrorFallback}>
89
+ <DynamicExperienceSlot widgetName="test-widget" />
90
+ </ErrorBoundary>,
91
+ );
92
+
93
+ act(() => {
94
+ triggerFallback(true);
95
+ });
96
+
97
+ expect(screen.getByText(/Fallback Triggered: RenderFallbackSignal/i)).toBeInTheDocument();
98
+ });
99
+
100
+ test('calls unmount on cleanup', () => {
101
+ window.UCL = mockUcl;
102
+ const { unmount } = render(<DynamicExperienceSlot widgetName="test-widget" />);
103
+
104
+ unmount();
105
+
106
+ expect(mockUcl.unmount).toHaveBeenCalled();
107
+ });
108
+ });
@@ -0,0 +1,3 @@
1
+ import DynamicExperienceSlot from './DynamicExperienceSlot';
2
+
3
+ export default DynamicExperienceSlot;
package/src/index.jsx CHANGED
@@ -1,18 +1,24 @@
1
1
  import CohesionWrapper from './cohesion-wrapper/index';
2
2
  import CourseBanner from './course-banner';
3
+ import DynamicExperienceSlot from './dynamic-experience-slot';
3
4
  import EnterpriseDashboardModal from './dashboard-modal/index';
4
5
  import HelpChatbot from './chatbot/index';
6
+ import UclWrapper from './ucl-wrapper';
7
+ import NoCoursesView from './no-courses-view';
8
+ import NoticesRedirect from './notices-redirect/index';
5
9
  import UpgradeButton from './upgrade-button';
6
10
  import UserCareerMenu from './career-menu/index';
7
11
  import UserDashboardMenu from './dashboard-menu/index';
8
- import NoticesRedirect from './notices-redirect/index';
9
12
 
10
13
  export {
11
14
  CohesionWrapper,
12
15
  CourseBanner,
16
+ DynamicExperienceSlot,
13
17
  EnterpriseDashboardModal,
14
18
  HelpChatbot,
19
+ NoCoursesView,
15
20
  NoticesRedirect,
21
+ UclWrapper,
16
22
  UpgradeButton,
17
23
  UserCareerMenu,
18
24
  UserDashboardMenu,
@@ -0,0 +1,60 @@
1
+ /* eslint-disable import/no-unresolved */
2
+ import React, { useCallback, useEffect } from 'react';
3
+ import { useLocation } from 'react-router';
4
+ import { useIntl } from '@edx/frontend-platform/i18n';
5
+ import { Button, Image } from '@openedx/paragon';
6
+ import { Search } from '@openedx/paragon/icons';
7
+ import { baseAppUrl } from 'data/services/lms/urls';
8
+
9
+ import emptyCourseSVG from 'assets/empty-course.svg';
10
+ import { reduxHooks } from 'hooks';
11
+ import { exploreCoursesViewedCohesion, exploreCoursesClickedCohesion } from '../tracking/trackers/exploreCourses';
12
+
13
+ import messages from './messages';
14
+ import './index.scss';
15
+
16
+ const NoCoursesView = () => {
17
+ const { formatMessage } = useIntl();
18
+ const { courseSearchUrl } = reduxHooks.usePlatformSettingsData();
19
+ const location = useLocation();
20
+ const fullUrl = baseAppUrl(location.pathname);
21
+ const pageTitle = document.title;
22
+
23
+ const handleExploreCoursesViewed = useCallback(() => {
24
+ exploreCoursesViewedCohesion(pageTitle, fullUrl);
25
+ }, [pageTitle, fullUrl]);
26
+
27
+ const handleExploreCoursesClick = () => {
28
+ exploreCoursesClickedCohesion(pageTitle, fullUrl);
29
+ };
30
+
31
+ useEffect(() => {
32
+ handleExploreCoursesViewed();
33
+ }, [handleExploreCoursesViewed]);
34
+
35
+ return (
36
+ <div
37
+ id="no-courses-content-view"
38
+ className="d-flex align-items-center justify-content-center mb-4.5"
39
+ >
40
+ <Image src={emptyCourseSVG} alt={formatMessage(messages.bannerAlt)} />
41
+ <h3 className="h1">
42
+ {formatMessage(messages.lookingForChallengePrompt)}
43
+ </h3>
44
+ <p>
45
+ {formatMessage(messages.exploreCoursesPrompt)}
46
+ </p>
47
+ <Button
48
+ variant="brand"
49
+ as="a"
50
+ onClick={handleExploreCoursesClick}
51
+ href={baseAppUrl(courseSearchUrl)}
52
+ iconBefore={Search}
53
+ >
54
+ {formatMessage(messages.exploreCoursesButton)}
55
+ </Button>
56
+ </div>
57
+ );
58
+ };
59
+
60
+ export default NoCoursesView;
@@ -0,0 +1,13 @@
1
+ #no-courses-content-view {
2
+ border: 2px solid var(--pgn-color-light-400);
3
+ flex-direction: column;
4
+ padding-bottom: var(--pgn-spacing-spacer-5);
5
+ padding-top: var(--pgn-spacing-spacer-5);
6
+ height: 100%;
7
+
8
+ & > * {
9
+ margin-top: var(--pgn-spacing-spacer-3);
10
+ margin-bottom: var(--pgn-spacing-spacer-3);
11
+ }
12
+ }
13
+
@@ -0,0 +1,63 @@
1
+ import { fireEvent, render, screen } from '@testing-library/react';
2
+ import { IntlProvider } from '@edx/frontend-platform/i18n';
3
+ import { formatMessage } from '../testUtils';
4
+
5
+ import EmptyCourse from '.';
6
+ import messages from './messages';
7
+ import { exploreCoursesViewedCohesion, exploreCoursesClickedCohesion } from '../tracking/trackers/exploreCourses';
8
+
9
+ const courseSearchUrl = '/course-search-url';
10
+
11
+ jest.mock('react-router', () => ({
12
+ useLocation: jest.fn(() => ({
13
+ pathname: 'mock-pathname',
14
+ })),
15
+ }));
16
+
17
+ jest.mock('hooks', () => ({
18
+ reduxHooks: {
19
+ usePlatformSettingsData: jest.fn(() => ({
20
+ courseSearchUrl,
21
+ })),
22
+ },
23
+ }), { virtual: true });
24
+
25
+ jest.mock('data/services/lms/urls', () => ({
26
+ baseAppUrl: (path) => `mock-base-app-url${path}`,
27
+ }), { virtual: true });
28
+
29
+ jest.mock('../tracking/trackers/exploreCourses', () => ({
30
+ exploreCoursesViewedCohesion: jest.fn(),
31
+ exploreCoursesClickedCohesion: jest.fn(),
32
+ }));
33
+
34
+ describe('NoCoursesView', () => {
35
+ it('should display image, heading and button', () => {
36
+ render(<IntlProvider locale="en"><EmptyCourse /></IntlProvider>);
37
+ const image = screen.getByRole('img', { alt: formatMessage(messages.bannerAlt) });
38
+ expect(image).toBeInTheDocument();
39
+ });
40
+ it('should display heading and prompt', () => {
41
+ render(<IntlProvider locale="en"><EmptyCourse /></IntlProvider>);
42
+ const heading = screen.getByText(formatMessage(messages.lookingForChallengePrompt));
43
+ const prompt = screen.getByText(formatMessage(messages.exploreCoursesPrompt));
44
+ expect(heading).toBeInTheDocument();
45
+ expect(prompt).toBeInTheDocument();
46
+ });
47
+ it('should display button', () => {
48
+ render(<IntlProvider locale="en"><EmptyCourse /></IntlProvider>);
49
+ const button = screen.getByRole('link', { name: formatMessage(messages.exploreCoursesButton) });
50
+ expect(button).toBeInTheDocument();
51
+ expect(button.href).toContain(`mock-base-app-url${courseSearchUrl}`);
52
+ });
53
+ it('should fire cohesion viewed event on load', () => {
54
+ render(<IntlProvider locale="en"><EmptyCourse /></IntlProvider>);
55
+ expect(exploreCoursesViewedCohesion).toHaveBeenCalled();
56
+ });
57
+ it('should fire cohesion click event when explore courses CTA is clicked', () => {
58
+ render(<IntlProvider locale="en"><EmptyCourse /></IntlProvider>);
59
+ const button = screen.getByRole('link', { name: formatMessage(messages.exploreCoursesButton) });
60
+ fireEvent.click(button);
61
+ expect(exploreCoursesClickedCohesion).toHaveBeenCalled();
62
+ });
63
+ });
@@ -0,0 +1,26 @@
1
+ import { defineMessages } from '@edx/frontend-platform/i18n';
2
+
3
+ const messages = defineMessages({
4
+ lookingForChallengePrompt: {
5
+ id: 'Dashboard.NoCoursesView.lookingForChallengePrompt',
6
+ defaultMessage: 'Looking for a new challenge?',
7
+ description: 'Prompt user for new challenge',
8
+ },
9
+ exploreCoursesPrompt: {
10
+ id: 'Dashboard.NoCoursesView.exploreCoursesPrompt',
11
+ defaultMessage: 'Explore our courses to add them to your dashboard.',
12
+ description: 'Prompt user to explore more courses',
13
+ },
14
+ exploreCoursesButton: {
15
+ id: 'Dashboard.NoCoursesView.exploreCoursesButton',
16
+ defaultMessage: 'Explore courses',
17
+ description: 'Button to explore more courses',
18
+ },
19
+ bannerAlt: {
20
+ id: 'Dashboard.NoCoursesView.bannerAlt',
21
+ defaultMessage: 'No Courses view banner',
22
+ description: 'No Courses view basnner',
23
+ },
24
+ });
25
+
26
+ export default messages;
@@ -0,0 +1,49 @@
1
+ import { logError } from '@edx/frontend-platform/logging';
2
+
3
+ export const exploreCoursesViewedCohesion = (pageTitle, fullUrl) => {
4
+ if (window.tagular && typeof window.tagular === 'function') {
5
+ window.tagular?.('beam', {
6
+ '@type': 'redventures.usertracking.v3.ElementViewed',
7
+ metadata: {
8
+ page: {
9
+ title: pageTitle,
10
+ url: fullUrl,
11
+ pageType: 'Learner Home',
12
+ },
13
+ webElement: {
14
+ elementType: 'BUTTON',
15
+ htmlId: 'explore-courses',
16
+ location: 'recommendation-panel-legacy',
17
+ name: 'explore-courses-RD-cta',
18
+ text: 'Explore courses',
19
+ },
20
+ },
21
+ });
22
+ } else {
23
+ logError('Cohesion script failed to load before CTA was shown');
24
+ }
25
+ };
26
+
27
+ export const exploreCoursesClickedCohesion = (pageTitle, fullUrl) => {
28
+ if (window.tagular && typeof window.tagular === 'function') {
29
+ window.tagular?.('beam', {
30
+ '@type': 'redventures.usertracking.v3.ElementClicked',
31
+ metadata: {
32
+ page: {
33
+ title: pageTitle,
34
+ url: fullUrl,
35
+ pageType: 'Learner Home',
36
+ },
37
+ webElement: {
38
+ elementType: 'BUTTON',
39
+ htmlId: 'explore-courses',
40
+ location: 'recommendation-panel-legacy',
41
+ name: 'explore-courses-RD-cta',
42
+ text: 'Explore courses',
43
+ },
44
+ },
45
+ });
46
+ } else {
47
+ logError('Cohesion script failed to load before CTA was clicked');
48
+ }
49
+ };
@@ -0,0 +1,43 @@
1
+ import { useState, useEffect } from 'react';
2
+ import { logError, logInfo } from '@edx/frontend-platform/logging';
3
+
4
+ const UclWrapper = () => {
5
+ const [isLoaded, setLoaded] = useState(false);
6
+
7
+ // eslint-disable-next-line no-underscore-dangle
8
+ window._UCL = {
9
+ identity: '2u-edx-learner-dashboard',
10
+ };
11
+
12
+ useEffect(() => {
13
+ if (isLoaded) {
14
+ return;
15
+ }
16
+
17
+ const head = document.getElementsByTagName('head')[0];
18
+ const script = document.createElement('script');
19
+ script.src = 'https://affiliate-bundle.api.highereducation.com/latest/UCL.adapter.js';
20
+ script.dataset.testId = 'ucl-test';
21
+ script.async = true;
22
+
23
+ script.onload = () => {
24
+ if (window.UCL && typeof window.UCL === 'function') {
25
+ logInfo('UCL script loaded successfully!');
26
+ } else {
27
+ // in the case that the script successfully loaded but UCL is still not found
28
+ logError('window.UCL not found after UCL script load.');
29
+ }
30
+ };
31
+
32
+ script.onerror = (e) => {
33
+ logError('UCL script failed to load', e);
34
+ };
35
+
36
+ head.appendChild(script);
37
+ setLoaded(true);
38
+ }, [isLoaded]);
39
+
40
+ return null;
41
+ };
42
+
43
+ export default UclWrapper;
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import {
3
+ render,
4
+ } from '@testing-library/react';
5
+
6
+ import UclWrapper from './UclWrapper';
7
+
8
+ describe('UCL Wrapper loads', () => {
9
+ it('should load the UCL wrapper into the head', () => {
10
+ render(<UclWrapper />);
11
+ const script = document.querySelector('[data-test-id="ucl-test"]');
12
+
13
+ // eslint-disable-next-line no-underscore-dangle
14
+ expect(window._UCL.identity).toEqual('2u-edx-learner-dashboard');
15
+ expect(script.dataset.testId).toEqual('ucl-test');
16
+ });
17
+ });
@@ -0,0 +1,3 @@
1
+ import UclWrapper from './UclWrapper';
2
+
3
+ export default UclWrapper;