Skip to content

Commit

Permalink
Save user image to database and display if available (#463)
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinlu3 authored Oct 31, 2024
1 parent 6a146af commit 8bc7b4c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/docker/realm-config/oncokb-curation-realm.json
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@
"linkOnly": false,
"firstBrokerLoginFlowAlias": "first broker login",
"config": {
"syncMode": "IMPORT",
"syncMode": "FORCE",
"clientSecret": "GOOGLE_CLIENT_SECRET",
"clientId": "GOOGLE_CLIENT_ID",
"useJwksUrl": "true"
Expand Down
6 changes: 3 additions & 3 deletions src/main/webapp/app/components/sidebar/NavigationSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ import { Button, NavbarBrand } from 'reactstrap';
import { FiFileText } from 'react-icons/fi';
import { GoDatabase } from 'react-icons/go';
import { BiSearchAlt } from 'react-icons/bi';
import { FaSignOutAlt, FaUserCircle, FaExclamationTriangle, FaExternalLinkAlt, FaExternalLinkSquareAlt } from 'react-icons/fa';
import { FaSignOutAlt, FaExclamationTriangle, FaExternalLinkAlt } from 'react-icons/fa';
import { HiMiniBars3 } from 'react-icons/hi2';
import { MskccLogo } from 'app/shared/logo/MskccLogo';
import { SIDEBAR_COLLAPSED_WIDTH, SIDEBAR_EXPANDED_WIDTH } from 'app/stores/layout.store';
import _ from 'lodash';
import classNames from 'classnames';
import { WHOLE_NUMBER_REGEX } from 'app/config/constants/regex';
import CustomCursor from '../../../content/images/oncogenic-black.svg';
import { flow } from 'mobx';
import { Linkout } from 'app/shared/links/Linkout';
import { Avatar } from 'app/shared/avatar/Avatar';

const ENTITY_MENU_NAME: { [key in ENTITY_TYPE]?: string } = {
[ENTITY_TYPE.ALTERATION]: 'Alteration',
Expand Down Expand Up @@ -270,7 +270,7 @@ export const NavigationSidebar: React.FunctionComponent<StoreProps> = ({ isNavSi
</div>
<MenuDivider />
<Menu>
<SubMenu label={props.account?.firstName} icon={<FaUserCircle size={DEFAULT_NAV_ICON_SIZE} />}>
<SubMenu label={props.account?.firstName} icon={<Avatar user={props.account} />}>
<MenuItem component={<NavLink to={PAGE_ROUTE.ACCOUNT} />}>Account Settings</MenuItem>
{props.isAdmin && <MenuItem component={<NavLink to={PAGE_ROUTE.USER} />}>User Management</MenuItem>}
</SubMenu>
Expand Down
19 changes: 19 additions & 0 deletions src/main/webapp/app/shared/avatar/Avatar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import { IUser } from '../model/user.model';
import { FaUserCircle } from 'react-icons/fa';
import { DEFAULT_NAV_ICON_SIZE } from 'app/config/constants/constants';

export interface IAvatar {
user: IUser | undefined;
}

export const Avatar = ({ user }: IAvatar) => {
if (!user?.imageUrl) {
return <FaUserCircle size={DEFAULT_NAV_ICON_SIZE} />;
}
return (
<div className="d-flex justify-content-center align-items-center">
<img className="rounded-circle" src={user.imageUrl} width={DEFAULT_NAV_ICON_SIZE} height={DEFAULT_NAV_ICON_SIZE}></img>
</div>
);
};

0 comments on commit 8bc7b4c

Please sign in to comment.