mirror of
https://github.com/datahub-project/datahub.git
synced 2025-10-01 03:56:44 +00:00
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
![]() |
import React from 'react';
|
||
|
import { List, Typography } from 'antd';
|
||
|
import styled from 'styled-components';
|
||
|
|
||
|
import { EntityType } from '../../../types.generated';
|
||
|
import { useEntityRegistry } from '../../useEntityRegistry';
|
||
|
import { PreviewType } from '../Entity';
|
||
|
|
||
|
type Props = {
|
||
|
ownerships: { [key in EntityType]?: any[] };
|
||
|
entityPath?: string;
|
||
|
};
|
||
|
|
||
|
const ListContainer = styled.div`
|
||
|
display: default;
|
||
|
flex-grow: default;
|
||
|
`;
|
||
|
|
||
|
export default ({ ownerships, entityPath }: Props) => {
|
||
|
const entityRegistry = useEntityRegistry();
|
||
|
|
||
|
const entityType = entityRegistry.getTypeFromPathName(entityPath || '');
|
||
|
|
||
|
if (!entityType) return null;
|
||
|
|
||
|
const entitiesToShow = ownerships[entityType] || [];
|
||
|
|
||
|
return (
|
||
|
<ListContainer>
|
||
|
<List
|
||
|
dataSource={entitiesToShow}
|
||
|
header={
|
||
|
<Typography.Title level={3}>
|
||
|
{entityRegistry.getCollectionName(entityType)} they own
|
||
|
</Typography.Title>
|
||
|
}
|
||
|
renderItem={(item) => {
|
||
|
return entityRegistry.renderPreview(entityType, PreviewType.PREVIEW, item);
|
||
|
}}
|
||
|
/>
|
||
|
</ListContainer>
|
||
|
);
|
||
|
};
|