mirror of
https://github.com/datahub-project/datahub.git
synced 2025-11-01 19:25:56 +00:00
fix image
This commit is contained in:
parent
e2f985a298
commit
e207d31729
@ -13,6 +13,7 @@ export interface IUser {
|
||||
id: number;
|
||||
name: string;
|
||||
userName: string;
|
||||
pictureLink: string;
|
||||
userSetting: null | {
|
||||
defaultWatch: string;
|
||||
detailDefaultView: string;
|
||||
|
||||
@ -4,6 +4,9 @@ import { IAppConfig } from '@datahub/shared/types/configurator/configurator';
|
||||
|
||||
type AvatarCreatorFunc = (obj: Partial<IAvatar>) => IAvatar;
|
||||
|
||||
// gray circle
|
||||
const fallback = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
|
||||
|
||||
/**
|
||||
* Takes a Partial<IAvatar> object and builds an IAvatar
|
||||
* @param {Partial<IAvatar>} object
|
||||
@ -11,15 +14,16 @@ type AvatarCreatorFunc = (obj: Partial<IAvatar>) => IAvatar;
|
||||
* @param {IAppConfig.userEntityProps.aviUrlFallback} aviUrlFallback
|
||||
* @return {IAvatar}
|
||||
*/
|
||||
const makeAvatar = ({ aviUrlPrimary, aviUrlFallback = '' }: IAppConfig['userEntityProps']): AvatarCreatorFunc => (
|
||||
const makeAvatar = ({ aviUrlPrimary, aviUrlFallback = fallback }: IAppConfig['userEntityProps']): AvatarCreatorFunc => (
|
||||
object: Partial<IAvatar>
|
||||
): IAvatar => {
|
||||
const props = pick(object, ['email', 'userName', 'name']);
|
||||
const props = pick(object, ['email', 'userName', 'name', 'imageUrl']);
|
||||
const { userName } = props;
|
||||
const imageFallback = aviUrlFallback || fallback;
|
||||
|
||||
return {
|
||||
imageUrl: userName && aviUrlPrimary ? aviUrlPrimary.replace('[username]', userName) : aviUrlFallback,
|
||||
imageUrlFallback: aviUrlFallback,
|
||||
imageUrl: userName && aviUrlPrimary ? aviUrlPrimary.replace('[username]', userName) : imageFallback,
|
||||
imageUrlFallback: imageFallback,
|
||||
...props
|
||||
};
|
||||
};
|
||||
|
||||
@ -91,8 +91,8 @@ export default class ApplicationRoute extends Route.extend(ApplicationRouteMixin
|
||||
getConfig('wikiLinks')
|
||||
];
|
||||
const sessionUser = this.sessionUser || {};
|
||||
const { userName = '', email = '', name = '' } = sessionUser.currentUser || {};
|
||||
const avatar = makeAvatar(avatarEntityProps)({ userName, email, name });
|
||||
const { userName = '', email = '', name = '', pictureLink = '' } = sessionUser.currentUser || {};
|
||||
const avatar = makeAvatar(avatarEntityProps)({ userName, email, name, imageUrl: pictureLink });
|
||||
|
||||
return {
|
||||
showStagingBanner,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user