From a499aa4cc576f6120ce7f66a533854a5f7699747 Mon Sep 17 00:00:00 2001 From: Awais Ansari Date: Thu, 13 Jul 2023 14:01:03 +0500 Subject: [PATCH] feat: implement showPreferences flag in notification preferences --- src/account-settings/AccountSettingsPage.jsx | 4 ++++ src/account-settings/JumpNav.jsx | 10 ++++++---- src/index.jsx | 5 ++--- src/notification-preferences/data/reducers.js | 2 ++ src/notification-preferences/data/selectors.js | 4 ++++ src/notification-preferences/data/thunks.js | 1 + 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/account-settings/AccountSettingsPage.jsx b/src/account-settings/AccountSettingsPage.jsx index 28cb41d40..abdb807ae 100644 --- a/src/account-settings/AccountSettingsPage.jsx +++ b/src/account-settings/AccountSettingsPage.jsx @@ -50,6 +50,7 @@ import { import { fetchSiteLanguages } from './site-language'; import CoachingToggle from './coaching/CoachingToggle'; import DemographicsSection from './demographics/DemographicsSection'; +import { fetchCourseList } from '../notification-preferences/data/thunks'; class AccountSettingsPage extends React.Component { constructor(props, context) { @@ -79,6 +80,7 @@ class AccountSettingsPage extends React.Component { } componentDidMount() { + this.props.fetchCourseList(); this.props.fetchSettings(); this.props.fetchSiteLanguages(); sendTrackingLogEvent('edx.user.settings.viewed', { @@ -908,6 +910,7 @@ AccountSettingsPage.propTypes = { saveSettings: PropTypes.func.isRequired, fetchSettings: PropTypes.func.isRequired, beginNameChange: PropTypes.func.isRequired, + fetchCourseList: PropTypes.func.isRequired, tpaProviders: PropTypes.arrayOf(PropTypes.shape({ connected: PropTypes.bool, })), @@ -959,6 +962,7 @@ AccountSettingsPage.defaultProps = { }; export default connect(accountSettingsPageSelector, { + fetchCourseList, fetchSettings, saveSettings, saveMultipleSettings, diff --git a/src/account-settings/JumpNav.jsx b/src/account-settings/JumpNav.jsx index a671bfe1f..f94c10d39 100644 --- a/src/account-settings/JumpNav.jsx +++ b/src/account-settings/JumpNav.jsx @@ -5,17 +5,20 @@ import { OpenInNew } from '@edx/paragon/icons'; import classNames from 'classnames'; import PropTypes from 'prop-types'; 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, displayDemographicsLink, }) => { const stickToTop = useWindowSize().width > breakpoints.small.minWidth; - const showNotificationMenu = false; + const showPreferences = useSelector(selectShowPreferences()); + return (
- {showNotificationMenu - && ( + {showPreferences && ( <>
- )} + )}
); }; diff --git a/src/index.jsx b/src/index.jsx index e67d73169..daf9e107f 100755 --- a/src/index.jsx +++ b/src/index.jsx @@ -25,7 +25,6 @@ import NotificationCourses from './notification-preferences/NotificationCourses' import NotificationPreferences from './notification-preferences/NotificationPreferences'; subscribe(APP_READY, () => { - const allowNotificationRoutes = false; ReactDOM.render( @@ -35,8 +34,8 @@ subscribe(APP_READY, () => {
- {allowNotificationRoutes && ()} - {allowNotificationRoutes && ()} + + diff --git a/src/notification-preferences/data/reducers.js b/src/notification-preferences/data/reducers.js index cee6a7a18..cbdc83a56 100644 --- a/src/notification-preferences/data/reducers.js +++ b/src/notification-preferences/data/reducers.js @@ -7,6 +7,7 @@ import { } from '../../constants'; export const defaultState = { + showPreferences: false, courses: { status: IDLE_STATUS, courses: [], @@ -42,6 +43,7 @@ const notificationPreferencesReducer = (state = defaultState, action = {}) => { courses: [...state.courses.courses, ...action.payload.courseList], pagination: action.payload.pagination, }, + showPreferences: action.payload.showPreferences, }; case Actions.FAILED_COURSE_LIST: return { diff --git a/src/notification-preferences/data/selectors.js b/src/notification-preferences/data/selectors.js index c2293b39c..a7f06230f 100644 --- a/src/notification-preferences/data/selectors.js +++ b/src/notification-preferences/data/selectors.js @@ -57,3 +57,7 @@ export const selectSelectedCourseId = () => state => ( export const selectPagination = () => state => ( state.notificationPreferences.courses.pagination ); + +export const selectShowPreferences = () => state => ( + state.notificationPreferences.showPreferences +); diff --git a/src/notification-preferences/data/thunks.js b/src/notification-preferences/data/thunks.js index bc14a9bbc..dcc865f5f 100644 --- a/src/notification-preferences/data/thunks.js +++ b/src/notification-preferences/data/thunks.js @@ -33,6 +33,7 @@ const normalizeCourses = (responseData) => { return { courseList, pagination, + showPreferences: responseData.showPreferences, }; };