Skip to content

Commit ad2aa77

Browse files
Merge pull request #3395 from OneCommunityGlobal/revert-3294-vinay/notify-user-new-permission
Revert "Vinay: Let a user know through a popup that Permissions have been changed for them"
2 parents 923e049 + c510328 commit ad2aa77

3 files changed

Lines changed: 11 additions & 35 deletions

File tree

src/components/Header/Header.jsx

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ import {
6161
import NotificationCard from '../Notification/notificationCard';
6262
import DarkModeButton from './DarkModeButton';
6363
import BellNotification from './BellNotification';
64-
import { getUserProfile } from '../../actions/userProfile';
6564

6665
export function Header(props) {
6766
const location = useLocation();
@@ -216,27 +215,6 @@ export function Header(props) {
216215
const openModal = () => {
217216
setLogoutPopup(true);
218217
};
219-
220-
const handlePermissionChangeAck = async() => {
221-
// handle setting the ack true
222-
try {
223-
const {firstName: name, lastName, personalLinks, adminLinks} = props.userProfile
224-
const res = await axios.put(ENDPOINTS.USER_PROFILE(userId), {
225-
// req fields for updation
226-
firstName: name,
227-
lastName,
228-
personalLinks,
229-
adminLinks,
230-
231-
isAcknowledged: true,
232-
});
233-
if (res.status === 200) {
234-
props.getUserProfile(userId);
235-
}
236-
} catch (e) {
237-
// console.log('update ack', e);
238-
}
239-
}
240218

241219
const removeViewingUser = () => {
242220
setPopup(false);
@@ -325,7 +303,6 @@ export function Header(props) {
325303

326304
if (location.pathname === '/login') return null;
327305

328-
const viewingUser = JSON.parse(window.sessionStorage.getItem('viewingUser'))
329306
return (
330307
<div className="header-wrapper">
331308
<Navbar className="py-3 navbar" color="dark" dark expand="md">
@@ -578,14 +555,8 @@ export function Header(props) {
578555
</Navbar>
579556
{!isAuthUser && (
580557
<PopUpBar
581-
message={`You are currently viewing the header for ${viewingUser.firstName} ${viewingUser.lastName}`}
582558
onClickClose={() => setPopup(prevPopup => !prevPopup)}
583-
/>
584-
)}
585-
{props.auth.isAuthenticated && props.userProfile?.permissions?.isAcknowledged===false && (
586-
<PopUpBar
587-
message="Heads Up, there were permission changes made to this account"
588-
onClickClose={handlePermissionChangeAck}
559+
viewingUser={JSON.parse(window.sessionStorage.getItem('viewingUser'))}
589560
/>
590561
)}
591562
<div>
@@ -637,5 +608,4 @@ export default connect(mapStateToProps, {
637608
getAllRoles,
638609
hasPermission,
639610
getWeeklySummaries,
640-
getUserProfile
641611
})(Header);

src/components/PopUpBar/PopUpBar.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
import './PopUpBar.css';
33

44
function PopUpBar(props) {
5-
const { message, onClickClose } = props;
5+
const { viewingUser, onClickClose } = props;
6+
const { firstName, lastName } = viewingUser;
67
return (
78
<div className="popup_container" data-testid="test-popup">
8-
{message}
9+
{`You are currently viewing the header for ${firstName} ${lastName}`}
910
<button type="button" className="close_button" onClick={onClickClose}>
1011
X
1112
</button>

src/components/PopUpBar/__tests__/PopUpBar.test.jsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import { render, screen, fireEvent } from '@testing-library/react';
22
import PopUpBar from '../PopUpBar';
33

4+
const viewingUser = {
5+
firstName: 'TestUser',
6+
lastName: 'LastName',
7+
};
8+
49
// render Component
510
const renderComponent = (props = {}) => {
6-
render(<PopUpBar message="PopUpBar text message" {...props} />);
11+
render(<PopUpBar viewingUser={viewingUser} {...props} />);
712
};
813

914
// Test Cases
@@ -16,7 +21,7 @@ describe('Test Suite for PopUpBar', () => {
1621

1722
it('Test Case 2: Renders with correct text', () => {
1823
renderComponent();
19-
const expectedText = `PopUpBar text message`;
24+
const expectedText = `You are currently viewing the header for ${viewingUser.firstName} ${viewingUser.lastName}`;
2025
const actualText = screen.getByText(expectedText);
2126
expect(actualText).toBeInTheDocument();
2227
});

0 commit comments

Comments
 (0)