@edx/frontend-plugin-learner-dashboard 2.0.3 → 2.0.5
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.
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
|
+
var _logging = require("@edx/frontend-platform/logging");
|
|
8
9
|
const CohesionWrapper = () => {
|
|
9
10
|
const [isLoaded, setLoaded] = (0, _react.useState)(false);
|
|
10
11
|
|
|
@@ -18,6 +19,17 @@ const CohesionWrapper = () => {
|
|
|
18
19
|
const script = document.createElement('script');
|
|
19
20
|
script.src = 'https://www.edx.org/beam-wrapper.js';
|
|
20
21
|
script.dataset.testId = 'cohesion-test';
|
|
22
|
+
script.onload = () => {
|
|
23
|
+
if (window.tagular && typeof window.tagular === 'function') {
|
|
24
|
+
(0, _logging.logInfo)('Cohesion script loaded successfully!');
|
|
25
|
+
} else {
|
|
26
|
+
// in the case that the script successfully loaded but tagular is still not found
|
|
27
|
+
(0, _logging.logError)('window.tagular not found after Cohesion script load.');
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
script.onerror = e => {
|
|
31
|
+
(0, _logging.logError)('Cohesion script failed to load', e);
|
|
32
|
+
};
|
|
21
33
|
head.appendChild(script);
|
|
22
34
|
setLoaded(true);
|
|
23
35
|
}, [isLoaded]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CohesionWrapper.js","names":["_react","require","CohesionWrapper","isLoaded","setLoaded","useState","window","chsn_pageType","useEffect","head","document","getElementsByTagName","script","createElement","src","dataset","testId","appendChild","_default","exports","default"],"sources":["../../src/cohesion-wrapper/CohesionWrapper.jsx"],"sourcesContent":["import { useState, useEffect } from 'react';\n\nconst CohesionWrapper = () => {\n const [isLoaded, setLoaded] = useState(false);\n\n // set pageType value\n window.chsn_pageType = 'lms-homepage';\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://www.edx.org/beam-wrapper.js';\n script.dataset.testId = 'cohesion-test';\n head.appendChild(script);\n setLoaded(true);\n }, [isLoaded]);\n\n return null;\n};\n\nexport default CohesionWrapper;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,
|
|
1
|
+
{"version":3,"file":"CohesionWrapper.js","names":["_react","require","_logging","CohesionWrapper","isLoaded","setLoaded","useState","window","chsn_pageType","useEffect","head","document","getElementsByTagName","script","createElement","src","dataset","testId","onload","tagular","logInfo","logError","onerror","e","appendChild","_default","exports","default"],"sources":["../../src/cohesion-wrapper/CohesionWrapper.jsx"],"sourcesContent":["import { useState, useEffect } from 'react';\nimport { logError, logInfo } from '@edx/frontend-platform/logging';\n\nconst CohesionWrapper = () => {\n const [isLoaded, setLoaded] = useState(false);\n\n // set pageType value\n window.chsn_pageType = 'lms-homepage';\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://www.edx.org/beam-wrapper.js';\n script.dataset.testId = 'cohesion-test';\n\n script.onload = () => {\n if (window.tagular && typeof window.tagular === 'function') {\n logInfo('Cohesion script loaded successfully!');\n } else {\n // in the case that the script successfully loaded but tagular is still not found\n logError('window.tagular not found after Cohesion script load.');\n }\n };\n\n script.onerror = (e) => {\n logError('Cohesion script failed to load', e);\n };\n\n head.appendChild(script);\n setLoaded(true);\n }, [isLoaded]);\n\n return null;\n};\n\nexport default CohesionWrapper;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,MAAME,eAAe,GAAGA,CAAA,KAAM;EAC5B,MAAM,CAACC,QAAQ,EAAEC,SAAS,CAAC,GAAG,IAAAC,eAAQ,EAAC,KAAK,CAAC;;EAE7C;EACAC,MAAM,CAACC,aAAa,GAAG,cAAc;EAErC,IAAAC,gBAAS,EAAC,MAAM;IACd,IAAIL,QAAQ,EAAE;MACZ;IACF;IAEA,MAAMM,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,qCAAqC;IAClDF,MAAM,CAACG,OAAO,CAACC,MAAM,GAAG,eAAe;IAEvCJ,MAAM,CAACK,MAAM,GAAG,MAAM;MACpB,IAAIX,MAAM,CAACY,OAAO,IAAI,OAAOZ,MAAM,CAACY,OAAO,KAAK,UAAU,EAAE;QAC1D,IAAAC,gBAAO,EAAC,sCAAsC,CAAC;MACjD,CAAC,MAAM;QACL;QACA,IAAAC,iBAAQ,EAAC,sDAAsD,CAAC;MAClE;IACF,CAAC;IAEDR,MAAM,CAACS,OAAO,GAAIC,CAAC,IAAK;MACtB,IAAAF,iBAAQ,EAAC,gCAAgC,EAAEE,CAAC,CAAC;IAC/C,CAAC;IAEDb,IAAI,CAACc,WAAW,CAACX,MAAM,CAAC;IACxBR,SAAS,CAAC,IAAI,CAAC;EACjB,CAAC,EAAE,CAACD,QAAQ,CAAC,CAAC;EAEd,OAAO,IAAI;AACb,CAAC;AAAC,IAAAqB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaxB,eAAe","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useState, useEffect } from 'react';
|
|
2
|
+
import { logError, logInfo } from '@edx/frontend-platform/logging';
|
|
2
3
|
|
|
3
4
|
const CohesionWrapper = () => {
|
|
4
5
|
const [isLoaded, setLoaded] = useState(false);
|
|
@@ -15,6 +16,20 @@ const CohesionWrapper = () => {
|
|
|
15
16
|
const script = document.createElement('script');
|
|
16
17
|
script.src = 'https://www.edx.org/beam-wrapper.js';
|
|
17
18
|
script.dataset.testId = 'cohesion-test';
|
|
19
|
+
|
|
20
|
+
script.onload = () => {
|
|
21
|
+
if (window.tagular && typeof window.tagular === 'function') {
|
|
22
|
+
logInfo('Cohesion script loaded successfully!');
|
|
23
|
+
} else {
|
|
24
|
+
// in the case that the script successfully loaded but tagular is still not found
|
|
25
|
+
logError('window.tagular not found after Cohesion script load.');
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
script.onerror = (e) => {
|
|
30
|
+
logError('Cohesion script failed to load', e);
|
|
31
|
+
};
|
|
32
|
+
|
|
18
33
|
head.appendChild(script);
|
|
19
34
|
setLoaded(true);
|
|
20
35
|
}, [isLoaded]);
|