Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 2s
107 lines
3.2 KiB
TypeScript
107 lines
3.2 KiB
TypeScript
import { css } from '@rocket.chat/css-in-js';
|
|
import { Box, Button, IconButton } from '@rocket.chat/fuselage';
|
|
import { UserAvatar } from '@rocket.chat/ui-avatar';
|
|
import { useEmbeddedLayout } from '@rocket.chat/ui-client';
|
|
import type { ReactNode, ComponentProps } from 'react';
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
import MarkdownText from '../MarkdownText';
|
|
import * as Status from '../UserStatus';
|
|
import UserCardActions from './UserCardActions';
|
|
import UserCardDialog from './UserCardDialog';
|
|
import UserCardInfo from './UserCardInfo';
|
|
import UserCardRoles from './UserCardRoles';
|
|
import UserCardUsername from './UserCardUsername';
|
|
|
|
const clampStyle = css`
|
|
display: -webkit-box;
|
|
overflow: hidden;
|
|
-webkit-line-clamp: 3;
|
|
-webkit-box-orient: vertical;
|
|
word-break: break-word;
|
|
`;
|
|
|
|
export type UserCardProps = {
|
|
user?: {
|
|
nickname?: string;
|
|
name?: string;
|
|
username?: string;
|
|
etag?: string;
|
|
customStatus?: ReactNode;
|
|
roles?: ReactNode;
|
|
bio?: ReactNode;
|
|
status?: ReactNode;
|
|
localTime?: ReactNode;
|
|
};
|
|
actions?: ReactNode;
|
|
onOpenUserInfo?: () => void;
|
|
onClose?: () => void;
|
|
} & ComponentProps<typeof UserCardDialog>;
|
|
|
|
const UserCard = ({
|
|
user: { name, username, etag, customStatus, roles, bio, status = <Status.Offline />, localTime, nickname } = {},
|
|
actions,
|
|
onOpenUserInfo,
|
|
onClose,
|
|
...props
|
|
}: UserCardProps) => {
|
|
const { t } = useTranslation();
|
|
const isLayoutEmbedded = useEmbeddedLayout();
|
|
|
|
return (
|
|
<UserCardDialog aria-label={t('User_card')} {...props}>
|
|
<div>
|
|
{username && <UserAvatar username={username} etag={etag} size='x124' />}
|
|
<Box flexGrow={0} display='flex' marginBlockStart={12} alignItems='center' justifyContent='center'>
|
|
<UserCardActions aria-label={t('User_card_actions')}>{actions}</UserCardActions>
|
|
</Box>
|
|
</div>
|
|
<Box display='flex' flexDirection='column' flexGrow={1} flexShrink={1} marginInlineStart={16} width='1px'>
|
|
<Box marginBlockEnd={4} withTruncatedText display='flex' alignItems='center'>
|
|
<UserCardUsername status={status} name={name} />
|
|
{nickname && (
|
|
<Box
|
|
flexGrow={1}
|
|
flexShrink={1}
|
|
flexBasis={0}
|
|
title={nickname}
|
|
color='hint'
|
|
marginInlineStart={4}
|
|
fontScale='p2'
|
|
withTruncatedText
|
|
>
|
|
({nickname})
|
|
</Box>
|
|
)}
|
|
</Box>
|
|
{customStatus && (
|
|
<UserCardInfo marginBlockEnd={16}>
|
|
{typeof customStatus === 'string' ? (
|
|
<MarkdownText withTruncatedText variant='inlineWithoutBreaks' content={customStatus} parseEmoji={true} />
|
|
) : (
|
|
customStatus
|
|
)}
|
|
</UserCardInfo>
|
|
)}
|
|
<UserCardRoles>{roles}</UserCardRoles>
|
|
<UserCardInfo>{localTime}</UserCardInfo>
|
|
{bio && (
|
|
<UserCardInfo withTruncatedText={false} className={clampStyle} height='x60'>
|
|
{typeof bio === 'string' ? <MarkdownText variant='inline' content={bio} /> : bio}
|
|
</UserCardInfo>
|
|
)}
|
|
{onOpenUserInfo && !isLayoutEmbedded && (
|
|
<div>
|
|
<Button small onClick={onOpenUserInfo}>
|
|
{t('See_full_profile')}
|
|
</Button>
|
|
</div>
|
|
)}
|
|
</Box>
|
|
{onClose && <IconButton marginInlineStart={16} small aria-label={t('Close')} icon='cross' onClick={onClose} />}
|
|
</UserCardDialog>
|
|
);
|
|
};
|
|
|
|
export default UserCard;
|