@edx/frontend-plugin-learner-dashboard 3.3.3 → 3.3.4

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.
@@ -8,6 +8,7 @@ var _react = _interopRequireWildcard(require("react"));
8
8
  var _i18n = require("@edx/frontend-platform/i18n");
9
9
  var _paragon = require("@openedx/paragon");
10
10
  var _icons = require("@openedx/paragon/icons");
11
+ var _reactIntersectionObserver = require("react-intersection-observer");
11
12
  var _urls = require("data/services/lms/urls");
12
13
  var _emptyCourse = _interopRequireDefault(require("assets/empty-course.svg"));
13
14
  var _hooks = require("hooks");
@@ -27,6 +28,13 @@ const NoCoursesView = () => {
27
28
  courseSearchUrl
28
29
  } = _hooks.reduxHooks.usePlatformSettingsData();
29
30
  const viewCorrelationIdRef = (0, _react.useRef)(window.crypto.randomUUID());
31
+ const hasViewEventFired = (0, _react.useRef)(false);
32
+ const {
33
+ ref: exploreCoursesRef,
34
+ inView
35
+ } = (0, _reactIntersectionObserver.useInView)({
36
+ triggerOnce: true
37
+ });
30
38
  const handleExploreCoursesViewed = (0, _react.useCallback)(() => {
31
39
  (0, _exploreCourses.exploreCoursesViewedCohesion)(viewCorrelationIdRef.current);
32
40
  }, []);
@@ -34,8 +42,11 @@ const NoCoursesView = () => {
34
42
  (0, _exploreCourses.exploreCoursesClickedCohesion)(viewCorrelationIdRef.current);
35
43
  };
36
44
  (0, _react.useEffect)(() => {
37
- handleExploreCoursesViewed();
38
- }, [handleExploreCoursesViewed]);
45
+ if (!hasViewEventFired.current && inView) {
46
+ handleExploreCoursesViewed();
47
+ hasViewEventFired.current = true;
48
+ }
49
+ }, [handleExploreCoursesViewed, inView]);
39
50
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
40
51
  id: "no-courses-content-view",
41
52
  className: "d-flex align-items-center justify-content-center mb-4.5",
@@ -53,6 +64,7 @@ const NoCoursesView = () => {
53
64
  onClick: handleExploreCoursesClick,
54
65
  href: (0, _urls.baseAppUrl)(courseSearchUrl),
55
66
  iconBefore: _icons.Search,
67
+ ref: exploreCoursesRef,
56
68
  children: formatMessage(_messages.default.exploreCoursesButton)
57
69
  })]
58
70
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_react","_interopRequireWildcard","require","_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","viewCorrelationIdRef","useRef","window","crypto","randomUUID","handleExploreCoursesViewed","useCallback","exploreCoursesViewedCohesion","current","handleExploreCoursesClick","exploreCoursesClickedCohesion","useEffect","jsxs","id","className","children","jsx","Image","src","emptyCourseSVG","alt","messages","bannerAlt","lookingForChallengePrompt","exploreCoursesPrompt","Button","variant","as","onClick","href","baseAppUrl","iconBefore","Search","exploreCoursesButton","_default","exports"],"sources":["../../src/no-courses-view/index.jsx"],"sourcesContent":["/* eslint-disable import/no-unresolved */\nimport React, { useCallback, useEffect, useRef } from 'react';\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 viewCorrelationIdRef = useRef(window.crypto.randomUUID());\n\n const handleExploreCoursesViewed = useCallback(() => {\n exploreCoursesViewedCohesion(viewCorrelationIdRef.current);\n }, []);\n\n const handleExploreCoursesClick = () => {\n exploreCoursesClickedCohesion(viewCorrelationIdRef.current);\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,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAEA,IAAAK,YAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,eAAA,GAAAR,OAAA;AAEA,IAAAS,SAAA,GAAAH,sBAAA,CAAAN,OAAA;AACAA,OAAA;AAAsB,IAAAU,WAAA,GAAAV,OAAA;AAAA,SAAAM,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAZ,wBAAAY,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAhB,uBAAA,YAAAA,CAAAY,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SA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C,MAAM;IACdN,0BAA0B,CAAC,CAAC;EAC9B,CAAC,EAAE,CAACA,0BAA0B,CAAC,CAAC;EAEhC,oBACE,IAAA/B,WAAA,CAAAsC,IAAA;IACEC,EAAE,EAAC,yBAAyB;IAC5BC,SAAS,EAAC,yDAAyD;IAAAC,QAAA,gBAEnE,IAAAzC,WAAA,CAAA0C,GAAA,EAAClD,QAAA,CAAAmD,KAAK;MAACC,GAAG,EAAEC,oBAAe;MAACC,GAAG,EAAEzB,aAAa,CAAC0B,iBAAQ,CAACC,SAAS;IAAE,CAAE,CAAC,eACtE,IAAAhD,WAAA,CAAA0C,GAAA;MAAIF,SAAS,EAAC,IAAI;MAAAC,QAAA,EACfpB,aAAa,CAAC0B,iBAAQ,CAACE,yBAAyB;IAAC,CAChD,CAAC,eACL,IAAAjD,WAAA,CAAA0C,GAAA;MAAAD,QAAA,EACGpB,aAAa,CAAC0B,iBAAQ,CAACG,oBAAoB;IAAC,CAC5C,CAAC,eACJ,IAAAlD,WAAA,CAAA0C,GAAA,EAAClD,QAAA,CAAA2D,MAAM;MACLC,OAAO,EAAC,OAAO;MACfC,EAAE,EAAC,GAAG;MACNC,OAAO,EAAEnB,yBAA0B;MACnCoB,IAAI,EAAE,IAAAC,gBAAU,EAACjC,eAAe,CAAE;MAClCkC,UAAU,EAAEC,aAAO;MAAAjB,QAAA,EAElBpB,aAAa,CAAC0B,iBAAQ,CAACY,oBAAoB;IAAC,CACvC,CAAC;EAAA,CACN,CAAC;AAEV,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA1D,OAAA,GAEaiB,aAAa","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_react","_interopRequireWildcard","require","_i18n","_paragon","_icons","_reactIntersectionObserver","_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","viewCorrelationIdRef","useRef","window","crypto","randomUUID","hasViewEventFired","ref","exploreCoursesRef","inView","useInView","triggerOnce","handleExploreCoursesViewed","useCallback","exploreCoursesViewedCohesion","current","handleExploreCoursesClick","exploreCoursesClickedCohesion","useEffect","jsxs","id","className","children","jsx","Image","src","emptyCourseSVG","alt","messages","bannerAlt","lookingForChallengePrompt","exploreCoursesPrompt","Button","variant","as","onClick","href","baseAppUrl","iconBefore","Search","exploreCoursesButton","_default","exports"],"sources":["../../src/no-courses-view/index.jsx"],"sourcesContent":["/* eslint-disable import/no-unresolved */\nimport React, { useCallback, useEffect, useRef } from 'react';\nimport { useIntl } from '@edx/frontend-platform/i18n';\nimport { Button, Image } from '@openedx/paragon';\nimport { Search } from '@openedx/paragon/icons';\nimport { useInView } from 'react-intersection-observer';\n\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 viewCorrelationIdRef = useRef(window.crypto.randomUUID());\n const hasViewEventFired = useRef(false);\n\n const { ref: exploreCoursesRef, inView } = useInView({ triggerOnce: true });\n\n const handleExploreCoursesViewed = useCallback(() => {\n exploreCoursesViewedCohesion(viewCorrelationIdRef.current);\n }, []);\n\n const handleExploreCoursesClick = () => {\n exploreCoursesClickedCohesion(viewCorrelationIdRef.current);\n };\n\n useEffect(() => {\n if (!hasViewEventFired.current && inView) {\n handleExploreCoursesViewed();\n hasViewEventFired.current = true;\n }\n }, [handleExploreCoursesViewed, inView]);\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 ref={exploreCoursesRef}\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,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,0BAAA,GAAAJ,OAAA;AAEA,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,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAjB,uBAAA,YAAAA,CAAAa,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA,MAAAF,CAAA,GAAAJ,CA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HANGED
@@ -36,6 +36,7 @@
36
36
  "@optimizely/react-sdk": "^3.2.2",
37
37
  "jest-environment-jsdom": "^30.0.0",
38
38
  "lodash": "^4.17.21",
39
+ "react-intersection-observer": "^10.0.3",
39
40
  "react-redux": "^7.2.4",
40
41
  "react-responsive": "^10.0.0",
41
42
  "reselect": "^5.1.1"
@@ -47,7 +48,7 @@
47
48
  "@openedx/frontend-build": "14.6.2",
48
49
  "@testing-library/jest-dom": "^6.6.3",
49
50
  "@testing-library/react": "^16.2.0",
50
- "jest": "30.2.0",
51
+ "jest": "30.3.0",
51
52
  "react-error-boundary": "^6.1.0",
52
53
  "rosie": "2.1.1",
53
54
  "semantic-release": "^25.0.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edx/frontend-plugin-learner-dashboard",
3
- "version": "3.3.3",
3
+ "version": "3.3.4",
4
4
  "description": "Repository for Learner Dashboard MFE frontend plugins",
5
5
  "main": "dist/index.js",
6
6
  "repository": {
@@ -36,6 +36,7 @@
36
36
  "@optimizely/react-sdk": "^3.2.2",
37
37
  "jest-environment-jsdom": "^30.0.0",
38
38
  "lodash": "^4.17.21",
39
+ "react-intersection-observer": "^10.0.3",
39
40
  "react-redux": "^7.2.4",
40
41
  "react-responsive": "^10.0.0",
41
42
  "reselect": "^5.1.1"
@@ -47,7 +48,7 @@
47
48
  "@openedx/frontend-build": "14.6.2",
48
49
  "@testing-library/jest-dom": "^6.6.3",
49
50
  "@testing-library/react": "^16.2.0",
50
- "jest": "30.2.0",
51
+ "jest": "30.3.0",
51
52
  "react-error-boundary": "^6.1.0",
52
53
  "rosie": "2.1.1",
53
54
  "semantic-release": "^25.0.0",
@@ -3,6 +3,8 @@ import React, { useCallback, useEffect, useRef } from 'react';
3
3
  import { useIntl } from '@edx/frontend-platform/i18n';
4
4
  import { Button, Image } from '@openedx/paragon';
5
5
  import { Search } from '@openedx/paragon/icons';
6
+ import { useInView } from 'react-intersection-observer';
7
+
6
8
  import { baseAppUrl } from 'data/services/lms/urls';
7
9
 
8
10
  import emptyCourseSVG from 'assets/empty-course.svg';
@@ -16,6 +18,9 @@ const NoCoursesView = () => {
16
18
  const { formatMessage } = useIntl();
17
19
  const { courseSearchUrl } = reduxHooks.usePlatformSettingsData();
18
20
  const viewCorrelationIdRef = useRef(window.crypto.randomUUID());
21
+ const hasViewEventFired = useRef(false);
22
+
23
+ const { ref: exploreCoursesRef, inView } = useInView({ triggerOnce: true });
19
24
 
20
25
  const handleExploreCoursesViewed = useCallback(() => {
21
26
  exploreCoursesViewedCohesion(viewCorrelationIdRef.current);
@@ -26,8 +31,11 @@ const NoCoursesView = () => {
26
31
  };
27
32
 
28
33
  useEffect(() => {
29
- handleExploreCoursesViewed();
30
- }, [handleExploreCoursesViewed]);
34
+ if (!hasViewEventFired.current && inView) {
35
+ handleExploreCoursesViewed();
36
+ hasViewEventFired.current = true;
37
+ }
38
+ }, [handleExploreCoursesViewed, inView]);
31
39
 
32
40
  return (
33
41
  <div
@@ -47,6 +55,7 @@ const NoCoursesView = () => {
47
55
  onClick={handleExploreCoursesClick}
48
56
  href={baseAppUrl(courseSearchUrl)}
49
57
  iconBefore={Search}
58
+ ref={exploreCoursesRef}
50
59
  >
51
60
  {formatMessage(messages.exploreCoursesButton)}
52
61
  </Button>
@@ -8,6 +8,13 @@ import { exploreCoursesViewedCohesion, exploreCoursesClickedCohesion } from '../
8
8
 
9
9
  const courseSearchUrl = '/course-search-url';
10
10
 
11
+ jest.mock('react-intersection-observer', () => ({
12
+ useInView: jest.fn(() => ({
13
+ ref: jest.fn(),
14
+ inView: jest.fn(),
15
+ })),
16
+ }));
17
+
11
18
  jest.mock('hooks', () => ({
12
19
  reduxHooks: {
13
20
  usePlatformSettingsData: jest.fn(() => ({