Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added notification preferences settings at account level #1159

Open
wants to merge 7 commits into
base: 2u-main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/account-settings/AccountSettingsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import {
} from './data/constants';
import { fetchSiteLanguages } from './site-language';
import { fetchCourseList } from '../notification-preferences/data/thunks';
import NotificationSettings from '../notification-preferences/NotificationSettings';
import { withLocation, withNavigate } from './hoc';

class AccountSettingsPage extends React.Component {
Expand Down Expand Up @@ -727,7 +728,7 @@ class AccountSettingsPage extends React.Component {
{...editableFieldProps}
/>
</div>
<div className="account-section pt-3 mb-5" id="social-media">
<div className="account-section pt-3" id="social-media">
<h2 className="section-heading h4 mb-3">
{this.props.intl.formatMessage(messages['account.settings.section.social.media'])}
</h2>
Expand Down Expand Up @@ -763,8 +764,10 @@ class AccountSettingsPage extends React.Component {
{...editableFieldProps}
/>
</div>

<div className="account-section pt-3 mb-5" id="site-preferences" ref={this.navLinkRefs['#site-preferences']}>
<div className="border border-light-700 my-6" />
<NotificationSettings />
<div className="border border-light-700 my-6" />
<div className="account-section mb-5" id="site-preferences" ref={this.navLinkRefs['#site-preferences']}>
<h2 className="section-heading h4 mb-3">
{this.props.intl.formatMessage(messages['account.settings.section.site.preferences'])}
</h2>
Expand Down
22 changes: 1 addition & 21 deletions src/account-settings/JumpNav.jsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
import { getConfig } from '@edx/frontend-platform';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { breakpoints, useWindowSize, Icon } from '@openedx/paragon';
import { OpenInNew } from '@openedx/paragon/icons';
import { breakpoints, useWindowSize } from '@openedx/paragon';
import classNames from 'classnames';
import React from 'react';
import { useSelector } from 'react-redux';
import { NavHashLink } from 'react-router-hash-link';
import Scrollspy from 'react-scrollspy';
import { Link } from 'react-router-dom';
import messages from './AccountSettingsPage.messages';
import { selectShowPreferences } from '../notification-preferences/data/selectors';

const JumpNav = ({
intl,
}) => {
const stickToTop = useWindowSize().width > breakpoints.small.minWidth;
const showPreferences = useSelector(selectShowPreferences());

return (
<div className={classNames('jump-nav px-2.25', { 'jump-nav-sm position-sticky pt-3': stickToTop })}>
Expand Down Expand Up @@ -65,21 +60,6 @@ const JumpNav = ({
</li>
)}
</Scrollspy>
{showPreferences && (
<>
<hr />
<Scrollspy
className="list-unstyled"
>
<li>
<Link to="/notifications" target="_blank" rel="noopener noreferrer">
<span>{intl.formatMessage(messages['notification.preferences.notifications.label'])}</span>
<Icon className="d-inline-block align-bottom ml-1" src={OpenInNew} />
</Link>
</li>
</Scrollspy>
</>
)}
</div>
);
};
Expand Down
10 changes: 10 additions & 0 deletions src/account-settings/test/AccountSettingsPage.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ describe('AccountSettingsPage', () => {

afterEach(() => jest.clearAllMocks());

beforeAll(() => {
global.lightningjs = {
require: jest.fn().mockImplementation((module, url) => ({ moduleName: module, url })),
};
});

afterAll(() => {
delete global.lightningjs;
});

it('renders AccountSettingsPage correctly with editing enabled', async () => {
const { getByText, rerender, getByLabelText } = render(reduxWrapper(<IntlAccountSettingsPage {...props} />));

Expand Down
4 changes: 2 additions & 2 deletions src/account-settings/test/mockData.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const mockData = {
profileDataManager: null,
},
notificationPreferences: {
showPreferences: false,
showPreferences: true,
courses: {
status: 'success',
courses: [],
Expand All @@ -98,7 +98,7 @@ const mockData = {
preferences: {
status: 'idle',
updatePreferenceStatus: 'idle',
selectedCourse: null,
selectedCourse: 'account',
preferences: [],
apps: [],
nonEditable: {},
Expand Down
16 changes: 16 additions & 0 deletions src/divider/Divider.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import PropTypes from 'prop-types';
import classNames from 'classnames';

const Divider = ({ className, ...props }) => (
<div className={classNames('divider', className)} {...props} />

Check warning on line 5 in src/divider/Divider.jsx

View check run for this annotation

Codecov / codecov/patch

src/divider/Divider.jsx#L4-L5

Added lines #L4 - L5 were not covered by tests
);

Divider.propTypes = {

Check warning on line 8 in src/divider/Divider.jsx

View check run for this annotation

Codecov / codecov/patch

src/divider/Divider.jsx#L8

Added line #L8 was not covered by tests
className: PropTypes.string,
};

Divider.defaultProps = {

Check warning on line 12 in src/divider/Divider.jsx

View check run for this annotation

Codecov / codecov/patch

src/divider/Divider.jsx#L12

Added line #L12 was not covered by tests
className: undefined,
};

export default Divider;
2 changes: 2 additions & 0 deletions src/divider/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// eslint-disable-next-line import/prefer-default-export
export { default as Divider } from './Divider';
4 changes: 0 additions & 4 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import messages from './i18n';

import './index.scss';
import Head from './head/Head';
import NotificationCourses from './notification-preferences/NotificationCourses';
import NotificationPreferences from './notification-preferences/NotificationPreferences';

subscribe(APP_READY, () => {
ReactDOM.render(
Expand All @@ -38,8 +36,6 @@ subscribe(APP_READY, () => {
</div>
)}
>
<Route path="/notifications/:courseId" element={<NotificationPreferences />} />
<Route path="/notifications" element={<NotificationCourses />} />
<Route
path="/id-verification/*"
element={<IdVerificationPageSlot />}
Expand Down
16 changes: 15 additions & 1 deletion src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ $fa-font-path: "~font-awesome/fonts";
}

.dropdown-item:active,
.dropdown-item:focus,
.dropdown-item:focus,
.btn-tertiary:not(:disabled):not(.disabled).active {
background-color: $light-300 !important;
}
Expand All @@ -131,6 +131,20 @@ $fa-font-path: "~font-awesome/fonts";
.h-4\.5 {
height: 36px;
}

.course-dropdown{
#course-dropdown-btn {
width: 100%;
font-size: 14px !important;
padding-top: 10px !important;
padding-bottom: 10px !important;
border: 1px solid $light-500 !important;
}

.dropdown-item {
font-size: 14px !important;
}
}
}

.usabilla_live_button_container {
Expand Down
85 changes: 0 additions & 85 deletions src/notification-preferences/NotificationCourses.jsx

This file was deleted.

97 changes: 0 additions & 97 deletions src/notification-preferences/NotificationCourses.test.jsx

This file was deleted.

Loading