Skip to content

Commit 3ea088e

Browse files
committed
Revert "fix: PR requests"
This reverts commit 7678313.
1 parent 4a18c89 commit 3ea088e

File tree

8 files changed

+39
-12
lines changed

8 files changed

+39
-12
lines changed

src/containers/Dashboard/__snapshots__/index.test.jsx.snap

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`Dashboard snapshots courses loaded, show select session modal snapshot 1`] = `
3+
exports[`Dashboard snapshots courses loaded, show select session modal, no available dashboards snapshot 1`] = `
44
<div
55
className="d-flex flex-column p-2 pt-0"
66
id="dashboard-container"
@@ -11,7 +11,6 @@ exports[`Dashboard snapshots courses loaded, show select session modal snapshot
1111
test-page-title
1212
</h1>
1313
<Fragment>
14-
<DashboardModalSlot />
1514
<SelectSessionModal />
1615
</Fragment>
1716
<div
@@ -44,7 +43,7 @@ exports[`Dashboard snapshots courses still loading snapshot 1`] = `
4443
</div>
4544
`;
4645

47-
exports[`Dashboard snapshots there are no courses snapshot 1`] = `
46+
exports[`Dashboard snapshots there are no courses, there ARE available dashboards snapshot 1`] = `
4847
<div
4948
className="d-flex flex-column p-2 pt-0"
5049
id="dashboard-container"
@@ -55,7 +54,7 @@ exports[`Dashboard snapshots there are no courses snapshot 1`] = `
5554
test-page-title
5655
</h1>
5756
<Fragment>
58-
<DashboardModalSlot />
57+
<DashboardModal />
5958
</Fragment>
6059
<div
6160
data-testid="dashboard-content"

src/containers/Dashboard/index.test.jsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { reduxHooks } from 'hooks';
44

55
import SelectSessionModal from 'containers/SelectSessionModal';
66
import CoursesPanel from 'containers/CoursesPanel';
7+
import DashboardModalSlot from 'plugin-slots/DashboardModalSlot';
78

89
import DashboardLayout from './DashboardLayout';
910
import LoadingView from './LoadingView';
@@ -67,6 +68,7 @@ describe('Dashboard', () => {
6768
const testView = ({
6869
props,
6970
content: [contentName, contentEl],
71+
showEnterpriseModal,
7072
showSelectSessionModal,
7173
}) => {
7274
beforeEach(() => { wrapper = createWrapper(props); });
@@ -75,6 +77,10 @@ describe('Dashboard', () => {
7577
it(`renders ${contentName}`, () => {
7678
testContent(contentEl);
7779
});
80+
it(`${renderString(showEnterpriseModal)} dashboard modal`, () => {
81+
expect(wrapper.instance.findByType(DashboardModalSlot).length)
82+
.toEqual(showEnterpriseModal ? 1 : 0);
83+
});
7884
it(`${renderString(showSelectSessionModal)} select session modal`, () => {
7985
expect(wrapper.instance.findByType(SelectSessionModal).length).toEqual(showSelectSessionModal ? 1 : 0);
8086
});
@@ -87,6 +93,7 @@ describe('Dashboard', () => {
8793
showSelectSessionModal: false,
8894
},
8995
content: ['LoadingView', <LoadingView />],
96+
showEnterpriseModal: false,
9097
showSelectSessionModal: false,
9198
});
9299
});
@@ -101,6 +108,7 @@ describe('Dashboard', () => {
101108
content: ['LoadedView', (
102109
<DashboardLayout><CoursesPanel /></DashboardLayout>
103110
)],
111+
showEnterpriseModal: false,
104112
showSelectSessionModal: true,
105113
});
106114
});
@@ -115,6 +123,7 @@ describe('Dashboard', () => {
115123
content: ['Dashboard layout with no courses sidebar and content', (
116124
<DashboardLayout><CoursesPanel /></DashboardLayout>
117125
)],
126+
showEnterpriseModal: true,
118127
showSelectSessionModal: false,
119128
});
120129
});

src/data/redux/app/selectors/appSelectors.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ export const numCourses = createSelector(
1010
(courseData) => Object.keys(courseData).length,
1111
);
1212
export const hasCourses = createSelector([module.numCourses], (num) => num > 0);
13-
13+
export const hasAvailableDashboards = createSelector(
14+
[simpleSelectors.enterpriseDashboard],
15+
(data) => data !== null && data.isLearnerPortalEnabled === true,
16+
);
1417
export const showSelectSessionModal = createSelector(
1518
[simpleSelectors.selectSessionModal],
1619
(data) => data.cardId != null,
@@ -19,5 +22,6 @@ export const showSelectSessionModal = createSelector(
1922
export default StrictDict({
2023
numCourses,
2124
hasCourses,
25+
hasAvailableDashboards,
2226
showSelectSessionModal,
2327
});

src/data/redux/app/selectors/appSelectors.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ describe('basic app selectors', () => {
1717
expect(cb(0)).toEqual(false);
1818
});
1919
});
20+
describe('hasAvailableDashboards', () => {
21+
it('returns true iff the enterpriseDashboard field is populated and learner portal is enabled', () => {
22+
const { preSelectors, cb } = appSelectors.hasAvailableDashboards;
23+
expect(preSelectors).toEqual([simpleSelectors.enterpriseDashboard]);
24+
expect(cb({ isLearnerPortalEnabled: true })).toEqual(true);
25+
expect(cb({ isLearnerPortalEnabled: false })).toEqual(false);
26+
expect(cb(null)).toEqual(false);
27+
});
28+
});
2029
describe('showSelectSessionModal', () => {
2130
it('returns true if the selectSessionModal cardId is not null', () => {
2231
const { preSelectors, cb } = appSelectors.showSelectSessionModal;

src/data/redux/app/selectors/simpleSelectors.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ describe('app simple selectors', () => {
3636
expect(preSelectors).toEqual([appSelector]);
3737
expect(cb(testState.app)).toEqual(testString);
3838
});
39+
test('enterpriseDashboard returns empty object if data returns null', () => {
40+
testState = { app: { enterpriseDashboard: null } };
41+
const { preSelectors, cb } = simpleSelectors.enterpriseDashboard;
42+
expect(preSelectors).toEqual([appSelector]);
43+
expect(cb(testState.app)).toEqual({});
44+
});
3945
describe('cardSimpleSelectors', () => {
4046
keys = keyStore(cardSimpleSelectors);
4147
test.each([

src/plugin-slots/DashboardModalSlot/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
# Dashboard Modal Slot
1+
# Course Card Action Slot
22

33
### Slot ID: `dashboard_modal_slot`
44

55
## Description
66

7-
This slot is used for the modal on a dashboard.
7+
This slot is used for the modal on a dashboard that appears on initial load.
88
The following `env.config.jsx` will render the modal.
99

1010
## Example
1111

12-
Learner dashboard will show modal
13-
![Screenshot of the dashboard modal](./images/dashboard_modal_slot.png)
12+
Learner dashboard will show modal on initial load
13+
![Screenshot of the dashboard modal](./images/widget_sidebar_slot.png)
1414

1515
```js
1616
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework';
@@ -27,7 +27,7 @@ const config = {
2727
type: DIRECT_PLUGIN,
2828
priority: 60,
2929
RenderWidget:
30-
<ModalDialog title="Modal that appears on learner dashboard" />,
30+
<ModalDialog title="Modal that appears on initial render of learner dashboard" />,
3131
},
3232
},
3333
],
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React from 'react';
22
import { PluginSlot } from '@openedx/frontend-plugin-framework';
33

4-
const DashboardModalSlot = () => (
4+
const DashboardModal = () => (
55
<PluginSlot id="dashboard_modal_slot" />
66
);
77

8-
export default DashboardModalSlot;
8+
export default DashboardModal;

0 commit comments

Comments
 (0)