mirror of
https://github.com/Unleash/unleash.git
synced 2025-10-27 11:02:16 +01:00
chore: show avatars in cross-project change requests table.
Keeps using the same avatar cell as the project-based change requests table, but makes showing the avatar optional. Also adds a truncator to the created by cell, to avoid weird name stacking.
This commit is contained in:
parent
b9d81e5f59
commit
a9392e134f
@ -2,24 +2,36 @@ import { TextCell } from 'component/common/Table/cells/TextCell/TextCell';
|
|||||||
import { styled, Typography } from '@mui/material';
|
import { styled, Typography } from '@mui/material';
|
||||||
import { useSearchHighlightContext } from 'component/common/Table/SearchHighlightContext/SearchHighlightContext';
|
import { useSearchHighlightContext } from 'component/common/Table/SearchHighlightContext/SearchHighlightContext';
|
||||||
import { Highlighter } from 'component/common/Highlighter/Highlighter';
|
import { Highlighter } from 'component/common/Highlighter/Highlighter';
|
||||||
|
import {
|
||||||
|
type AvatarUser,
|
||||||
|
UserAvatar,
|
||||||
|
} from 'component/common/UserAvatar/UserAvatar';
|
||||||
|
import { Truncator } from 'component/common/Truncator/Truncator';
|
||||||
|
|
||||||
const StyledContainer = styled('div')(({ theme }) => ({
|
const StyledContainer = styled('div')(({ theme }) => ({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
margin: 0,
|
margin: 0,
|
||||||
|
columnGap: theme.spacing(0.5),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const AvatarCell = ({ value }: any) => {
|
type AvatarCellProps = {
|
||||||
|
value: AvatarUser;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const AvatarCell = ({ value }: AvatarCellProps) => {
|
||||||
const { searchQuery } = useSearchHighlightContext();
|
const { searchQuery } = useSearchHighlightContext();
|
||||||
return (
|
return (
|
||||||
<TextCell>
|
<TextCell>
|
||||||
<StyledContainer>
|
<StyledContainer>
|
||||||
|
<UserAvatar disableTooltip={true} user={value} />
|
||||||
<Typography component={'span'} variant={'body2'}>
|
<Typography component={'span'} variant={'body2'}>
|
||||||
{' '}
|
<Truncator title={value?.username}>
|
||||||
<Highlighter search={searchQuery}>
|
<Highlighter search={searchQuery}>
|
||||||
{value?.username}
|
{value?.username}
|
||||||
</Highlighter>
|
</Highlighter>
|
||||||
|
</Truncator>
|
||||||
</Typography>
|
</Typography>
|
||||||
</StyledContainer>
|
</StyledContainer>
|
||||||
</TextCell>
|
</TextCell>
|
||||||
|
|||||||
@ -37,10 +37,12 @@ const StyledTooltipContent = styled(Box)({
|
|||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export type AvatarUser = Partial<
|
||||||
|
Pick<IUser, 'id' | 'name' | 'email' | 'username' | 'imageUrl'>
|
||||||
|
>;
|
||||||
|
|
||||||
export interface IUserAvatarProps extends AvatarProps {
|
export interface IUserAvatarProps extends AvatarProps {
|
||||||
user?: Partial<
|
user?: AvatarUser;
|
||||||
Pick<IUser, 'id' | 'name' | 'email' | 'username' | 'imageUrl'>
|
|
||||||
>;
|
|
||||||
src?: string;
|
src?: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
sx?: SxProps<Theme>;
|
sx?: SxProps<Theme>;
|
||||||
|
|||||||
@ -12,12 +12,10 @@ export type ChangeRequestSearchItemSchemaOneOfCreatedBy = {
|
|||||||
id: number;
|
id: number;
|
||||||
/**
|
/**
|
||||||
* Avatar image URL for the user.
|
* Avatar image URL for the user.
|
||||||
* @nullable
|
|
||||||
*/
|
*/
|
||||||
imageUrl?: string | null;
|
imageUrl?: string;
|
||||||
/**
|
/**
|
||||||
* Username of the user.
|
* Username of the user.
|
||||||
* @nullable
|
|
||||||
*/
|
*/
|
||||||
username?: string | null;
|
username?: string;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -12,12 +12,10 @@ export type ChangeRequestSearchItemSchemaOneOfFourCreatedBy = {
|
|||||||
id: number;
|
id: number;
|
||||||
/**
|
/**
|
||||||
* Avatar image URL for the user.
|
* Avatar image URL for the user.
|
||||||
* @nullable
|
|
||||||
*/
|
*/
|
||||||
imageUrl?: string | null;
|
imageUrl?: string;
|
||||||
/**
|
/**
|
||||||
* Username of the user.
|
* Username of the user.
|
||||||
* @nullable
|
|
||||||
*/
|
*/
|
||||||
username?: string | null;
|
username?: string;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user