2021-05-11 17:55:45 -07:00
|
|
|
import { Divider, Image, Row, Space, Tag, Typography } from 'antd';
|
2021-02-03 11:49:51 -08:00
|
|
|
import React from 'react';
|
|
|
|
import { Link } from 'react-router-dom';
|
2021-03-23 15:18:32 -07:00
|
|
|
import styled from 'styled-components';
|
2021-05-25 10:42:35 +05:30
|
|
|
import { GlobalTags, Owner, GlossaryTerms } from '../../types.generated';
|
2021-02-23 12:45:42 -08:00
|
|
|
import { useEntityRegistry } from '../useEntityRegistry';
|
2021-05-11 17:55:45 -07:00
|
|
|
import AvatarsGroup from '../shared/avatar/AvatarsGroup';
|
2021-05-18 07:49:42 +05:30
|
|
|
import TagTermGroup from '../shared/tags/TagTermGroup';
|
2021-02-03 11:49:51 -08:00
|
|
|
|
2021-02-23 12:45:42 -08:00
|
|
|
interface Props {
|
|
|
|
name: string;
|
|
|
|
logoUrl?: string;
|
2021-05-13 09:18:49 +05:30
|
|
|
logoComponent?: JSX.Element;
|
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;
|
2021-05-11 17:55:45 -07:00
|
|
|
owners?: Array<Owner> | null;
|
2021-03-23 15:18:32 -07:00
|
|
|
snippet?: React.ReactNode;
|
2021-05-25 10:42:35 +05:30
|
|
|
glossaryTerms?: GlossaryTerms;
|
2021-05-26 09:58:43 +08:00
|
|
|
dataTestID?: string;
|
2021-02-03 11:49:51 -08:00
|
|
|
}
|
|
|
|
|
2021-03-23 15:18:32 -07:00
|
|
|
const DescriptionParagraph = styled(Typography.Paragraph)`
|
|
|
|
&&& {
|
|
|
|
margin-bottom: 0px;
|
|
|
|
padding-left: 8px;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2021-05-10 19:23:34 -07:00
|
|
|
const PreviewImage = styled(Image)`
|
|
|
|
max-height: 48px;
|
|
|
|
width: auto;
|
|
|
|
object-fit: contain;
|
|
|
|
`;
|
|
|
|
|
2021-02-23 12:45:42 -08:00
|
|
|
const styles = {
|
2021-03-23 15:18:32 -07:00
|
|
|
row: { width: '100%', marginBottom: '0px' },
|
2021-02-23 12:45:42 -08:00
|
|
|
leftColumn: { maxWidth: '75%' },
|
|
|
|
rightColumn: { maxWidth: '25%' },
|
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,
|
2021-05-13 09:18:49 +05:30
|
|
|
logoComponent,
|
2021-02-23 12:45:42 -08:00
|
|
|
url,
|
|
|
|
description,
|
|
|
|
type,
|
|
|
|
platform,
|
|
|
|
qualifier,
|
|
|
|
tags,
|
|
|
|
owners,
|
2021-03-23 15:18:32 -07:00
|
|
|
snippet,
|
2021-05-25 10:42:35 +05:30
|
|
|
glossaryTerms,
|
2021-05-26 09:58:43 +08:00
|
|
|
dataTestID,
|
2021-02-23 12:45:42 -08:00
|
|
|
}: Props) {
|
|
|
|
const entityRegistry = useEntityRegistry();
|
2021-05-11 17:55:45 -07:00
|
|
|
|
2021-02-03 11:49:51 -08:00
|
|
|
return (
|
2021-05-26 09:58:43 +08:00
|
|
|
<Row style={styles.row} justify="space-between" data-testid={dataTestID}>
|
2021-02-23 12:45:42 -08:00
|
|
|
<Space direction="vertical" align="start" size={28} style={styles.leftColumn}>
|
|
|
|
<Link to={url}>
|
2021-03-13 07:55:29 -08:00
|
|
|
<Space direction="horizontal" size={20} align="center">
|
2021-05-13 09:18:49 +05:30
|
|
|
{logoUrl ? <PreviewImage src={logoUrl} preview /> : logoComponent || ''}
|
|
|
|
|
2021-02-23 12:45:42 -08:00
|
|
|
<Space direction="vertical" size={8}>
|
|
|
|
<Typography.Text strong style={styles.name}>
|
|
|
|
{name}
|
|
|
|
</Typography.Text>
|
2021-05-13 09:18:49 +05:30
|
|
|
{(type || platform || qualifier) && (
|
|
|
|
<Space split={<Divider type="vertical" />} size={16}>
|
|
|
|
<Typography.Text>{type}</Typography.Text>
|
|
|
|
<Typography.Text strong>{platform}</Typography.Text>
|
|
|
|
{qualifier && <Tag>{qualifier}</Tag>}
|
|
|
|
</Space>
|
|
|
|
)}
|
2021-02-23 12:45:42 -08:00
|
|
|
</Space>
|
|
|
|
</Space>
|
2021-02-09 14:30:23 -08:00
|
|
|
</Link>
|
2021-03-23 15:18:32 -07:00
|
|
|
<div>
|
|
|
|
{description.length === 0 ? (
|
|
|
|
<DescriptionParagraph type="secondary">No description</DescriptionParagraph>
|
|
|
|
) : (
|
|
|
|
<DescriptionParagraph>{description}</DescriptionParagraph>
|
|
|
|
)}
|
|
|
|
{snippet}
|
|
|
|
</div>
|
2021-02-23 12:45:42 -08:00
|
|
|
</Space>
|
|
|
|
<Space direction="vertical" align="end" size={36} style={styles.rightColumn}>
|
|
|
|
<Space direction="vertical" size={12}>
|
2021-04-10 08:08:55 +08:00
|
|
|
<Typography.Text strong>{owners && owners.length > 0 ? 'Owned By' : ''}</Typography.Text>
|
2021-05-11 17:55:45 -07:00
|
|
|
<AvatarsGroup owners={owners} entityRegistry={entityRegistry} maxCount={4} />
|
2021-02-23 12:45:42 -08:00
|
|
|
</Space>
|
2021-05-25 10:42:35 +05:30
|
|
|
<TagTermGroup glossaryTerms={glossaryTerms} editableTags={tags} maxShow={3} />
|
2021-02-23 12:45:42 -08:00
|
|
|
</Space>
|
|
|
|
</Row>
|
2021-02-03 11:49:51 -08:00
|
|
|
);
|
|
|
|
}
|