2021-02-23 12:45:42 -08:00
|
|
|
import { Avatar, Divider, Image, Row, Space, Tag, Tooltip, Typography } from 'antd';
|
2021-02-03 11:49:51 -08:00
|
|
|
import React from 'react';
|
|
|
|
import { Link } from 'react-router-dom';
|
2021-03-07 11:26:47 -08:00
|
|
|
import { EntityType, GlobalTags } from '../../types.generated';
|
2021-02-23 12:45:42 -08:00
|
|
|
import defaultAvatar from '../../images/default_avatar.png';
|
|
|
|
import { useEntityRegistry } from '../useEntityRegistry';
|
2021-03-07 11:26:47 -08:00
|
|
|
import TagGroup from '../shared/TagGroup';
|
2021-02-03 11:49:51 -08:00
|
|
|
|
2021-02-23 12:45:42 -08:00
|
|
|
interface Props {
|
|
|
|
name: string;
|
|
|
|
logoUrl?: string;
|
2021-02-03 11:49:51 -08:00
|
|
|
url: string;
|
2021-02-23 12:45:42 -08:00
|
|
|
description: string;
|
2021-03-07 11:26:47 -08:00
|
|
|
type?: string;
|
|
|
|
platform?: string;
|
2021-02-23 12:45:42 -08:00
|
|
|
qualifier?: string | null;
|
2021-03-07 11:26:47 -08:00
|
|
|
tags?: GlobalTags;
|
|
|
|
owners?: Array<{ urn: string; name?: string; photoUrl?: string }>;
|
2021-02-03 11:49:51 -08:00
|
|
|
}
|
|
|
|
|
2021-02-23 12:45:42 -08:00
|
|
|
const styles = {
|
|
|
|
row: { width: '100%' },
|
|
|
|
leftColumn: { maxWidth: '75%' },
|
|
|
|
rightColumn: { maxWidth: '25%' },
|
|
|
|
logoImage: { width: '48px' },
|
2021-03-09 23:14:52 -08:00
|
|
|
name: { fontSize: '18px' },
|
2021-02-23 12:45:42 -08:00
|
|
|
typeName: { color: '#585858' },
|
|
|
|
platformName: { color: '#585858' },
|
|
|
|
ownedBy: { color: '#585858' },
|
|
|
|
};
|
|
|
|
|
|
|
|
export default function DefaultPreviewCard({
|
|
|
|
name,
|
|
|
|
logoUrl,
|
|
|
|
url,
|
|
|
|
description,
|
|
|
|
type,
|
|
|
|
platform,
|
|
|
|
qualifier,
|
|
|
|
tags,
|
|
|
|
owners,
|
|
|
|
}: Props) {
|
|
|
|
const entityRegistry = useEntityRegistry();
|
2021-02-03 11:49:51 -08:00
|
|
|
return (
|
2021-02-23 12:45:42 -08:00
|
|
|
<Row style={styles.row} justify="space-between">
|
|
|
|
<Space direction="vertical" align="start" size={28} style={styles.leftColumn}>
|
|
|
|
<Link to={url}>
|
|
|
|
<Space direction="horizontal" size={28} align="center">
|
|
|
|
{logoUrl && <Image style={styles.logoImage} src={logoUrl} preview />}
|
|
|
|
<Space direction="vertical" size={8}>
|
|
|
|
<Typography.Text strong style={styles.name}>
|
|
|
|
{name}
|
|
|
|
</Typography.Text>
|
|
|
|
<Space split={<Divider type="vertical" />} size={16}>
|
2021-03-09 23:14:52 -08:00
|
|
|
<Typography.Text>{type}</Typography.Text>
|
|
|
|
<Typography.Text strong>{platform}</Typography.Text>
|
2021-02-23 12:45:42 -08:00
|
|
|
<Tag>{qualifier}</Tag>
|
|
|
|
</Space>
|
|
|
|
</Space>
|
|
|
|
</Space>
|
2021-02-09 14:30:23 -08:00
|
|
|
</Link>
|
2021-02-23 12:45:42 -08:00
|
|
|
<Typography.Paragraph>{description}</Typography.Paragraph>
|
|
|
|
</Space>
|
|
|
|
<Space direction="vertical" align="end" size={36} style={styles.rightColumn}>
|
|
|
|
<Space>
|
2021-03-07 11:26:47 -08:00
|
|
|
<TagGroup globalTags={tags} />
|
2021-02-23 12:45:42 -08:00
|
|
|
</Space>
|
|
|
|
<Space direction="vertical" size={12}>
|
2021-03-09 23:14:52 -08:00
|
|
|
<Typography.Text strong>Owned By</Typography.Text>
|
2021-02-23 12:45:42 -08:00
|
|
|
<Avatar.Group maxCount={4}>
|
2021-03-07 11:26:47 -08:00
|
|
|
{owners?.map((owner) => (
|
|
|
|
<Tooltip title={owner.name} key={owner.urn}>
|
2021-02-23 12:45:42 -08:00
|
|
|
<Link to={`/${entityRegistry.getPathName(EntityType.CorpUser)}/${owner.urn}`}>
|
|
|
|
<Avatar src={owner.photoUrl || defaultAvatar} />
|
|
|
|
</Link>
|
|
|
|
</Tooltip>
|
|
|
|
))}
|
|
|
|
</Avatar.Group>
|
|
|
|
</Space>
|
|
|
|
</Space>
|
|
|
|
</Row>
|
2021-02-03 11:49:51 -08:00
|
|
|
);
|
|
|
|
}
|