Skip to content

Commit

Permalink
Revert "feat: adding new plugin slot for an enterprise modal"
Browse files Browse the repository at this point in the history
This reverts commit f110a0a.
  • Loading branch information
jsnwesson committed Mar 3, 2025
1 parent 13721f2 commit e764e9c
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 48 deletions.
4 changes: 2 additions & 2 deletions src/containers/Dashboard/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React from 'react';

import { reduxHooks } from 'hooks';
import { RequestKeys } from 'data/constants/requests';
import EnterpriseDashboardModal from 'containers/EnterpriseDashboardModal';
import SelectSessionModal from 'containers/SelectSessionModal';
import CoursesPanel from 'containers/CoursesPanel';
import EnterpriseDashboardModalSlot from 'plugin-slots/EnterpriseDashboardModalSlot';

import LoadingView from './LoadingView';
import DashboardLayout from './DashboardLayout';
Expand All @@ -24,7 +24,7 @@ export const Dashboard = () => {
<h1 className="sr-only">{pageTitle}</h1>
{!initIsPending && (
<>
{hasAvailableDashboards && <EnterpriseDashboardModalSlot />}
{hasAvailableDashboards && <EnterpriseDashboardModal />}
{(hasCourses && showSelectSessionModal) && <SelectSessionModal />}
</>
)}
Expand Down
6 changes: 3 additions & 3 deletions src/containers/Dashboard/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { shallow } from '@edx/react-unit-test-utils';

import { reduxHooks } from 'hooks';

import EnterpriseDashboardModal from 'containers/EnterpriseDashboardModal';
import SelectSessionModal from 'containers/SelectSessionModal';
import CoursesPanel from 'containers/CoursesPanel';
import EnterpriseDashboardModalSlot from 'plugin-slots/EnterpriseDashboardModalSlot';

import DashboardLayout from './DashboardLayout';
import LoadingView from './LoadingView';
Expand All @@ -20,7 +20,7 @@ jest.mock('hooks', () => ({
},
}));

jest.mock('plugin-slots/EnterpriseDashboardModalSlot', () => 'EnterpriseDashboardModalSlot');
jest.mock('containers/EnterpriseDashboardModal', () => 'EnterpriseDashboardModal');
jest.mock('containers/CoursesPanel', () => 'CoursesPanel');
jest.mock('./LoadingView', () => 'LoadingView');
jest.mock('./DashboardLayout', () => 'DashboardLayout');
Expand Down Expand Up @@ -81,7 +81,7 @@ describe('Dashboard', () => {
testContent(contentEl);
});
it(`${renderString(showEnterpriseModal)} dashbaord modal`, () => {
expect(wrapper.instance.findByType(EnterpriseDashboardModalSlot).length)
expect(wrapper.instance.findByType(EnterpriseDashboardModal).length)
.toEqual(showEnterpriseModal ? 1 : 0);
});
it(`${renderString(showSelectSessionModal)} select session modal`, () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`EnterpriseDashboard empty snapshot 1`] = `null`;

exports[`EnterpriseDashboard snapshot 1`] = `
<ModalDialog
hasCloseButton={false}
onClose={[MockFunction useEnterpriseDashboardHook.handleEscape]}
title=""
>
<div
className="bg-white p-3 rounded shadow"
style={
{
"textAlign": "start",
}
}
>
<h4>
You have access to the edX, Inc. dashboard
</h4>
<p>
To access the courses available to you through edX, Inc., visit the edX, Inc. dashboard now.
</p>
<ActionRow>
<Button
onClick={[MockFunction useEnterpriseDashboardHook.handleClose]}
variant="tertiary"
>
Dismiss
</Button>
<Button
href="/edx-dashboard"
onClick={[MockFunction useEnterpriseDashboardHook.handleCTAClick]}
type="a"
>
Go to dashboard
</Button>
</ActionRow>
</div>
</ModalDialog>
`;
60 changes: 60 additions & 0 deletions src/containers/EnterpriseDashboardModal/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import React from 'react';
// import PropTypes from 'prop-types';

import { useIntl } from '@edx/frontend-platform/i18n';
import {
ModalDialog, ActionRow, Button,
} from '@openedx/paragon';

import messages from './messages';
import useEnterpriseDashboardHook from './hooks';

export const EnterpriseDashboardModal = () => {
const { formatMessage } = useIntl();
const {
showModal,
handleClose,
handleCTAClick,
handleEscape,
dashboard,
} = useEnterpriseDashboardHook();
if (!dashboard || !dashboard.label) {
return null;
}
return (
<ModalDialog
isOpen={showModal}
onClose={handleEscape}
hasCloseButton={false}
title=""
>
<div
className="bg-white p-3 rounded shadow"
style={{ textAlign: 'start' }}
>
<h4>
{formatMessage(messages.enterpriseDialogHeader, {
label: dashboard.label,
})}
</h4>
<p>
{formatMessage(messages.enterpriseDialogBody, {
label: dashboard.label,
})}
</p>
<ActionRow>
<Button variant="tertiary" onClick={handleClose}>
{formatMessage(messages.enterpriseDialogDismissButton)}
</Button>
<Button type="a" href={dashboard.url} onClick={handleCTAClick}>
{formatMessage(messages.enterpriseDialogConfirmButton)}
</Button>
</ActionRow>
</div>
</ModalDialog>
);
};

EnterpriseDashboardModal.propTypes = {};

export default EnterpriseDashboardModal;
29 changes: 29 additions & 0 deletions src/containers/EnterpriseDashboardModal/index.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { shallow } from '@edx/react-unit-test-utils';
import EnterpriseDashboard from '.';

import useEnterpriseDashboardHook from './hooks';

jest.mock('./hooks', () => ({
__esModule: true,
default: jest.fn(),
}));

describe('EnterpriseDashboard', () => {
test('snapshot', () => {
const hookData = {
dashboard: { label: 'edX, Inc.', url: '/edx-dashboard' },
showDialog: false,
handleClose: jest.fn().mockName('useEnterpriseDashboardHook.handleClose'),
handleCTAClick: jest.fn().mockName('useEnterpriseDashboardHook.handleCTAClick'),
handleEscape: jest.fn().mockName('useEnterpriseDashboardHook.handleEscape'),
};
useEnterpriseDashboardHook.mockReturnValueOnce({ ...hookData });
const el = shallow(<EnterpriseDashboard />);
expect(el.snapshot).toMatchSnapshot();
});
test('empty snapshot', () => {
useEnterpriseDashboardHook.mockReturnValueOnce({});
const el = shallow(<EnterpriseDashboard />);
expect(el.snapshot).toMatchSnapshot();
});
});
26 changes: 26 additions & 0 deletions src/containers/EnterpriseDashboardModal/messages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { defineMessages } from '@edx/frontend-platform/i18n';

const messages = defineMessages({
enterpriseDialogHeader: {
id: 'leanerDashboard.enterpriseDialogHeader',
defaultMessage: 'You have access to the {label} dashboard',
description: 'title for enterpise dashboard dialog',
},
enterpriseDialogBody: {
id: 'leanerDashboard.enterpriseDialogBody',
defaultMessage: 'To access the courses available to you through {label}, visit the {label} dashboard now.',
description: 'Body text for enterpise dashboard dialog',
},
enterpriseDialogDismissButton: {
id: 'leanerDashboard.enterpriseDialogDismissButton',
defaultMessage: 'Dismiss',
description: 'Dismiss button to cancel visiting dashboard',
},
enterpriseDialogConfirmButton: {
id: 'leanerDashboard.enterpriseDialogConfirmButton',
defaultMessage: 'Go to dashboard',
description: 'Confirm button to go to the dashboard url',
},
});

export default messages;
33 changes: 0 additions & 33 deletions src/plugin-slots/EnterpriseDashboardModalSlot/README.md

This file was deleted.

8 changes: 0 additions & 8 deletions src/plugin-slots/EnterpriseDashboardModalSlot/index.jsx

This file was deleted.

3 changes: 1 addition & 2 deletions src/plugin-slots/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
* [`footer_slot`](./FooterSlot/)
* [`widget_sidebar_slot`](./WidgetSidebarSlot/)
* [`course_list_slot`](./CourseListSlot/)
* [`no_courses_view_slot`](./NoCoursesViewSlot/)
* [`enterprise_dashboard_modal_slot](./EnterpriseDashboardModalSlot)
* [`no_courses_view_slot`](./NoCoursesViewSlot/)

0 comments on commit e764e9c

Please sign in to comment.