@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
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { RequestStates, RequestKeys } from './constants';
|
|
2
|
-
|
|
3
|
-
export const requestStatus = (state, { requestKey }) => state.requests[requestKey];
|
|
4
|
-
|
|
5
|
-
const statusSelector = (fn) => (requestKey) => (state) => fn(state.requests[requestKey]);
|
|
6
|
-
|
|
7
|
-
export const isInactive = ({ status }) => status === RequestStates.inactive;
|
|
8
|
-
export const isPending = ({ status }) => status === RequestStates.pending;
|
|
9
|
-
export const isCompleted = ({ status }) => status === RequestStates.completed;
|
|
10
|
-
export const isFailed = ({ status }) => status === RequestStates.failed;
|
|
11
|
-
export const error = (request) => request.error;
|
|
12
|
-
export const errorStatus = (request) => request.error?.response?.status;
|
|
13
|
-
export const errorCode = (request) => request.error?.response?.data;
|
|
14
|
-
|
|
15
|
-
export const data = (request) => request.data;
|
|
16
|
-
|
|
17
|
-
export const masquerade = (state) => {
|
|
18
|
-
const request = requestStatus(state, { requestKey: RequestKeys.masquerade });
|
|
19
|
-
return {
|
|
20
|
-
isMasquerading: isCompleted(request),
|
|
21
|
-
isMasqueradingFailed: isFailed(request),
|
|
22
|
-
isMasqueradingPending: isPending(request),
|
|
23
|
-
masqueradeErrorStatus: errorStatus(request),
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export default {
|
|
28
|
-
requestStatus,
|
|
29
|
-
isInactive: statusSelector(isInactive),
|
|
30
|
-
isPending: statusSelector(isPending),
|
|
31
|
-
isCompleted: statusSelector(isCompleted),
|
|
32
|
-
isFailed: statusSelector(isFailed),
|
|
33
|
-
error: statusSelector(error),
|
|
34
|
-
errorCode: statusSelector(errorCode),
|
|
35
|
-
errorStatus: statusSelector(errorStatus),
|
|
36
|
-
data: statusSelector(data),
|
|
37
|
-
masquerade,
|
|
38
|
-
};
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-named-as-default-member */
|
|
2
|
-
import { RequestStates, RequestKeys } from './constants';
|
|
3
|
-
|
|
4
|
-
import selectors from './selectors';
|
|
5
|
-
|
|
6
|
-
const requestKey = 'my-test-request-key';
|
|
7
|
-
const requestData = { some: 'request-data' };
|
|
8
|
-
const inactiveRequest = { status: RequestStates.inactive, some: 'request-data' };
|
|
9
|
-
const pendingRequest = { status: RequestStates.pending, some: 'request-data' };
|
|
10
|
-
const completedRequest = { status: RequestStates.completed, some: 'request-data' };
|
|
11
|
-
const failedRequest = { status: RequestStates.failed, some: 'request-data' };
|
|
12
|
-
|
|
13
|
-
const testValue = 'my-test-value';
|
|
14
|
-
|
|
15
|
-
const testErrorValue = {
|
|
16
|
-
response: {
|
|
17
|
-
status: 500,
|
|
18
|
-
data: 'my-test-error',
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const testState = {
|
|
23
|
-
requests: {
|
|
24
|
-
[requestKey]: requestData,
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
const mockUseSelector = (selector, state) => selector(state);
|
|
28
|
-
const genRequests = (request) => ({
|
|
29
|
-
requests: { [requestKey]: request },
|
|
30
|
-
});
|
|
31
|
-
const select = (selector, request) => (
|
|
32
|
-
mockUseSelector(selector(requestKey), genRequests(request))
|
|
33
|
-
);
|
|
34
|
-
describe('requests selectors unit tests', () => {
|
|
35
|
-
test('requestStatus returns data associated with given key', () => {
|
|
36
|
-
expect(selectors.requestStatus(testState, { requestKey })).toEqual(requestData);
|
|
37
|
-
});
|
|
38
|
-
const testStatusSelector = (selector, matchingRequest) => {
|
|
39
|
-
expect(mockUseSelector(selector(requestKey), testState)).toEqual(false);
|
|
40
|
-
expect(mockUseSelector(
|
|
41
|
-
selector(requestKey),
|
|
42
|
-
{ requests: { [requestKey]: matchingRequest } },
|
|
43
|
-
)).toEqual(true);
|
|
44
|
-
};
|
|
45
|
-
test('isInactive returns true iff the given request is inactive', () => {
|
|
46
|
-
testStatusSelector(selectors.isInactive, inactiveRequest);
|
|
47
|
-
});
|
|
48
|
-
test('isPending returns true iff the given request is pending', () => {
|
|
49
|
-
testStatusSelector(selectors.isPending, pendingRequest);
|
|
50
|
-
});
|
|
51
|
-
test('isCompleted returns true iff the given request is completed', () => {
|
|
52
|
-
testStatusSelector(selectors.isCompleted, completedRequest);
|
|
53
|
-
});
|
|
54
|
-
test('isFailed returns true iff the given request is failed', () => {
|
|
55
|
-
testStatusSelector(selectors.isFailed, failedRequest);
|
|
56
|
-
});
|
|
57
|
-
test('error returns the error from the request', () => {
|
|
58
|
-
expect(select(selectors.error, { error: testValue })).toEqual(testValue);
|
|
59
|
-
});
|
|
60
|
-
test('errorStatus returns the error response status', () => {
|
|
61
|
-
expect(select(selectors.errorStatus, {})).toEqual(undefined);
|
|
62
|
-
expect(select(selectors.errorStatus, { error: {} })).toEqual(undefined);
|
|
63
|
-
expect(select(selectors.errorStatus, { error: { response: {} } })).toEqual(undefined);
|
|
64
|
-
expect(select(selectors.errorStatus, { error: { response: { status: testValue } } }))
|
|
65
|
-
.toEqual(testValue);
|
|
66
|
-
expect(select(selectors.errorStatus, { error: testErrorValue })).toEqual(
|
|
67
|
-
testErrorValue.response.status,
|
|
68
|
-
);
|
|
69
|
-
});
|
|
70
|
-
test('errorCode returns the error response data', () => {
|
|
71
|
-
expect(select(selectors.errorCode, {})).toEqual(undefined);
|
|
72
|
-
expect(select(selectors.errorCode, { error: {} })).toEqual(undefined);
|
|
73
|
-
expect(select(selectors.errorCode, { error: { response: {} } })).toEqual(undefined);
|
|
74
|
-
expect(select(selectors.errorCode, { error: { response: { data: testValue } } }))
|
|
75
|
-
.toEqual(testValue);
|
|
76
|
-
expect(select(selectors.errorCode, { error: testErrorValue })).toEqual(
|
|
77
|
-
testErrorValue.response.data,
|
|
78
|
-
);
|
|
79
|
-
});
|
|
80
|
-
test('data reurns the request data', () => {
|
|
81
|
-
expect(select(selectors.data, { data: testValue })).toEqual(testValue);
|
|
82
|
-
});
|
|
83
|
-
test('masquerade returns the masquerade data', () => {
|
|
84
|
-
const mockResponse = (response) => ({
|
|
85
|
-
requests: {
|
|
86
|
-
[RequestKeys.masquerade]: response,
|
|
87
|
-
},
|
|
88
|
-
});
|
|
89
|
-
expect(selectors.masquerade(mockResponse(completedRequest))).toEqual({
|
|
90
|
-
isMasquerading: true,
|
|
91
|
-
isMasqueradingFailed: false,
|
|
92
|
-
isMasqueradingPending: false,
|
|
93
|
-
masqueradeErrorStatus: undefined,
|
|
94
|
-
});
|
|
95
|
-
expect(selectors.masquerade(mockResponse(pendingRequest))).toEqual({
|
|
96
|
-
isMasquerading: false,
|
|
97
|
-
isMasqueradingFailed: false,
|
|
98
|
-
isMasqueradingPending: true,
|
|
99
|
-
masqueradeErrorStatus: undefined,
|
|
100
|
-
});
|
|
101
|
-
expect(selectors.masquerade(mockResponse({
|
|
102
|
-
...failedRequest,
|
|
103
|
-
error: testErrorValue,
|
|
104
|
-
}))).toEqual({
|
|
105
|
-
isMasquerading: false,
|
|
106
|
-
isMasqueradingFailed: true,
|
|
107
|
-
isMasqueradingPending: false,
|
|
108
|
-
masqueradeErrorStatus: testErrorValue.response.status,
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
});
|