Skip to content

Commit e764e9c

Browse files
committed
Revert "feat: adding new plugin slot for an enterprise modal"
This reverts commit f110a0a.
1 parent 13721f2 commit e764e9c

File tree

9 files changed

+163
-48
lines changed

9 files changed

+163
-48
lines changed

src/containers/Dashboard/index.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import React from 'react';
22

33
import { reduxHooks } from 'hooks';
44
import { RequestKeys } from 'data/constants/requests';
5+
import EnterpriseDashboardModal from 'containers/EnterpriseDashboardModal';
56
import SelectSessionModal from 'containers/SelectSessionModal';
67
import CoursesPanel from 'containers/CoursesPanel';
7-
import EnterpriseDashboardModalSlot from 'plugin-slots/EnterpriseDashboardModalSlot';
88

99
import LoadingView from './LoadingView';
1010
import DashboardLayout from './DashboardLayout';
@@ -24,7 +24,7 @@ export const Dashboard = () => {
2424
<h1 className="sr-only">{pageTitle}</h1>
2525
{!initIsPending && (
2626
<>
27-
{hasAvailableDashboards && <EnterpriseDashboardModalSlot />}
27+
{hasAvailableDashboards && <EnterpriseDashboardModal />}
2828
{(hasCourses && showSelectSessionModal) && <SelectSessionModal />}
2929
</>
3030
)}

src/containers/Dashboard/index.test.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { shallow } from '@edx/react-unit-test-utils';
22

33
import { reduxHooks } from 'hooks';
44

5+
import EnterpriseDashboardModal from 'containers/EnterpriseDashboardModal';
56
import SelectSessionModal from 'containers/SelectSessionModal';
67
import CoursesPanel from 'containers/CoursesPanel';
7-
import EnterpriseDashboardModalSlot from 'plugin-slots/EnterpriseDashboardModalSlot';
88

99
import DashboardLayout from './DashboardLayout';
1010
import LoadingView from './LoadingView';
@@ -20,7 +20,7 @@ jest.mock('hooks', () => ({
2020
},
2121
}));
2222

23-
jest.mock('plugin-slots/EnterpriseDashboardModalSlot', () => 'EnterpriseDashboardModalSlot');
23+
jest.mock('containers/EnterpriseDashboardModal', () => 'EnterpriseDashboardModal');
2424
jest.mock('containers/CoursesPanel', () => 'CoursesPanel');
2525
jest.mock('./LoadingView', () => 'LoadingView');
2626
jest.mock('./DashboardLayout', () => 'DashboardLayout');
@@ -81,7 +81,7 @@ describe('Dashboard', () => {
8181
testContent(contentEl);
8282
});
8383
it(`${renderString(showEnterpriseModal)} dashbaord modal`, () => {
84-
expect(wrapper.instance.findByType(EnterpriseDashboardModalSlot).length)
84+
expect(wrapper.instance.findByType(EnterpriseDashboardModal).length)
8585
.toEqual(showEnterpriseModal ? 1 : 0);
8686
});
8787
it(`${renderString(showSelectSessionModal)} select session modal`, () => {
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`EnterpriseDashboard empty snapshot 1`] = `null`;
4+
5+
exports[`EnterpriseDashboard snapshot 1`] = `
6+
<ModalDialog
7+
hasCloseButton={false}
8+
onClose={[MockFunction useEnterpriseDashboardHook.handleEscape]}
9+
title=""
10+
>
11+
<div
12+
className="bg-white p-3 rounded shadow"
13+
style={
14+
{
15+
"textAlign": "start",
16+
}
17+
}
18+
>
19+
<h4>
20+
You have access to the edX, Inc. dashboard
21+
</h4>
22+
<p>
23+
To access the courses available to you through edX, Inc., visit the edX, Inc. dashboard now.
24+
</p>
25+
<ActionRow>
26+
<Button
27+
onClick={[MockFunction useEnterpriseDashboardHook.handleClose]}
28+
variant="tertiary"
29+
>
30+
Dismiss
31+
</Button>
32+
<Button
33+
href="/edx-dashboard"
34+
onClick={[MockFunction useEnterpriseDashboardHook.handleCTAClick]}
35+
type="a"
36+
>
37+
Go to dashboard
38+
</Button>
39+
</ActionRow>
40+
</div>
41+
</ModalDialog>
42+
`;
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import React from 'react';
2+
// import PropTypes from 'prop-types';
3+
4+
import { useIntl } from '@edx/frontend-platform/i18n';
5+
import {
6+
ModalDialog, ActionRow, Button,
7+
} from '@openedx/paragon';
8+
9+
import messages from './messages';
10+
import useEnterpriseDashboardHook from './hooks';
11+
12+
export const EnterpriseDashboardModal = () => {
13+
const { formatMessage } = useIntl();
14+
const {
15+
showModal,
16+
handleClose,
17+
handleCTAClick,
18+
handleEscape,
19+
dashboard,
20+
} = useEnterpriseDashboardHook();
21+
if (!dashboard || !dashboard.label) {
22+
return null;
23+
}
24+
return (
25+
<ModalDialog
26+
isOpen={showModal}
27+
onClose={handleEscape}
28+
hasCloseButton={false}
29+
title=""
30+
>
31+
<div
32+
className="bg-white p-3 rounded shadow"
33+
style={{ textAlign: 'start' }}
34+
>
35+
<h4>
36+
{formatMessage(messages.enterpriseDialogHeader, {
37+
label: dashboard.label,
38+
})}
39+
</h4>
40+
<p>
41+
{formatMessage(messages.enterpriseDialogBody, {
42+
label: dashboard.label,
43+
})}
44+
</p>
45+
<ActionRow>
46+
<Button variant="tertiary" onClick={handleClose}>
47+
{formatMessage(messages.enterpriseDialogDismissButton)}
48+
</Button>
49+
<Button type="a" href={dashboard.url} onClick={handleCTAClick}>
50+
{formatMessage(messages.enterpriseDialogConfirmButton)}
51+
</Button>
52+
</ActionRow>
53+
</div>
54+
</ModalDialog>
55+
);
56+
};
57+
58+
EnterpriseDashboardModal.propTypes = {};
59+
60+
export default EnterpriseDashboardModal;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { shallow } from '@edx/react-unit-test-utils';
2+
import EnterpriseDashboard from '.';
3+
4+
import useEnterpriseDashboardHook from './hooks';
5+
6+
jest.mock('./hooks', () => ({
7+
__esModule: true,
8+
default: jest.fn(),
9+
}));
10+
11+
describe('EnterpriseDashboard', () => {
12+
test('snapshot', () => {
13+
const hookData = {
14+
dashboard: { label: 'edX, Inc.', url: '/edx-dashboard' },
15+
showDialog: false,
16+
handleClose: jest.fn().mockName('useEnterpriseDashboardHook.handleClose'),
17+
handleCTAClick: jest.fn().mockName('useEnterpriseDashboardHook.handleCTAClick'),
18+
handleEscape: jest.fn().mockName('useEnterpriseDashboardHook.handleEscape'),
19+
};
20+
useEnterpriseDashboardHook.mockReturnValueOnce({ ...hookData });
21+
const el = shallow(<EnterpriseDashboard />);
22+
expect(el.snapshot).toMatchSnapshot();
23+
});
24+
test('empty snapshot', () => {
25+
useEnterpriseDashboardHook.mockReturnValueOnce({});
26+
const el = shallow(<EnterpriseDashboard />);
27+
expect(el.snapshot).toMatchSnapshot();
28+
});
29+
});
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { defineMessages } from '@edx/frontend-platform/i18n';
2+
3+
const messages = defineMessages({
4+
enterpriseDialogHeader: {
5+
id: 'leanerDashboard.enterpriseDialogHeader',
6+
defaultMessage: 'You have access to the {label} dashboard',
7+
description: 'title for enterpise dashboard dialog',
8+
},
9+
enterpriseDialogBody: {
10+
id: 'leanerDashboard.enterpriseDialogBody',
11+
defaultMessage: 'To access the courses available to you through {label}, visit the {label} dashboard now.',
12+
description: 'Body text for enterpise dashboard dialog',
13+
},
14+
enterpriseDialogDismissButton: {
15+
id: 'leanerDashboard.enterpriseDialogDismissButton',
16+
defaultMessage: 'Dismiss',
17+
description: 'Dismiss button to cancel visiting dashboard',
18+
},
19+
enterpriseDialogConfirmButton: {
20+
id: 'leanerDashboard.enterpriseDialogConfirmButton',
21+
defaultMessage: 'Go to dashboard',
22+
description: 'Confirm button to go to the dashboard url',
23+
},
24+
});
25+
26+
export default messages;

src/plugin-slots/EnterpriseDashboardModalSlot/README.md

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/plugin-slots/EnterpriseDashboardModalSlot/index.jsx

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/plugin-slots/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44
* [`footer_slot`](./FooterSlot/)
55
* [`widget_sidebar_slot`](./WidgetSidebarSlot/)
66
* [`course_list_slot`](./CourseListSlot/)
7-
* [`no_courses_view_slot`](./NoCoursesViewSlot/)
8-
* [`enterprise_dashboard_modal_slot](./EnterpriseDashboardModalSlot)
7+
* [`no_courses_view_slot`](./NoCoursesViewSlot/)

0 commit comments

Comments
 (0)