Skip to content

Commit 84ffb12

Browse files
authored
Revert "feat: added notification tray for common header/learner dashboard (#592)" (#594)
This reverts commit 82d3c19.
1 parent 82d3c19 commit 84ffb12

File tree

7 files changed

+419
-516
lines changed

7 files changed

+419
-516
lines changed

src/DesktopHeader.jsx

+2-24
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import { connect } from 'react-redux';
4-
53
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
64
import { getConfig } from '@edx/frontend-platform';
75
import { AvatarButton, Dropdown } from '@openedx/paragon';
@@ -12,8 +10,6 @@ import UserMenuGroupSlot from './plugin-slots/UserMenuGroupSlot';
1210
import UserMenuItem from './common/UserMenuItem';
1311
import { Menu, MenuTrigger, MenuContent } from './Menu';
1412
import { LinkedLogo, Logo } from './Logo';
15-
import Notifications from './Notifications';
16-
import { mapDispatchToProps, mapStateToProps } from './data/selectors';
1713

1814
// i18n
1915
import messages from './Header.messages';
@@ -24,20 +20,6 @@ import { CaretIcon } from './Icons';
2420
class DesktopHeader extends React.Component {
2521
constructor(props) { // eslint-disable-line no-useless-constructor
2622
super(props);
27-
this.state = {
28-
locationHref: window.location.href,
29-
};
30-
}
31-
32-
componentDidMount() {
33-
this.props.fetchAppsNotificationCount();
34-
}
35-
36-
componentDidUpdate() {
37-
if (window.location.href !== this.state.locationHref) {
38-
this.setState({ locationHref: window.location.href });
39-
this.props.fetchAppsNotificationCount();
40-
}
4123
}
4224

4325
renderMenu(menu) {
@@ -170,7 +152,6 @@ class DesktopHeader extends React.Component {
170152
logoAltText,
171153
logoDestination,
172154
loggedIn,
173-
showNotificationsTray,
174155
intl,
175156
} = this.props;
176157
const logoProps = { src: logo, alt: logoAltText, href: logoDestination };
@@ -196,7 +177,6 @@ class DesktopHeader extends React.Component {
196177
? (
197178
<>
198179
{this.renderSecondaryMenu()}
199-
{showNotificationsTray && <Notifications showLeftMargin={false} />}
200180
{this.renderUserMenu()}
201181
</>
202182
) : this.renderLoggedOutItems()}
@@ -240,8 +220,7 @@ DesktopHeader.propTypes = {
240220
name: PropTypes.string,
241221
email: PropTypes.string,
242222
loggedIn: PropTypes.bool,
243-
showNotificationsTray: PropTypes.bool,
244-
fetchAppsNotificationCount: PropTypes.func.isRequired,
223+
245224
// i18n
246225
intl: intlShape.isRequired,
247226
};
@@ -258,7 +237,6 @@ DesktopHeader.defaultProps = {
258237
name: '',
259238
email: '',
260239
loggedIn: false,
261-
showNotificationsTray: false,
262240
};
263241

264-
export default connect(mapStateToProps, mapDispatchToProps)(injectIntl(DesktopHeader));
242+
export default injectIntl(DesktopHeader);

src/Header.jsx

+3-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useContext } from 'react';
22
import Responsive from 'react-responsive';
33
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
44
import { sendTrackEvent } from '@edx/frontend-platform/analytics';
5-
import { AppContext, AppProvider } from '@edx/frontend-platform/react';
5+
import { AppContext } from '@edx/frontend-platform/react';
66
import { Badge } from '@openedx/paragon';
77
import {
88
APP_CONFIG_INITIALIZED,
@@ -16,7 +16,6 @@ import { useEnterpriseConfig } from '@edx/frontend-enterprise-utils';
1616
import PropTypes from 'prop-types';
1717
import DesktopHeader from './DesktopHeader';
1818
import MobileHeader from './MobileHeader';
19-
import store from './store';
2019

2120
import messages from './Header.messages';
2221

@@ -27,17 +26,13 @@ ensureConfig([
2726
'MARKETING_SITE_BASE_URL',
2827
'ORDER_HISTORY_URL',
2928
'LOGO_URL',
30-
'ACCOUNT_SETTINGS_URL',
31-
'NOTIFICATION_FEEDBACK_URL',
3229
], 'Header component');
3330

3431
subscribe(APP_CONFIG_INITIALIZED, () => {
3532
mergeConfig({
3633
MINIMAL_HEADER: !!process.env.MINIMAL_HEADER,
3734
ENTERPRISE_LEARNER_PORTAL_HOSTNAME: process.env.ENTERPRISE_LEARNER_PORTAL_HOSTNAME,
3835
AUTHN_MINIMAL_HEADER: !!process.env.AUTHN_MINIMAL_HEADER,
39-
ACCOUNT_SETTINGS_URL: process.env.ACCOUNT_SETTINGS_URL || '',
40-
NOTIFICATION_FEEDBACK_URL: process.env.NOTIFICATION_FEEDBACK_URL || '',
4136
}, 'Header additional config');
4237
});
4338

@@ -199,14 +194,14 @@ const Header = ({
199194
}
200195

201196
return (
202-
<AppProvider store={store} wrapWithRouter={false}>
197+
<>
203198
<Responsive maxWidth={769}>
204199
<MobileHeader {...props} />
205200
</Responsive>
206201
<Responsive minWidth={769}>
207202
<DesktopHeader {...props} />
208203
</Responsive>
209-
</AppProvider>
204+
</>
210205
);
211206
};
212207

src/Header.test.jsx

+1-6
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ import { useEnterpriseConfig } from '@edx/frontend-enterprise-utils';
77
import { AppContext } from '@edx/frontend-platform/react';
88
import { getConfig } from '@edx/frontend-platform';
99
import { Context as ResponsiveContext } from 'react-responsive';
10-
import { fireEvent, render, screen } from '@testing-library/react';
1110

12-
import { initializeMockApp } from './setupTest';
11+
import { fireEvent, render, screen } from '@testing-library/react';
1312
import Header from './index';
1413

1514
jest.mock('@edx/frontend-platform');
@@ -42,10 +41,6 @@ describe('<Header />', () => {
4241
beforeEach(() => {
4342
useEnterpriseConfig.mockReturnValue({});
4443
});
45-
beforeAll(async () => {
46-
// We need to mock AuthService to implicitly use `getAuthenticatedUser` within `AppContext.Provider`.
47-
await initializeMockApp();
48-
});
4944

5045
const mockUseEnterpriseConfig = () => {
5146
useEnterpriseConfig.mockReturnValue({

src/MobileHeader.jsx

+5-25
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import { connect } from 'react-redux';
4-
53
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
64
import { getConfig } from '@edx/frontend-platform';
7-
import { AvatarButton } from '@openedx/paragon';
85

96
// Local Components
7+
import { AvatarButton } from '@openedx/paragon';
108
import UserMenuGroupSlot from './plugin-slots/UserMenuGroupSlot';
119
import UserMenuGroupItemSlot from './plugin-slots/UserMenuGroupItemSlot';
1210
import { Menu, MenuTrigger, MenuContent } from './Menu';
1311
import { LinkedLogo, Logo } from './Logo';
1412
import UserMenuItem from './common/UserMenuItem';
15-
import Notifications from './Notifications';
16-
import { mapDispatchToProps, mapStateToProps } from './data/selectors';
13+
1714
// i18n
1815
import messages from './Header.messages';
1916

@@ -23,20 +20,6 @@ import { MenuIcon } from './Icons';
2320
class MobileHeader extends React.Component {
2421
constructor(props) { // eslint-disable-line no-useless-constructor
2522
super(props);
26-
this.state = {
27-
locationHref: window.location.href,
28-
};
29-
}
30-
31-
componentDidMount() {
32-
this.props.fetchAppsNotificationCount();
33-
}
34-
35-
componentDidUpdate() {
36-
if (window.location.href !== this.state.locationHref) {
37-
this.setState({ locationHref: window.location.href });
38-
this.props.fetchAppsNotificationCount();
39-
}
4023
}
4124

4225
renderMenu(menu) {
@@ -152,7 +135,6 @@ class MobileHeader extends React.Component {
152135
mainMenu,
153136
userMenu,
154137
loggedOutItems,
155-
showNotificationsTray,
156138
} = this.props;
157139
const logoProps = { src: logo, alt: logoAltText, href: logoDestination };
158140
const stickyClassName = stickyOnMobile ? 'sticky-top' : '';
@@ -191,7 +173,6 @@ class MobileHeader extends React.Component {
191173
</div>
192174
{userMenu.length > 0 || loggedOutItems.length > 0 ? (
193175
<div className="w-100 d-flex justify-content-end align-items-center">
194-
{showNotificationsTray && loggedIn && <Notifications />}
195176
<Menu tag="nav" aria-label={intl.formatMessage(messages['header.label.secondary.nav'])} className="position-static">
196177
<MenuTrigger
197178
tag={AvatarButton}
@@ -246,8 +227,7 @@ MobileHeader.propTypes = {
246227
email: PropTypes.string,
247228
loggedIn: PropTypes.bool,
248229
stickyOnMobile: PropTypes.bool,
249-
showNotificationsTray: PropTypes.bool,
250-
fetchAppsNotificationCount: PropTypes.func.isRequired,
230+
251231
// i18n
252232
intl: intlShape.isRequired,
253233
};
@@ -265,7 +245,7 @@ MobileHeader.defaultProps = {
265245
email: '',
266246
loggedIn: false,
267247
stickyOnMobile: true,
268-
showNotificationsTray: false,
248+
269249
};
270250

271-
export default connect(mapStateToProps, mapDispatchToProps)(injectIntl(MobileHeader));
251+
export default injectIntl(MobileHeader);

src/Notifications/index.jsx

+2-13
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import React, {
66

77
import classNames from 'classnames';
88
import { useDispatch, useSelector } from 'react-redux';
9-
import PropTypes from 'prop-types';
109

1110
import { getConfig } from '@edx/frontend-platform';
1211
import { useIntl } from '@edx/frontend-platform/i18n';
@@ -27,7 +26,7 @@ import NotificationTabs from './NotificationTabs';
2726

2827
import './notification.scss';
2928

30-
const Notifications = ({ showLeftMargin }) => {
29+
const Notifications = () => {
3130
const intl = useIntl();
3231
const dispatch = useDispatch();
3332
const popoverRef = useRef(null);
@@ -145,9 +144,7 @@ const Notifications = ({ showLeftMargin }) => {
145144
iconAs={Icon}
146145
variant="light"
147146
iconClassNames="text-primary-500"
148-
className={classNames('mr-1 notification-button', {
149-
'ml-4': showLeftMargin,
150-
})}
147+
className="ml-4 mr-1 notification-button"
151148
data-testid="notification-bell-icon"
152149
/>
153150
{notificationCounts?.count > 0 && (
@@ -171,12 +168,4 @@ const Notifications = ({ showLeftMargin }) => {
171168
);
172169
};
173170

174-
Notifications.propTypes = {
175-
showLeftMargin: PropTypes.bool,
176-
};
177-
178-
Notifications.defaultProps = {
179-
showLeftMargin: true,
180-
};
181-
182171
export default Notifications;

0 commit comments

Comments
 (0)