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 19, 2025
1 parent d2dc28e commit 9f57363
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 18 deletions.
3 changes: 1 addition & 2 deletions src/containers/Dashboard/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const Dashboard = () => {
hooks.useInitializeDashboard();
const { pageTitle } = hooks.useDashboardMessages();
const hasCourses = reduxHooks.useHasCourses();
const hasAvailableDashboards = reduxHooks.useHasAvailableDashboards();
const initIsPending = reduxHooks.useRequestIsPending(RequestKeys.initialize);
const showSelectSessionModal = reduxHooks.useShowSelectSessionModal();

Expand All @@ -24,7 +23,7 @@ export const Dashboard = () => {
<h1 className="sr-only">{pageTitle}</h1>
{!initIsPending && (
<>
{hasAvailableDashboards && <DashboardModalSlot />}
<DashboardModalSlot />
{(hasCourses && showSelectSessionModal) && <SelectSessionModal />}
</>
)}
Expand Down
12 changes: 3 additions & 9 deletions src/containers/Dashboard/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import Dashboard from '.';
jest.mock('hooks', () => ({
reduxHooks: {
useHasCourses: jest.fn(),
useHasAvailableDashboards: jest.fn(),
useShowSelectSessionModal: jest.fn(),
useRequestIsPending: jest.fn(),
},
Expand All @@ -38,12 +37,10 @@ describe('Dashboard', () => {
});
const createWrapper = ({
hasCourses,
hasAvailableDashboards,
initIsPending,
showSelectSessionModal,
}) => {
reduxHooks.useHasCourses.mockReturnValueOnce(hasCourses);
reduxHooks.useHasAvailableDashboards.mockReturnValueOnce(hasAvailableDashboards);
reduxHooks.useRequestIsPending.mockReturnValueOnce(initIsPending);
reduxHooks.useShowSelectSessionModal.mockReturnValueOnce(showSelectSessionModal);
return shallow(<Dashboard />);
Expand Down Expand Up @@ -80,7 +77,7 @@ describe('Dashboard', () => {
it(`renders ${contentName}`, () => {
testContent(contentEl);
});
it(`${renderString(showEnterpriseModal)} dashbaord modal`, () => {
it(`${renderString(showEnterpriseModal)} dashboard modal`, () => {
expect(wrapper.instance.findByType(DashboardModalSlot).length)
.toEqual(showEnterpriseModal ? 1 : 0);
});
Expand All @@ -92,7 +89,6 @@ describe('Dashboard', () => {
testView({
props: {
hasCourses: false,
hasAvailableDashboards: false,
initIsPending: true,
showSelectSessionModal: false,
},
Expand All @@ -102,11 +98,10 @@ describe('Dashboard', () => {
});
});

describe('courses loaded, show select session modal, no available dashboards', () => {
describe('courses loaded, show select session modal', () => {
testView({
props: {
hasCourses: true,
hasAvailableDashboards: false,
initIsPending: false,
showSelectSessionModal: true,
},
Expand All @@ -118,11 +113,10 @@ describe('Dashboard', () => {
});
});

describe('there are no courses, there ARE available dashboards', () => {
describe('there are no courses', () => {
testView({
props: {
hasCourses: false,
hasAvailableDashboards: true,
initIsPending: false,
showSelectSessionModal: false,
},
Expand Down
1 change: 0 additions & 1 deletion src/data/redux/hooks/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export const useSocialShareSettings = () => useSelector(selectors.socialShareSet

/** global-level meta-selectors **/
export const useHasCourses = () => useSelector(selectors.hasCourses);
export const useHasAvailableDashboards = () => useSelector(selectors.hasAvailableDashboards);
export const useCurrentCourseList = (opts) => useSelector(
state => selectors.currentList(state, opts),
);
Expand Down
15 changes: 9 additions & 6 deletions src/plugin-slots/DashboardModalSlot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@

## Description

This slot is used for the modal on a dashboard that directs you to the enterprise dashboard if applicable.
This slot is used for the modal on a dashboard that appears on initial load.
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)

```js
import { DIRECT_PLUGIN, PLUGIN_OPERATIONS } from '@openedx/frontend-plugin-framework';
import { DashboardModal } from '@edx/frontend-plugin-learner-dashboard';
import { ModalDialog } from '@openedx/paragon';

const config = {
pluginSlots: {
Expand All @@ -21,10 +26,8 @@ const config = {
id: 'dashboard_modal',
type: DIRECT_PLUGIN,
priority: 60,
RenderWidget: DashboardModal,
content: {
store,
},
RenderWidget:
<ModalDialog title="Modal that appears on initial render of learner dashboard" />,
},
},
],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9f57363

Please sign in to comment.