Skip to content

Commit

Permalink
Apply changes for multiworkspace too
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesBochet committed Dec 17, 2024
1 parent 7ab1b59 commit ef42a41
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ import { useTheme } from '@emotion/react';
import styled from '@emotion/styled';
import { useState } from 'react';
import { useRecoilState, useRecoilValue } from 'recoil';
import { getImageAbsoluteURI } from 'twenty-shared';
import {
Avatar,
IconChevronDown,
MenuItemSelectAvatar,
UndecoratedLink,
} from 'twenty-ui';
import { REACT_APP_SERVER_BASE_URL } from '~/config';

const StyledLogo = styled.div<{ logo: string }>`
background: url(${({ logo }) => logo});
Expand Down Expand Up @@ -102,13 +101,9 @@ export const MultiWorkspaceDropdownButton = ({
data-testid="workspace-dropdown"
isNavigationDrawerExpanded={isNavigationDrawerExpanded}
>
<StyledLogo
logo={
getImageAbsoluteURI({
imageUrl: currentWorkspace?.logo ?? '',
baseUrl: REACT_APP_SERVER_BASE_URL,
}) ?? ''
}
<Avatar
placeholder={currentWorkspace?.displayName || ''}
avatarUrl={currentWorkspace?.logo ?? DEFAULT_WORKSPACE_LOGO}
/>
<NavigationDrawerAnimatedCollapseWrapper>
<StyledLabel>{currentWorkspace?.displayName ?? ''}</StyledLabel>
Expand All @@ -135,13 +130,9 @@ export const MultiWorkspaceDropdownButton = ({
<MenuItemSelectAvatar
text={workspace.displayName ?? '(No name)'}
avatar={
<StyledLogo
logo={
getImageAbsoluteURI({
imageUrl: workspace.logo ?? DEFAULT_WORKSPACE_LOGO,
baseUrl: REACT_APP_SERVER_BASE_URL,
}) ?? ''
}
<Avatar
placeholder={workspace.displayName || ''}
avatarUrl={workspace.logo ?? DEFAULT_WORKSPACE_LOGO}
/>
}
selected={currentWorkspace?.id === workspace.id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const NavigationDrawerHeader = ({
<MultiWorkspaceDropdownButton workspaces={workspaces} />
) : (
<StyledSingleWorkspaceContainer>
<Avatar placeholder={name.charAt(0)} avatarUrl={logo} />
<Avatar placeholder={name} avatarUrl={logo} />
<NavigationDrawerAnimatedCollapseWrapper>
<StyledName>{name}</StyledName>
</NavigationDrawerAnimatedCollapseWrapper>
Expand Down
6 changes: 2 additions & 4 deletions packages/twenty-ui/src/display/avatar/components/Avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { styled } from '@linaria/react';
import { isNonEmptyString, isUndefined } from '@sniptt/guards';
import { isNonEmptyString, isNull, isUndefined } from '@sniptt/guards';
import { useContext } from 'react';
import { useRecoilState } from 'recoil';

Expand Down Expand Up @@ -90,12 +90,10 @@ export const Avatar = ({
})
: null;

const noAvatarUrl = !isNonEmptyString(avatarImageURI);

const placeholderChar = placeholder?.[0]?.toLocaleUpperCase();

const showPlaceholder =
noAvatarUrl || invalidAvatarUrls.includes(avatarImageURI);
isNull(avatarImageURI) || invalidAvatarUrls.includes(avatarImageURI);

const handleImageError = () => {
if (isNonEmptyString(avatarImageURI)) {
Expand Down

0 comments on commit ef42a41

Please sign in to comment.