Skip to content

Commit f249b1f

Browse files
authored
fix: use initials in profile icon when signed in (#3625)
* use user initials * handle profile and header cleanup
1 parent bc2849b commit f249b1f

19 files changed

+372
-1251
lines changed

src/app/views/authentication/Authentication.styles.ts

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/app/views/authentication/Authentication.tsx

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MessageBarType, Spinner, SpinnerSize, styled } from '@fluentui/react';
1+
import { Spinner } from '@fluentui/react-components';
22
import { SeverityLevel } from '@microsoft/applicationinsights-web';
33
import { useState } from 'react';
44

@@ -9,9 +9,18 @@ import { componentNames, errorTypes, eventTypes, telemetry } from '../../../tele
99
import { getAuthTokenSuccess, getConsentedScopesSuccess } from '../../services/slices/auth.slice';
1010
import { setQueryResponseStatus } from '../../services/slices/query-status.slice';
1111
import { translateMessage } from '../../utils/translate-messages';
12-
import { classNames } from '../classnames';
13-
import { showSignInButtonOrProfile } from './auth-util-components/ProfileButtonV9';
14-
import { authenticationStyles } from './Authentication.styles';
12+
import { showSignInButtonOrProfile } from './auth-util-components/ProfileButton';
13+
14+
const showProgressSpinner = (): React.ReactNode => {
15+
return (
16+
<Spinner/>
17+
);
18+
};
19+
20+
const removeUnderScore = (statusString: string): string => {
21+
return statusString ? statusString.replace(/_/g, ' ') : statusString;
22+
}
23+
1524

1625
const Authentication = (props: any) => {
1726
const dispatch: AppDispatch = useAppDispatch();
@@ -20,8 +29,6 @@ const Authentication = (props: any) => {
2029
const tokenPresent = !!authToken.token;
2130
const logoutInProgress = !!authToken.pending;
2231

23-
const classes = classNames(props);
24-
2532
const signIn = async (): Promise<void> => {
2633
setLoginInProgress(true);
2734
telemetry.trackEvent(eventTypes.BUTTON_CLICK_EVENT, {
@@ -82,19 +89,6 @@ const Authentication = (props: any) => {
8289
}
8390
}
8491

85-
86-
const removeUnderScore = (statusString: string): string => {
87-
return statusString ? statusString.replace(/_/g, ' ') : statusString;
88-
}
89-
90-
const showProgressSpinner = (): React.ReactNode => {
91-
return (
92-
<div className={classes.spinnerContainer}>
93-
<Spinner className={classes.spinner} size={SpinnerSize.medium} />
94-
</div>
95-
);
96-
};
97-
9892
if (logoutInProgress) {
9993
return showProgressSpinner();
10094
}
@@ -116,6 +110,4 @@ const Authentication = (props: any) => {
116110
);
117111
};
118112

119-
// @ts-ignore
120-
const StyledAuthentication = styled(Authentication, authenticationStyles);
121-
export default StyledAuthentication;
113+
export default Authentication;

src/app/views/authentication/AuthenticationV9.tsx

Lines changed: 0 additions & 118 deletions
This file was deleted.

src/app/views/authentication/auth-util-components/ProfileButton.styles.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,43 @@
1-
import { ActionButton, getId, getTheme, TooltipHost } from '@fluentui/react';
1+
import { Button, Persona, PersonaProps, Tooltip } from '@fluentui/react-components';
22
import { translateMessage } from '../../../utils/translate-messages';
3-
import Profile from '../profile/Profile';
4-
import { profileButtonStyles } from './ProfileButton.styles';
3+
import { useHeaderStyles } from '../../main-header/utils';
4+
import { ProfileV9 } from '../profile/Profile';
55

6+
export const PersonaSignIn = (props: Partial<PersonaProps>) => {
7+
return (
8+
<Persona
9+
presence={{ status: 'offline' }}
10+
{...props}
11+
/>
12+
);
13+
};
14+
15+
const SignInButton = ({signIn}: {signIn: ()=> void})=>{
16+
const styles = useHeaderStyles()
17+
return (
18+
<Tooltip
19+
content={translateMessage('sign in')}
20+
relationship="description">
21+
<Button
22+
aria-label={translateMessage('sign in')}
23+
role='button'
24+
appearance='subtle'
25+
className={styles.iconButton}
26+
icon={<PersonaSignIn/>}
27+
onClick={signIn}
28+
/>
29+
</Tooltip>
30+
)
31+
}
632
export function showSignInButtonOrProfile(
733
tokenPresent: boolean,
8-
signIn: Function,
9-
signInWithOther: Function
34+
signIn: () => void,
35+
signInWithOther: ()=>Promise<void>
1036
) {
11-
12-
const currentTheme = getTheme();
13-
const { actionButtonStyles } = profileButtonStyles(currentTheme);
14-
const signInButton =
15-
<TooltipHost
16-
content={
17-
<div style={{padding:'3px'}}>
18-
{translateMessage('sign in')}
19-
</div>}
20-
id={getId()}
21-
calloutProps={{ gapSpace: 0 }}
22-
>
23-
<ActionButton
24-
ariaLabel={translateMessage('sign in')}
25-
role='button'
26-
iconProps={{ iconName: 'Contact' }}
27-
onClick={() => signIn()}
28-
styles={actionButtonStyles}
29-
/>
30-
</TooltipHost>
31-
3237
return (
3338
<>
34-
{!tokenPresent && signInButton}
35-
{tokenPresent && <Profile signInWithOther={signInWithOther}/>}
39+
{!tokenPresent && <SignInButton signIn={signIn}/>}
40+
{tokenPresent && <ProfileV9 signInWithOther={signInWithOther} />}
3641
</>
3742
);
3843
}

src/app/views/authentication/auth-util-components/ProfileButtonV9.tsx

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)