Skip to content

Commit

Permalink
fix: PR requests
Browse files Browse the repository at this point in the history
  • Loading branch information
kiram15 committed Feb 26, 2025
1 parent 9f57363 commit 528fb79
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 39 deletions.
7 changes: 4 additions & 3 deletions src/containers/Dashboard/__snapshots__/index.test.jsx.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Dashboard snapshots courses loaded, show select session modal, no available dashboards snapshot 1`] = `
exports[`Dashboard snapshots courses loaded, show select session modal snapshot 1`] = `
<div
className="d-flex flex-column p-2 pt-0"
id="dashboard-container"
Expand All @@ -11,6 +11,7 @@ exports[`Dashboard snapshots courses loaded, show select session modal, no avail
test-page-title
</h1>
<Fragment>
<DashboardModalSlot />
<SelectSessionModal />
</Fragment>
<div
Expand Down Expand Up @@ -43,7 +44,7 @@ exports[`Dashboard snapshots courses still loading snapshot 1`] = `
</div>
`;

exports[`Dashboard snapshots there are no courses, there ARE available dashboards snapshot 1`] = `
exports[`Dashboard snapshots there are no courses snapshot 1`] = `
<div
className="d-flex flex-column p-2 pt-0"
id="dashboard-container"
Expand All @@ -54,7 +55,7 @@ exports[`Dashboard snapshots there are no courses, there ARE available dashboard
test-page-title
</h1>
<Fragment>
<DashboardModal />
<DashboardModalSlot />
</Fragment>
<div
data-testid="dashboard-content"
Expand Down
9 changes: 0 additions & 9 deletions src/containers/Dashboard/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { reduxHooks } from 'hooks';

import SelectSessionModal from 'containers/SelectSessionModal';
import CoursesPanel from 'containers/CoursesPanel';
import DashboardModalSlot from 'plugin-slots/DashboardModalSlot';

import DashboardLayout from './DashboardLayout';
import LoadingView from './LoadingView';
Expand Down Expand Up @@ -68,7 +67,6 @@ describe('Dashboard', () => {
const testView = ({
props,
content: [contentName, contentEl],
showEnterpriseModal,
showSelectSessionModal,
}) => {
beforeEach(() => { wrapper = createWrapper(props); });
Expand All @@ -77,10 +75,6 @@ describe('Dashboard', () => {
it(`renders ${contentName}`, () => {
testContent(contentEl);
});
it(`${renderString(showEnterpriseModal)} dashboard modal`, () => {
expect(wrapper.instance.findByType(DashboardModalSlot).length)
.toEqual(showEnterpriseModal ? 1 : 0);
});
it(`${renderString(showSelectSessionModal)} select session modal`, () => {
expect(wrapper.instance.findByType(SelectSessionModal).length).toEqual(showSelectSessionModal ? 1 : 0);
});
Expand All @@ -93,7 +87,6 @@ describe('Dashboard', () => {
showSelectSessionModal: false,
},
content: ['LoadingView', <LoadingView />],
showEnterpriseModal: false,
showSelectSessionModal: false,
});
});
Expand All @@ -108,7 +101,6 @@ describe('Dashboard', () => {
content: ['LoadedView', (
<DashboardLayout><CoursesPanel /></DashboardLayout>
)],
showEnterpriseModal: false,
showSelectSessionModal: true,
});
});
Expand All @@ -123,7 +115,6 @@ describe('Dashboard', () => {
content: ['Dashboard layout with no courses sidebar and content', (
<DashboardLayout><CoursesPanel /></DashboardLayout>
)],
showEnterpriseModal: true,
showSelectSessionModal: false,
});
});
Expand Down
6 changes: 1 addition & 5 deletions src/data/redux/app/selectors/appSelectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ export const numCourses = createSelector(
(courseData) => Object.keys(courseData).length,
);
export const hasCourses = createSelector([module.numCourses], (num) => num > 0);
export const hasAvailableDashboards = createSelector(
[simpleSelectors.enterpriseDashboard],
(data) => data !== null && data.isLearnerPortalEnabled === true,
);

export const showSelectSessionModal = createSelector(
[simpleSelectors.selectSessionModal],
(data) => data.cardId != null,
Expand All @@ -22,6 +19,5 @@ export const showSelectSessionModal = createSelector(
export default StrictDict({
numCourses,
hasCourses,
hasAvailableDashboards,
showSelectSessionModal,
});
9 changes: 0 additions & 9 deletions src/data/redux/app/selectors/appSelectors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@ describe('basic app selectors', () => {
expect(cb(0)).toEqual(false);
});
});
describe('hasAvailableDashboards', () => {
it('returns true iff the enterpriseDashboard field is populated and learner portal is enabled', () => {
const { preSelectors, cb } = appSelectors.hasAvailableDashboards;
expect(preSelectors).toEqual([simpleSelectors.enterpriseDashboard]);
expect(cb({ isLearnerPortalEnabled: true })).toEqual(true);
expect(cb({ isLearnerPortalEnabled: false })).toEqual(false);
expect(cb(null)).toEqual(false);
});
});
describe('showSelectSessionModal', () => {
it('returns true if the selectSessionModal cardId is not null', () => {
const { preSelectors, cb } = appSelectors.showSelectSessionModal;
Expand Down
6 changes: 0 additions & 6 deletions src/data/redux/app/selectors/simpleSelectors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ describe('app simple selectors', () => {
expect(preSelectors).toEqual([appSelector]);
expect(cb(testState.app)).toEqual(testString);
});
test('enterpriseDashboard returns empty object if data returns null', () => {
testState = { app: { enterpriseDashboard: null } };
const { preSelectors, cb } = simpleSelectors.enterpriseDashboard;
expect(preSelectors).toEqual([appSelector]);
expect(cb(testState.app)).toEqual({});
});
describe('cardSimpleSelectors', () => {
keys = keyStore(cardSimpleSelectors);
test.each([
Expand Down
10 changes: 5 additions & 5 deletions src/plugin-slots/DashboardModalSlot/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Course Card Action Slot
# Dashboard Modal Slot

### Slot ID: `dashboard_modal_slot`

## Description

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

## Example

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

```js
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework';
Expand All @@ -27,7 +27,7 @@ const config = {
type: DIRECT_PLUGIN,
priority: 60,
RenderWidget:
<ModalDialog title="Modal that appears on initial render of learner dashboard" />,
<ModalDialog title="Modal that appears on learner dashboard" />,
},
},
],
Expand Down
4 changes: 2 additions & 2 deletions src/plugin-slots/DashboardModalSlot/index.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import { PluginSlot } from '@openedx/frontend-plugin-framework';

const DashboardModal = () => (
const DashboardModalSlot = () => (
<PluginSlot id="dashboard_modal_slot" />
);

export default DashboardModal;
export default DashboardModalSlot;

0 comments on commit 528fb79

Please sign in to comment.