diff --git a/packages/app/src/components/Root/Root.tsx b/packages/app/src/components/Root/Root.tsx
index 20eabbcac5..cdb8469ee2 100644
--- a/packages/app/src/components/Root/Root.tsx
+++ b/packages/app/src/components/Root/Root.tsx
@@ -31,7 +31,7 @@ import {
SidebarDivider,
SidebarSearchField,
SidebarSpace,
- SidebarUserBadge,
+ SidebarUserSettings,
SidebarThemeToggle,
} from '@backstage/core';
@@ -84,7 +84,7 @@ const Root: FC<{}> = ({ children }) => (
-
+
{children}
diff --git a/packages/core/src/layout/Sidebar/Items.tsx b/packages/core/src/layout/Sidebar/Items.tsx
index ddd71cc189..412800447a 100644
--- a/packages/core/src/layout/Sidebar/Items.tsx
+++ b/packages/core/src/layout/Sidebar/Items.tsx
@@ -148,7 +148,6 @@ export const SidebarItem: FC = ({
);
}
-
return (
(); // for scrolling down when collapse item opens
+
+ const googleAuth = useApi(googleAuthApiRef);
+ const [profile, setProfile] = useState();
+
+ // TODO(soapraj): List all the providers supported by the app and let user log in from here
+ // TODO(soapraj): How to observe if the user is logged in
+ useEffect(() => {
+ googleAuth.getProfile({ optional: true }).then(googleProfile => {
+ setProfile(googleProfile);
+ });
+ }, [googleAuth, open]);
+
+ const handleClick = () => {
+ setOpen(!open);
+ setTimeout(() => ref.current?.scrollIntoView({ behavior: 'smooth' }), 300);
+ };
+
+ // Close the provider list when sidebar collapse
+ useEffect(() => {
+ if (!sidebarOpen && open) setOpen(false);
+ }, [sidebarOpen]);
+
+ // Handle main auth info that is shown on the collapsible SidebarItem
+ let avatar;
+ let displayName;
+ if (profile) {
+ // const classes = useStyles();
+ const email = profile.email;
+ const name = profile.name;
+ const imageUrl = profile.picture;
+ const avatarFallback = email.charAt(0).toUpperCase() + email.slice(1);
+ const emailTrimmed = email.split('@')[0];
+ const displayEmail =
+ emailTrimmed.charAt(0).toUpperCase() + emailTrimmed.slice(1);
+ displayName = name ?? displayEmail;
+ avatar = imageUrl
+ ? () =>
+ : () => {avatarFallback[0]};
+ }
+
+ return (
+ <>
+
+
+ {open ? : }
+
+
+
+
+ profile ? googleAuth.logout() : googleAuth.getAccessToken()
+ }
+ >
+
+
+
+
+ >
+ );
+}
diff --git a/packages/core/src/layout/Sidebar/index.ts b/packages/core/src/layout/Sidebar/index.ts
index baefc3d0e8..2bd961e197 100644
--- a/packages/core/src/layout/Sidebar/index.ts
+++ b/packages/core/src/layout/Sidebar/index.ts
@@ -33,3 +33,4 @@ export {
} from './config';
export type { SidebarContextType } from './config';
export { SidebarThemeToggle } from './SidebarThemeToggle';
+export { SidebarUserSettings } from './UserSettings';