Skip to content

Commit aef9e27

Browse files
authored
Merge pull request #9 from microsoft/users/esmishra/profile
User profile, log out, history redirection bug fix
2 parents 50f3438 + b404c00 commit aef9e27

File tree

12 files changed

+209
-86
lines changed

12 files changed

+209
-86
lines changed

source/reactjs/src/App.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import { initializeIcons } from '@fluentui/font-icons-mdl2';
4646
import { UserSettingsPanel } from './Components/UserSettingsPanel/UserSettingsPanel';
4747
import { helpPanelReducer, helpPanelReducerName } from './Components/HelpPanel/HelpPanel.reducer';
4848
import { helpPanelSagas } from './Components/HelpPanel/HelpPanel.sagas';
49+
import { ProfilePanel } from './Components/ProfilePanel';
4950

5051
export function App(): React.ReactElement {
5152
useLoginOnStartup(true, { scopes: ['https://graph.microsoft.com/.default'] });
@@ -187,8 +188,9 @@ export function App(): React.ReactElement {
187188
<HelpPanel />
188189
<UserSettingsPanel />
189190
<NotificationPanelCustom />
191+
<ProfilePanel />
190192
<BrowserRouter>
191-
<TopHeader />
193+
<TopHeader upn={user?.email} displayName={user?.name} />
192194
<SideNav links={navConfig} />
193195
<div>
194196
<Stack horizontal className={isPanelOpen ? 'ms-hiddenSm' : ''}>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { Panel, PersonaSize, Separator } from '@fluentui/react';
2+
import * as React from 'react';
3+
import { useDynamicReducer } from '@micro-frontend-react/employee-experience/lib/useDynamicReducer';
4+
import { Context, withContext } from '@micro-frontend-react/employee-experience/lib/Context';
5+
import { IEmployeeExperienceContext } from '@micro-frontend-react/employee-experience/lib/IEmployeeExperienceContext';
6+
import { getIsProfilePanelOpen, getProfile } from './Shared/SharedComponents.selectors';
7+
import { ActionButton } from '@fluentui/react/lib/Button';
8+
import { toggleProfilePanel } from './Shared/SharedComponents.actions';
9+
import { Persona } from './Shared/Components/Persona';
10+
11+
export function ProfilePanel(): React.ReactElement {
12+
const { useSelector, dispatch, authClient } = React.useContext(
13+
Context as React.Context<IEmployeeExperienceContext>
14+
);
15+
const isProfilePanelOpen = useSelector(getIsProfilePanelOpen);
16+
const profile = useSelector(getProfile);
17+
18+
const handleProfileDismiss = (): void => {
19+
dispatch(toggleProfilePanel(false));
20+
};
21+
22+
const handleLogout = (): void => {
23+
authClient.logOut();
24+
};
25+
26+
return (
27+
<Panel
28+
isLightDismiss
29+
isOpen={isProfilePanelOpen}
30+
onDismiss={handleProfileDismiss}
31+
closeButtonAriaLabel="Close profile panel"
32+
headerText="Profile"
33+
>
34+
<Persona
35+
emailAlias={profile?.userPrincipalName}
36+
size={PersonaSize.size56}
37+
text={profile?.displayName}
38+
secondaryText={profile?.userPrincipalName}
39+
styles={{ root: { paddingTop: '20px' } }}
40+
/>
41+
<Separator />
42+
<ActionButton styles={{ label: { color: '#0078d4' }, root: { marginLeft: '-5px' } }} onClick={handleLogout}>
43+
Sign out
44+
</ActionButton>
45+
</Panel>
46+
);
47+
}

0 commit comments

Comments
 (0)