Skip to content

Commit 60488e1

Browse files
committed
feat(FR-2669): add DeploymentOwnerInfo component with Relay fragment
1 parent 70198f4 commit 60488e1

1 file changed

Lines changed: 85 additions & 0 deletions

File tree

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/**
2+
@license
3+
Copyright (c) 2015-2026 Lablup Inc. All rights reserved.
4+
*/
5+
import { DeploymentOwnerInfo_deployment$key } from '../__generated__/DeploymentOwnerInfo_deployment.graphql';
6+
import { UserOutlined } from '@ant-design/icons';
7+
import { Avatar, Tooltip, Typography, theme } from 'antd';
8+
import { BAIFlex } from 'backend.ai-ui';
9+
import React from 'react';
10+
import { useTranslation } from 'react-i18next';
11+
import { graphql, useFragment } from 'react-relay';
12+
13+
interface DeploymentOwnerInfoProps {
14+
deploymentFrgmt: DeploymentOwnerInfo_deployment$key | null | undefined;
15+
}
16+
17+
const DeploymentOwnerInfo: React.FC<DeploymentOwnerInfoProps> = ({
18+
deploymentFrgmt,
19+
}) => {
20+
'use memo';
21+
const { t } = useTranslation();
22+
const { token } = theme.useToken();
23+
24+
const deployment = useFragment(
25+
graphql`
26+
fragment DeploymentOwnerInfo_deployment on ModelDeployment {
27+
id
28+
creator @since(version: "26.4.3") {
29+
id
30+
basicInfo {
31+
email
32+
username
33+
fullName
34+
}
35+
}
36+
}
37+
`,
38+
deploymentFrgmt,
39+
);
40+
41+
const email = deployment?.creator?.basicInfo?.email ?? '';
42+
const fullName = deployment?.creator?.basicInfo?.fullName ?? '';
43+
const username = deployment?.creator?.basicInfo?.username ?? '';
44+
45+
if (!email) {
46+
return <Typography.Text type="secondary">-</Typography.Text>;
47+
}
48+
49+
const initial = (fullName || username || email)
50+
.trim()
51+
.charAt(0)
52+
.toUpperCase();
53+
const tooltipLines = [
54+
t('deployment.CreatedBy'),
55+
fullName || username || email,
56+
email,
57+
]
58+
.filter(Boolean)
59+
.join('\n');
60+
61+
return (
62+
<BAIFlex gap="xs" align="center">
63+
<Tooltip
64+
title={<span style={{ whiteSpace: 'pre-line' }}>{tooltipLines}</span>}
65+
>
66+
<Avatar
67+
size="small"
68+
style={{
69+
backgroundColor: token.colorFillSecondary,
70+
color: token.colorText,
71+
flexShrink: 0,
72+
}}
73+
icon={!initial ? <UserOutlined /> : undefined}
74+
>
75+
{initial || null}
76+
</Avatar>
77+
</Tooltip>
78+
<Typography.Text ellipsis={{ tooltip: email }} style={{ maxWidth: 200 }}>
79+
{email}
80+
</Typography.Text>
81+
</BAIFlex>
82+
);
83+
};
84+
85+
export default DeploymentOwnerInfo;

0 commit comments

Comments
 (0)