@edx/frontend-plugin-learner-dashboard 3.4.0 → 4.0.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.
- package/.eslintrc.js +10 -1
- package/.github/workflows/release.yml +7 -0
- package/dist/career-menu/index.js +5 -2
- package/dist/career-menu/index.js.map +1 -1
- package/dist/course-banner/CourseBanner.js +4 -3
- package/dist/course-banner/CourseBanner.js.map +1 -1
- package/dist/course-banner/index.js +1 -25
- package/dist/course-banner/index.js.map +1 -1
- package/dist/dashboard-menu/index.js +5 -4
- package/dist/dashboard-menu/index.js.map +1 -1
- package/dist/dashboard-modal/EnterpriseDashboardModalWrapper.js +5 -2
- package/dist/dashboard-modal/EnterpriseDashboardModalWrapper.js.map +1 -1
- package/dist/dashboard-modal/hooks/hooks.js +6 -3
- package/dist/dashboard-modal/hooks/hooks.js.map +1 -1
- package/dist/dashboard-modal/index.js +1 -21
- package/dist/dashboard-modal/index.js.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/no-courses-view/index.js +4 -3
- package/dist/no-courses-view/index.js.map +1 -1
- package/dist/package.json +4 -4
- package/dist/progressive-profiling-dashboard/ProgressiveProfilingEntry.js +38 -0
- package/dist/progressive-profiling-dashboard/ProgressiveProfilingEntry.js.map +1 -0
- package/dist/progressive-profiling-dashboard/ProgressiveProfilingModal.js +117 -0
- package/dist/progressive-profiling-dashboard/ProgressiveProfilingModal.js.map +1 -0
- package/dist/progressive-profiling-dashboard/api/service.js +11 -6
- package/dist/progressive-profiling-dashboard/api/service.js.map +1 -1
- package/dist/progressive-profiling-dashboard/data/progressiveProfilingFields.js +2 -37
- package/dist/progressive-profiling-dashboard/data/progressiveProfilingFields.js.map +1 -1
- package/dist/progressive-profiling-dashboard/hooks/useClearProgressiveProfilingQueryParams.js +16 -0
- package/dist/progressive-profiling-dashboard/hooks/useClearProgressiveProfilingQueryParams.js.map +1 -0
- package/dist/progressive-profiling-dashboard/hooks/useProgressiveProfilingForm.js +3 -3
- package/dist/progressive-profiling-dashboard/hooks/useProgressiveProfilingForm.js.map +1 -1
- package/dist/progressive-profiling-dashboard/hooks/useProgressiveProfilingTrigger.js +14 -0
- package/dist/progressive-profiling-dashboard/hooks/useProgressiveProfilingTrigger.js.map +1 -0
- package/dist/progressive-profiling-dashboard/index.js +9 -0
- package/dist/progressive-profiling-dashboard/index.js.map +1 -0
- package/dist/setupTest.js +22 -10
- package/dist/setupTest.js.map +1 -1
- package/dist/tracking/trackers/progressiveProfiling.js +7 -2
- package/dist/tracking/trackers/progressiveProfiling.js.map +1 -1
- package/dist/upgrade-button/UpgradeButton.js +6 -3
- package/dist/upgrade-button/UpgradeButton.js.map +1 -1
- package/dist/upgrade-button/UpgradeButtonWrapper.js +4 -3
- package/dist/upgrade-button/UpgradeButtonWrapper.js.map +1 -1
- package/dist/upgrade-button/data/hooks.js +5 -7
- package/dist/upgrade-button/data/hooks.js.map +1 -1
- package/dist/upgrade-button/index.js +1 -25
- package/dist/upgrade-button/index.js.map +1 -1
- package/package.json +5 -5
- package/src/career-menu/index.jsx +3 -2
- package/src/career-menu/index.test.jsx +11 -6
- package/src/course-banner/CourseBanner.jsx +4 -3
- package/src/course-banner/CourseBanner.test.jsx +8 -14
- package/src/course-banner/index.jsx +1 -20
- package/src/dashboard-menu/index.jsx +3 -2
- package/src/dashboard-menu/index.test.jsx +15 -6
- package/src/dashboard-modal/EnterpriseDashboardModalWrapper.jsx +5 -2
- package/src/dashboard-modal/EnterpriseDashboardModalWrapper.test.jsx +10 -9
- package/src/dashboard-modal/hooks/hooks.js +6 -3
- package/src/dashboard-modal/hooks/hooks.test.js +8 -8
- package/src/dashboard-modal/index.jsx +1 -19
- package/src/index.jsx +2 -0
- package/src/no-courses-view/index.jsx +3 -2
- package/src/no-courses-view/index.test.jsx +8 -6
- package/src/progressive-profiling-dashboard/ProgressiveProfilingEntry.jsx +33 -0
- package/src/progressive-profiling-dashboard/ProgressiveProfilingModal.jsx +110 -0
- package/src/progressive-profiling-dashboard/api/service.js +12 -4
- package/src/progressive-profiling-dashboard/data/progressiveProfilingFields.js +1 -54
- package/src/progressive-profiling-dashboard/hooks/useClearProgressiveProfilingQueryParams.jsx +12 -0
- package/src/progressive-profiling-dashboard/hooks/useProgressiveProfilingForm.jsx +4 -4
- package/src/progressive-profiling-dashboard/hooks/useProgressiveProfilingTrigger.jsx +9 -0
- package/src/progressive-profiling-dashboard/index.jsx +3 -0
- package/src/setupTest.js +20 -8
- package/src/tracking/trackers/progressiveProfiling.js +7 -0
- package/src/upgrade-button/UpgradeButton.jsx +8 -4
- package/src/upgrade-button/UpgradeButton.test.jsx +19 -10
- package/src/upgrade-button/UpgradeButtonWrapper.jsx +5 -3
- package/src/upgrade-button/UpgradeButtonWrapper.test.jsx +9 -11
- package/src/upgrade-button/__snapshots__/UpgradeButton.test.jsx.snap +1 -9
- package/src/upgrade-button/data/hooks.js +5 -5
- package/src/upgrade-button/data/hooks.test.js +5 -0
- package/src/upgrade-button/index.jsx +1 -20
- package/dist/data/redux/app/constants.js +0 -18
- package/dist/data/redux/app/constants.js.map +0 -1
- package/dist/data/redux/app/selectors/courseCard.js +0 -54
- package/dist/data/redux/app/selectors/courseCard.js.map +0 -1
- package/dist/data/redux/app/selectors/simpleSelectors.js +0 -35
- package/dist/data/redux/app/selectors/simpleSelectors.js.map +0 -1
- package/dist/data/redux/hooks.js +0 -49
- package/dist/data/redux/hooks.js.map +0 -1
- package/dist/data/redux/requests/constants.js +0 -16
- package/dist/data/redux/requests/constants.js.map +0 -1
- package/dist/data/redux/requests/selectors.js +0 -61
- package/dist/data/redux/requests/selectors.js.map +0 -1
- package/src/data/redux/app/constants.js +0 -17
- package/src/data/redux/app/selectors/courseCard.js +0 -60
- package/src/data/redux/app/selectors/courseCard.test.js +0 -160
- package/src/data/redux/app/selectors/simpleSelectors.js +0 -26
- package/src/data/redux/app/selectors/simpleSelectors.test.js +0 -54
- package/src/data/redux/hooks.js +0 -44
- package/src/data/redux/requests/constants.js +0 -10
- package/src/data/redux/requests/selectors.js +0 -38
- package/src/data/redux/requests/selectors.test.js +0 -111
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { getAuthenticatedUser } from '@edx/frontend-platform/auth';
|
|
3
|
+
|
|
4
|
+
import ProgressiveProfilingModal from './ProgressiveProfilingModal';
|
|
5
|
+
import useProgressiveProfilingTrigger from './hooks/useProgressiveProfilingTrigger';
|
|
6
|
+
import useClearProgressiveProfilingQueryParams from './hooks/useClearProgressiveProfilingQueryParams';
|
|
7
|
+
import { trackProgressiveProfilingQuestionaireModalFormOpened } from '../tracking/trackers/progressiveProfiling';
|
|
8
|
+
|
|
9
|
+
const ProgressiveProfilingEntry = () => {
|
|
10
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
11
|
+
|
|
12
|
+
const username = getAuthenticatedUser()?.username;
|
|
13
|
+
|
|
14
|
+
const { shouldOpen } = useProgressiveProfilingTrigger();
|
|
15
|
+
const clearTrigger = useClearProgressiveProfilingQueryParams();
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (shouldOpen && username) {
|
|
19
|
+
setIsOpen(true);
|
|
20
|
+
trackProgressiveProfilingQuestionaireModalFormOpened({ host: window.location.origin });
|
|
21
|
+
}
|
|
22
|
+
}, [shouldOpen, username]);
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<ProgressiveProfilingModal
|
|
26
|
+
isOpen={isOpen}
|
|
27
|
+
onClose={() => setIsOpen(false)}
|
|
28
|
+
clearTrigger={clearTrigger}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { ProgressiveProfilingEntry };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { getConfig } from '@edx/frontend-platform';
|
|
4
|
+
import { useIntl } from '@edx/frontend-platform/i18n';
|
|
5
|
+
import {
|
|
6
|
+
Alert, Button, Form, Hyperlink, ModalDialog,
|
|
7
|
+
} from '@openedx/paragon';
|
|
8
|
+
|
|
9
|
+
import { FormFieldRenderer } from './field-renderer';
|
|
10
|
+
import useProgressiveProfilingForm from './hooks/useProgressiveProfilingForm';
|
|
11
|
+
import { COMPLETE_STATE, PENDING_STATE } from './utils/constants';
|
|
12
|
+
import messages from './progressive-profiling-authn-replica/messages';
|
|
13
|
+
import {
|
|
14
|
+
trackProgressiveProfilingSkipLinkClick, trackProgressiveProfilingSubmitClick,
|
|
15
|
+
trackProgressiveProfilingSupportLinkClick,
|
|
16
|
+
} from '../tracking/trackers/progressiveProfiling';
|
|
17
|
+
|
|
18
|
+
const ProgressiveProfilingModal = ({
|
|
19
|
+
isOpen, onClose, clearTrigger,
|
|
20
|
+
}) => {
|
|
21
|
+
const { formatMessage } = useIntl();
|
|
22
|
+
const {
|
|
23
|
+
loadState, submitState, error, values, fieldList, onChangeHandler, submit,
|
|
24
|
+
} = useProgressiveProfilingForm();
|
|
25
|
+
|
|
26
|
+
const handleSubmit = async (e) => {
|
|
27
|
+
e.preventDefault();
|
|
28
|
+
const success = await submit();
|
|
29
|
+
if (!success) { return; }
|
|
30
|
+
|
|
31
|
+
trackProgressiveProfilingSubmitClick({
|
|
32
|
+
isGenderSelected: !!values.gender,
|
|
33
|
+
isLevelOfEducationSelected: !!values.level_of_education,
|
|
34
|
+
host: window.location.origin,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
clearTrigger();
|
|
38
|
+
onClose();
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const handleSkip = () => {
|
|
42
|
+
trackProgressiveProfilingSkipLinkClick({ host: window.location.origin });
|
|
43
|
+
clearTrigger();
|
|
44
|
+
onClose();
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<ModalDialog
|
|
49
|
+
isOpen={isOpen}
|
|
50
|
+
onClose={() => {}}
|
|
51
|
+
hasCloseButton={false}
|
|
52
|
+
size="md"
|
|
53
|
+
title={formatMessage(messages['progressive.profiling.page.heading'])}
|
|
54
|
+
>
|
|
55
|
+
<ModalDialog.Header>
|
|
56
|
+
<ModalDialog.Title>
|
|
57
|
+
{formatMessage(messages['progressive.profiling.page.heading'])}
|
|
58
|
+
</ModalDialog.Title>
|
|
59
|
+
</ModalDialog.Header>
|
|
60
|
+
|
|
61
|
+
<ModalDialog.Body>
|
|
62
|
+
{error && (
|
|
63
|
+
<Alert variant="danger">
|
|
64
|
+
<Alert.Heading>{formatMessage(messages['welcome.page.error.heading'])}</Alert.Heading>
|
|
65
|
+
<p>{formatMessage(messages['welcome.page.error.message'])}</p>
|
|
66
|
+
</Alert>
|
|
67
|
+
)}
|
|
68
|
+
<Form id="profileForm" onSubmit={handleSubmit}>
|
|
69
|
+
{fieldList.map((fieldData) => (
|
|
70
|
+
<FormFieldRenderer
|
|
71
|
+
key={fieldData.name}
|
|
72
|
+
fieldData={fieldData}
|
|
73
|
+
value={values[fieldData.name]}
|
|
74
|
+
onChangeHandler={onChangeHandler}
|
|
75
|
+
/>
|
|
76
|
+
))}
|
|
77
|
+
|
|
78
|
+
{(getConfig().AUTHN_PROGRESSIVE_PROFILING_SUPPORT_LINK) && (
|
|
79
|
+
<div className="mt-2">
|
|
80
|
+
<Hyperlink
|
|
81
|
+
destination={getConfig().AUTHN_PROGRESSIVE_PROFILING_SUPPORT_LINK}
|
|
82
|
+
target="_blank"
|
|
83
|
+
showLaunchIcon={false}
|
|
84
|
+
onClick={() => trackProgressiveProfilingSupportLinkClick({ host: window.location.origin })}
|
|
85
|
+
>
|
|
86
|
+
{formatMessage(messages['optional.fields.information.link'])}
|
|
87
|
+
</Hyperlink>
|
|
88
|
+
</div>
|
|
89
|
+
)}
|
|
90
|
+
</Form>
|
|
91
|
+
</ModalDialog.Body>
|
|
92
|
+
<ModalDialog.Footer>
|
|
93
|
+
<Button variant="link" onClick={handleSkip} disabled={submitState === PENDING_STATE}>
|
|
94
|
+
{formatMessage(messages['optional.fields.skip.button'])}
|
|
95
|
+
</Button>
|
|
96
|
+
<Button variant="brand" type="submit" form="profileForm" disabled={loadState !== COMPLETE_STATE || submitState === PENDING_STATE}>
|
|
97
|
+
{formatMessage(messages['optional.fields.submit.button'])}
|
|
98
|
+
</Button>
|
|
99
|
+
</ModalDialog.Footer>
|
|
100
|
+
</ModalDialog>
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
ProgressiveProfilingModal.propTypes = {
|
|
105
|
+
isOpen: PropTypes.bool.isRequired,
|
|
106
|
+
onClose: PropTypes.func.isRequired,
|
|
107
|
+
clearTrigger: PropTypes.func.isRequired,
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export default ProgressiveProfilingModal;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { getConfig, snakeCaseObject } from '@edx/frontend-platform';
|
|
2
|
+
import { getAuthenticatedUser, getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
|
|
2
3
|
|
|
3
|
-
export async function saveProgressiveProfiling(
|
|
4
|
-
const payload = { ...values
|
|
4
|
+
export async function saveProgressiveProfiling(values, extendedProfileFieldNames = []) {
|
|
5
|
+
const payload = { ...values };
|
|
6
|
+
const extendedProfile = [];
|
|
7
|
+
const authenticatedUser = getAuthenticatedUser();
|
|
8
|
+
const client = getAuthenticatedHttpClient();
|
|
5
9
|
|
|
6
10
|
extendedProfileFieldNames.forEach((fieldName) => {
|
|
7
11
|
if (payload[fieldName] !== undefined && payload[fieldName] !== '') {
|
|
8
|
-
|
|
12
|
+
extendedProfile.push({
|
|
9
13
|
fieldName,
|
|
10
14
|
fieldValue: payload[fieldName],
|
|
11
15
|
});
|
|
@@ -14,8 +18,12 @@ export async function saveProgressiveProfiling(username, client, values, extende
|
|
|
14
18
|
delete payload[fieldName];
|
|
15
19
|
});
|
|
16
20
|
|
|
21
|
+
if (extendedProfile.length) {
|
|
22
|
+
payload.extendedProfile = extendedProfile;
|
|
23
|
+
}
|
|
24
|
+
|
|
17
25
|
await client.patch(
|
|
18
|
-
`${getConfig().LMS_BASE_URL}/api/user/v1/accounts/${username}`,
|
|
26
|
+
`${getConfig().LMS_BASE_URL}/api/user/v1/accounts/${authenticatedUser.username}`,
|
|
19
27
|
snakeCaseObject(payload),
|
|
20
28
|
{
|
|
21
29
|
headers: { 'Content-Type': 'application/merge-patch+json' },
|
|
@@ -1,57 +1,4 @@
|
|
|
1
1
|
export const progressiveProfilingFields = {
|
|
2
|
-
fields: {
|
|
3
|
-
gender: {
|
|
4
|
-
name: 'gender',
|
|
5
|
-
type: 'select',
|
|
6
|
-
label: 'Gender',
|
|
7
|
-
options: [
|
|
8
|
-
['f', 'Female'],
|
|
9
|
-
['m', 'Male'],
|
|
10
|
-
['o', 'Other'],
|
|
11
|
-
],
|
|
12
|
-
},
|
|
13
|
-
year_of_birth: {
|
|
14
|
-
name: 'year_of_birth',
|
|
15
|
-
type: 'select',
|
|
16
|
-
label: 'Year of Birth',
|
|
17
|
-
options: Array.from({ length: 100 }, (_, i) => {
|
|
18
|
-
const year = new Date().getFullYear() - i;
|
|
19
|
-
return [year.toString(), year.toString()];
|
|
20
|
-
}),
|
|
21
|
-
},
|
|
22
|
-
level_of_education: {
|
|
23
|
-
name: 'level_of_education',
|
|
24
|
-
type: 'select',
|
|
25
|
-
label: 'Level of Education',
|
|
26
|
-
options: [
|
|
27
|
-
['p', 'Doctorate'],
|
|
28
|
-
['m', 'Master\'s or professional degree'],
|
|
29
|
-
['b', 'Bachelor\'s Degree'],
|
|
30
|
-
['a', 'Associate Degree'],
|
|
31
|
-
['hs', 'Secondary/High School'],
|
|
32
|
-
['jhs', 'Junior secondary/junior high/middle school'],
|
|
33
|
-
['el', 'Elementary/primary school'],
|
|
34
|
-
['none', 'No formal education'],
|
|
35
|
-
['other', 'Other education'],
|
|
36
|
-
],
|
|
37
|
-
},
|
|
38
|
-
work_experience: {
|
|
39
|
-
name: 'work_experience',
|
|
40
|
-
type: 'checkbox',
|
|
41
|
-
label: 'Work Experience',
|
|
42
|
-
options: [
|
|
43
|
-
['0', 'No Experience'],
|
|
44
|
-
['1', '1-2 Years'],
|
|
45
|
-
['3', '3-5 Years'],
|
|
46
|
-
['5', '5+ Years'],
|
|
47
|
-
],
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
extendedProfile: ['work_experience'],
|
|
51
|
-
redirectUrl: '',
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export const progressiveProfilingFieldsReplica = {
|
|
55
2
|
fields: {
|
|
56
3
|
gender: {
|
|
57
4
|
name: 'gender',
|
|
@@ -80,6 +27,6 @@ export const progressiveProfilingFieldsReplica = {
|
|
|
80
27
|
],
|
|
81
28
|
},
|
|
82
29
|
},
|
|
83
|
-
extendedProfile: [
|
|
30
|
+
extendedProfile: [],
|
|
84
31
|
redirectUrl: '',
|
|
85
32
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { PROGRESSIVE_PROFILING_QUERY_PARAM } from '../utils/constants';
|
|
3
|
+
|
|
4
|
+
export default function useClearProgressiveProfilingQueryParams() {
|
|
5
|
+
return useCallback(() => {
|
|
6
|
+
const currentUrl = new URL(window.location.href);
|
|
7
|
+
|
|
8
|
+
currentUrl.searchParams.delete(PROGRESSIVE_PROFILING_QUERY_PARAM);
|
|
9
|
+
|
|
10
|
+
window.history.replaceState({}, '', currentUrl.toString());
|
|
11
|
+
}, []);
|
|
12
|
+
}
|
|
@@ -3,14 +3,14 @@ import {
|
|
|
3
3
|
COMPLETE_STATE, DEFAULT_STATE, PENDING_STATE,
|
|
4
4
|
} from '../utils/constants';
|
|
5
5
|
import { saveProgressiveProfiling } from '../api/service';
|
|
6
|
-
import {
|
|
6
|
+
import { progressiveProfilingFields } from '../data/progressiveProfilingFields';
|
|
7
7
|
|
|
8
|
-
export default function useProgressiveProfilingForm(
|
|
8
|
+
export default function useProgressiveProfilingForm() {
|
|
9
9
|
const [submitState, setSubmitState] = useState(DEFAULT_STATE);
|
|
10
10
|
const [error, setError] = useState(null);
|
|
11
11
|
const [values, setValues] = useState({});
|
|
12
12
|
|
|
13
|
-
const fieldData =
|
|
13
|
+
const fieldData = progressiveProfilingFields;
|
|
14
14
|
|
|
15
15
|
const fieldList = useMemo(
|
|
16
16
|
() => Object.keys(fieldData.fields).map((key) => fieldData.fields[key]),
|
|
@@ -31,7 +31,7 @@ export default function useProgressiveProfilingForm(username, client) {
|
|
|
31
31
|
try {
|
|
32
32
|
setSubmitState(PENDING_STATE);
|
|
33
33
|
setError(null);
|
|
34
|
-
await saveProgressiveProfiling(
|
|
34
|
+
await saveProgressiveProfiling(values, fieldData.extendedProfile || []);
|
|
35
35
|
setSubmitState(COMPLETE_STATE);
|
|
36
36
|
return true;
|
|
37
37
|
} catch (err) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PROGRESSIVE_PROFILING_QUERY_PARAM } from '../utils/constants';
|
|
2
|
+
|
|
3
|
+
export default function useProgressiveProfilingTrigger() {
|
|
4
|
+
const params = new URLSearchParams(window.location.search);
|
|
5
|
+
|
|
6
|
+
return {
|
|
7
|
+
shouldOpen: params.get(PROGRESSIVE_PROFILING_QUERY_PARAM) === 'true',
|
|
8
|
+
};
|
|
9
|
+
}
|
package/src/setupTest.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import '@testing-library/jest-dom';
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import { render as rtlRender } from '@testing-library/react';
|
|
4
|
+
import { render as rtlRender } from '@testing-library/react';
|
|
5
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
5
6
|
import { getConfig, mergeConfig } from '@edx/frontend-platform';
|
|
6
7
|
import { configure as configureI18n, IntlProvider } from '@edx/frontend-platform/i18n';
|
|
7
8
|
import { configure as configureLogging } from '@edx/frontend-platform/logging';
|
|
@@ -35,13 +36,13 @@ const supressWarningBlock = (callback) => {
|
|
|
35
36
|
};
|
|
36
37
|
/* eslint-enable no-console */
|
|
37
38
|
|
|
39
|
+
/* eslint-disable no-console */
|
|
38
40
|
class MockLoggingService {
|
|
39
|
-
// eslint-disable-next-line no-console
|
|
40
41
|
logInfo = jest.fn(infoString => console.log(infoString));
|
|
41
42
|
|
|
42
|
-
// eslint-disable-next-line no-console
|
|
43
43
|
logError = jest.fn(errorString => console.log(errorString));
|
|
44
44
|
}
|
|
45
|
+
/* eslint-enable no-console */
|
|
45
46
|
|
|
46
47
|
export const initializeIntl = () => {
|
|
47
48
|
const loggingService = configureLogging(MockLoggingService, {
|
|
@@ -64,12 +65,23 @@ function render(
|
|
|
64
65
|
...renderOptions
|
|
65
66
|
} = {},
|
|
66
67
|
) {
|
|
68
|
+
const queryClient = new QueryClient({
|
|
69
|
+
defaultOptions: {
|
|
70
|
+
queries: {
|
|
71
|
+
retry: false,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
/* eslint-disable react/jsx-filename-extension */
|
|
67
77
|
const Wrapper = ({ children }) => (
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
78
|
+
<QueryClientProvider client={queryClient}>
|
|
79
|
+
<IntlProvider locale="en">
|
|
80
|
+
{children}
|
|
81
|
+
</IntlProvider>
|
|
82
|
+
</QueryClientProvider>
|
|
72
83
|
);
|
|
84
|
+
/* eslint-enable react/jsx-filename-extension */
|
|
73
85
|
|
|
74
86
|
Wrapper.propTypes = {
|
|
75
87
|
children: PropTypes.node.isRequired,
|
|
@@ -7,6 +7,7 @@ export const eventNames = {
|
|
|
7
7
|
disablePostRegistrationRecommendations: 'edx.bi.user.recommendations.not.enabled',
|
|
8
8
|
progressiveProfilingSupportLinkClick: 'edx.bi.welcome.page.support.link.clicked',
|
|
9
9
|
loginAndRegistration: 'login_and_registration',
|
|
10
|
+
progressiveProfilingQuestionaireModalFormOpened: 'edx.bi.welcome.page.questionaire.modal.opened',
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
// Event link tracker for Progressive profiling skip button click
|
|
@@ -36,3 +37,9 @@ export const trackProgressiveProfilingSupportLinkClick = () => createEventTracke
|
|
|
36
37
|
eventNames.progressiveProfilingSupportLinkClick,
|
|
37
38
|
{},
|
|
38
39
|
)();
|
|
40
|
+
|
|
41
|
+
// Tracks the progressive profiling modal opened with the questionaire form.
|
|
42
|
+
export const trackProgressiveProfilingQuestionaireModalFormOpened = (evenProperties) => createEventTracker(
|
|
43
|
+
eventNames.progressiveProfilingQuestionaireModalFormOpened,
|
|
44
|
+
{ ...evenProperties },
|
|
45
|
+
)();
|
|
@@ -6,8 +6,8 @@ import { useIntl } from '@edx/frontend-platform/i18n';
|
|
|
6
6
|
import { Button } from '@openedx/paragon';
|
|
7
7
|
import { Locked } from '@openedx/paragon/icons';
|
|
8
8
|
|
|
9
|
+
import { useCourseData, useCourseTrackingEvent } from 'hooks';
|
|
9
10
|
import { upgradeClicked } from '../tracking/trackers/upgradeButton';
|
|
10
|
-
import reduxHooks from '../data/redux/hooks';
|
|
11
11
|
|
|
12
12
|
import { useIsCollapsed, useActionDisabledState } from './data/hooks';
|
|
13
13
|
import messages from './messages';
|
|
@@ -15,12 +15,16 @@ import messages from './messages';
|
|
|
15
15
|
export const UpgradeButton = ({ cardId }) => {
|
|
16
16
|
const { formatMessage } = useIntl();
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
const courseRun = useCourseData(cardId)?.courseRun || {};
|
|
19
|
+
const { upgradeUrl } = courseRun;
|
|
20
|
+
const org = courseRun.org || '';
|
|
21
|
+
const courseName = courseRun.title || '';
|
|
19
22
|
const { disableUpgradeCourse } = useActionDisabledState(cardId);
|
|
20
|
-
|
|
21
|
-
const trackUpgradeClick = reduxHooks.useTrackCourseEvent(
|
|
23
|
+
const trackUpgradeClick = useCourseTrackingEvent(
|
|
22
24
|
upgradeClicked,
|
|
23
25
|
cardId,
|
|
26
|
+
org,
|
|
27
|
+
courseName,
|
|
24
28
|
upgradeUrl,
|
|
25
29
|
);
|
|
26
30
|
|
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
/* eslint-disable import/no-named-as-default */
|
|
3
3
|
import { shallow } from '@edx/react-unit-test-utils';
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import { useCourseData, useCourseTrackingEvent } from 'hooks';
|
|
6
6
|
import { useActionDisabledState } from './data/hooks';
|
|
7
7
|
import UpgradeButton from './UpgradeButton';
|
|
8
8
|
import { upgradeClicked } from '../tracking/trackers/upgradeButton';
|
|
9
9
|
|
|
10
|
+
const mockTrackUpgradeClick = jest.fn().mockName('trackUpgradeClick');
|
|
11
|
+
|
|
10
12
|
jest.mock('../tracking/trackers/upgradeButton', () => ({
|
|
11
13
|
upgradeClicked: jest.fn().mockName('segment.trackUpgradeClicked'),
|
|
12
14
|
}));
|
|
13
15
|
|
|
14
|
-
jest.mock('
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
),
|
|
19
|
-
}));
|
|
16
|
+
jest.mock('hooks', () => ({
|
|
17
|
+
useCourseData: jest.fn(),
|
|
18
|
+
useCourseTrackingEvent: jest.fn(() => mockTrackUpgradeClick),
|
|
19
|
+
}), { virtual: true });
|
|
20
20
|
|
|
21
21
|
jest.mock('./data/hooks', () => ({
|
|
22
22
|
useActionDisabledState: jest.fn(() => ({ disableUpgradeCourse: false })),
|
|
@@ -28,17 +28,26 @@ describe('UpgradeButton', () => {
|
|
|
28
28
|
cardId: 'cardId',
|
|
29
29
|
};
|
|
30
30
|
const upgradeUrl = 'upgradeUrl';
|
|
31
|
-
|
|
31
|
+
const org = 'edX';
|
|
32
|
+
const courseName = 'Demo Course';
|
|
33
|
+
|
|
34
|
+
beforeEach(() => {
|
|
35
|
+
useCourseData.mockReturnValue({ courseRun: { upgradeUrl, org, title: courseName } });
|
|
36
|
+
});
|
|
37
|
+
|
|
32
38
|
describe('snapshot', () => {
|
|
33
39
|
test('can upgrade', () => {
|
|
34
40
|
const wrapper = shallow(<UpgradeButton {...props} />);
|
|
35
41
|
expect(wrapper.snapshot).toMatchSnapshot();
|
|
36
42
|
expect(wrapper.instance.props.disabled).toEqual(false);
|
|
37
|
-
expect(
|
|
43
|
+
expect(useCourseTrackingEvent).toHaveBeenCalledWith(
|
|
38
44
|
upgradeClicked,
|
|
39
45
|
props.cardId,
|
|
46
|
+
org,
|
|
47
|
+
courseName,
|
|
40
48
|
upgradeUrl,
|
|
41
|
-
)
|
|
49
|
+
);
|
|
50
|
+
expect(wrapper.instance.props.onClick).toEqual(mockTrackUpgradeClick);
|
|
42
51
|
});
|
|
43
52
|
test('cannot upgrade', () => {
|
|
44
53
|
useActionDisabledState.mockReturnValueOnce({ disableUpgradeCourse: true });
|
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
/* eslint-disable import/no-named-as-default-member */
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
|
+
|
|
6
|
+
import { useCourseData, useEntitlementInfo } from 'hooks';
|
|
5
7
|
import UpgradeButton from './UpgradeButton';
|
|
6
|
-
import reduxHooks from '../data/redux/hooks';
|
|
7
8
|
|
|
8
9
|
const UpgradeButtonWrapper = ({ cardId }) => {
|
|
9
|
-
const
|
|
10
|
+
const courseData = useCourseData(cardId);
|
|
11
|
+
const { isEntitlement } = useEntitlementInfo(courseData);
|
|
10
12
|
const {
|
|
11
13
|
isVerified,
|
|
12
14
|
isExecEd2UCourse,
|
|
13
|
-
} =
|
|
15
|
+
} = courseData?.enrollment || {};
|
|
14
16
|
|
|
15
17
|
if (!(isEntitlement || isVerified || isExecEd2UCourse)) {
|
|
16
18
|
return <UpgradeButton cardId={cardId} />;
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
/* eslint-disable import/no-named-as-default-member */
|
|
2
2
|
import { shallow } from '@edx/react-unit-test-utils';
|
|
3
|
-
import
|
|
3
|
+
import { useCourseData, useEntitlementInfo } from 'hooks';
|
|
4
4
|
import UpgradeButtonWrapper from './UpgradeButtonWrapper';
|
|
5
5
|
|
|
6
|
-
jest.mock('
|
|
7
|
-
|
|
8
|
-
isVerified: false,
|
|
9
|
-
isExecEd2UCourse: false,
|
|
6
|
+
jest.mock('hooks', () => ({
|
|
7
|
+
useCourseData: jest.fn(() => ({
|
|
8
|
+
enrollment: { isVerified: false, isExecEd2UCourse: false },
|
|
10
9
|
})),
|
|
11
|
-
|
|
10
|
+
useEntitlementInfo: jest.fn(() => ({
|
|
12
11
|
isEntitlement: false,
|
|
13
12
|
})),
|
|
14
|
-
}));
|
|
13
|
+
}), { virtual: true });
|
|
15
14
|
|
|
16
15
|
describe('UpgradeButtonWrapper', () => {
|
|
17
16
|
const props = {
|
|
@@ -23,11 +22,10 @@ describe('UpgradeButtonWrapper', () => {
|
|
|
23
22
|
expect(wrapper.snapshot).toMatchSnapshot();
|
|
24
23
|
});
|
|
25
24
|
test('is not visible', () => {
|
|
26
|
-
|
|
27
|
-
isVerified: true,
|
|
28
|
-
isExecEd2UCourse: true,
|
|
25
|
+
useCourseData.mockReturnValue({
|
|
26
|
+
enrollment: { isVerified: true, isExecEd2UCourse: true },
|
|
29
27
|
});
|
|
30
|
-
|
|
28
|
+
useEntitlementInfo.mockReturnValue({
|
|
31
29
|
isEntitlement: true,
|
|
32
30
|
});
|
|
33
31
|
const wrapper = shallow(<UpgradeButtonWrapper {...props} />);
|
|
@@ -6,15 +6,7 @@ exports[`UpgradeButton snapshot can upgrade 1`] = `
|
|
|
6
6
|
disabled={false}
|
|
7
7
|
href="upgradeUrl"
|
|
8
8
|
iconBefore={[Function]}
|
|
9
|
-
onClick={
|
|
10
|
-
{
|
|
11
|
-
"trackCourseEvent": {
|
|
12
|
-
"cardId": "cardId",
|
|
13
|
-
"eventName": [MockFunction segment.trackUpgradeClicked],
|
|
14
|
-
"upgradeUrl": "upgradeUrl",
|
|
15
|
-
},
|
|
16
|
-
}
|
|
17
|
-
}
|
|
9
|
+
onClick={[MockFunction trackUpgradeClick]}
|
|
18
10
|
variant="outline-primary"
|
|
19
11
|
>
|
|
20
12
|
Upgrade
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable import/no-named-as-default-member */
|
|
2
2
|
import { useWindowSize, breakpoints } from '@openedx/paragon';
|
|
3
|
-
import
|
|
3
|
+
import { useCourseData, useIsMasquerading } from 'hooks';
|
|
4
4
|
|
|
5
5
|
export const useIsCollapsed = () => {
|
|
6
6
|
const { width } = useWindowSize();
|
|
@@ -8,10 +8,10 @@ export const useIsCollapsed = () => {
|
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
export const useActionDisabledState = (cardId) => {
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const { upgradeUrl } =
|
|
11
|
+
const isMasquerading = useIsMasquerading();
|
|
12
|
+
const courseData = useCourseData(cardId);
|
|
13
|
+
const { canUpgrade } = courseData?.enrollment || {};
|
|
14
|
+
const { upgradeUrl } = courseData?.courseRun || {};
|
|
15
15
|
|
|
16
16
|
const disableUpgradeCourse = !upgradeUrl || (isMasquerading && !canUpgrade);
|
|
17
17
|
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { useWindowSize, breakpoints } from '@openedx/paragon';
|
|
2
2
|
import { useIsCollapsed } from './hooks';
|
|
3
3
|
|
|
4
|
+
jest.mock('hooks', () => ({
|
|
5
|
+
useCourseData: jest.fn(),
|
|
6
|
+
useIsMasquerading: jest.fn(),
|
|
7
|
+
}), { virtual: true });
|
|
8
|
+
|
|
4
9
|
jest.mock('@openedx/paragon', () => ({
|
|
5
10
|
...jest.requireActual('@openedx/paragon'),
|
|
6
11
|
useWindowSize: jest.fn(),
|
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Provider } from 'react-redux';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
1
|
import UpgradeButtonWrapper from './UpgradeButtonWrapper';
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
const { store } = content;
|
|
8
|
-
return (
|
|
9
|
-
<Provider store={store}>
|
|
10
|
-
<UpgradeButtonWrapper cardId={cardId} />
|
|
11
|
-
</Provider>
|
|
12
|
-
);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
UpgradeButtonWithProvider.propTypes = {
|
|
16
|
-
content: PropTypes.shape({
|
|
17
|
-
store: PropTypes.shape({}),
|
|
18
|
-
}),
|
|
19
|
-
cardId: PropTypes.string.isRequired,
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default UpgradeButtonWithProvider;
|
|
3
|
+
export default UpgradeButtonWrapper;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = exports.EXECUTIVE_EDUCATION_COURSE_MODES = exports.COURSE_MODES = void 0;
|
|
7
|
-
// Constants related to courses
|
|
8
|
-
const COURSE_MODES = exports.COURSE_MODES = {
|
|
9
|
-
EXECUTIVE_EDUCATION: 'executive-education',
|
|
10
|
-
PAID_EXECUTIVE_EDUCATION: 'paid-executive-education',
|
|
11
|
-
UNPAID_EXECUTIVE_EDUCATION: 'unpaid-executive-education'
|
|
12
|
-
};
|
|
13
|
-
const EXECUTIVE_EDUCATION_COURSE_MODES = exports.EXECUTIVE_EDUCATION_COURSE_MODES = [COURSE_MODES.EXECUTIVE_EDUCATION, COURSE_MODES.PAID_EXECUTIVE_EDUCATION, COURSE_MODES.UNPAID_EXECUTIVE_EDUCATION];
|
|
14
|
-
var _default = exports.default = {
|
|
15
|
-
COURSE_MODES,
|
|
16
|
-
EXECUTIVE_EDUCATION_COURSE_MODES
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["COURSE_MODES","exports","EXECUTIVE_EDUCATION","PAID_EXECUTIVE_EDUCATION","UNPAID_EXECUTIVE_EDUCATION","EXECUTIVE_EDUCATION_COURSE_MODES","_default","default"],"sources":["../../../../src/data/redux/app/constants.js"],"sourcesContent":["// Constants related to courses\nexport const COURSE_MODES = {\n EXECUTIVE_EDUCATION: 'executive-education',\n PAID_EXECUTIVE_EDUCATION: 'paid-executive-education',\n UNPAID_EXECUTIVE_EDUCATION: 'unpaid-executive-education',\n};\n\nexport const EXECUTIVE_EDUCATION_COURSE_MODES = [\n COURSE_MODES.EXECUTIVE_EDUCATION,\n COURSE_MODES.PAID_EXECUTIVE_EDUCATION,\n COURSE_MODES.UNPAID_EXECUTIVE_EDUCATION,\n];\n\nexport default {\n COURSE_MODES,\n EXECUTIVE_EDUCATION_COURSE_MODES,\n};\n"],"mappings":";;;;;;AAAA;AACO,MAAMA,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG;EAC1BE,mBAAmB,EAAE,qBAAqB;EAC1CC,wBAAwB,EAAE,0BAA0B;EACpDC,0BAA0B,EAAE;AAC9B,CAAC;AAEM,MAAMC,gCAAgC,GAAAJ,OAAA,CAAAI,gCAAA,GAAG,CAC9CL,YAAY,CAACE,mBAAmB,EAChCF,YAAY,CAACG,wBAAwB,EACrCH,YAAY,CAACI,0BAA0B,CACxC;AAAC,IAAAE,QAAA,GAAAL,OAAA,CAAAM,OAAA,GAEa;EACbP,YAAY;EACZK;AACF,CAAC","ignoreList":[]}
|