2021-02-23 12:45:42 -08:00
|
|
|
import React from 'react';
|
|
|
|
import { Typography, Row, Col } from 'antd';
|
2021-03-09 23:14:52 -08:00
|
|
|
import styled from 'styled-components';
|
|
|
|
|
2021-02-23 12:45:42 -08:00
|
|
|
import { useEntityRegistry } from '../useEntityRegistry';
|
|
|
|
import { BrowseEntityCard } from '../search/BrowseEntityCard';
|
2021-10-19 22:20:31 -07:00
|
|
|
import { useGetEntityCountsQuery } from '../../graphql/app.generated';
|
|
|
|
import { EntityType } from '../../types.generated';
|
2021-02-23 12:45:42 -08:00
|
|
|
|
2021-03-09 23:14:52 -08:00
|
|
|
const Title = styled(Typography.Text)`
|
|
|
|
&& {
|
|
|
|
margin: 0px 0px 0px 120px;
|
|
|
|
font-size: 32px;
|
2021-08-31 22:00:56 -07:00
|
|
|
color: ${(props) =>
|
|
|
|
props.theme.styles['homepage-text-color'] || props.theme.styles['homepage-background-upper-fade']};
|
2021-03-09 23:14:52 -08:00
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const EntityGridRow = styled(Row)`
|
|
|
|
padding: 40px 100px;
|
2021-05-26 13:48:49 +08:00
|
|
|
margin: 0 !important;
|
2021-03-09 23:14:52 -08:00
|
|
|
`;
|
|
|
|
|
|
|
|
const BodyContainer = styled.div`
|
|
|
|
background-color: ${(props) => props.theme.styles['homepage-background-lower-fade']};
|
|
|
|
`;
|
2021-02-23 12:45:42 -08:00
|
|
|
|
2021-10-19 22:20:31 -07:00
|
|
|
// TODO: Make this list config-driven
|
|
|
|
const PERMANENT_ENTITY_TYPES = [EntityType.Dataset, EntityType.Chart, EntityType.Dashboard];
|
|
|
|
|
2021-02-23 12:45:42 -08:00
|
|
|
export const HomePageBody = () => {
|
|
|
|
const entityRegistry = useEntityRegistry();
|
2021-10-19 22:20:31 -07:00
|
|
|
const browseEntityList = entityRegistry.getBrowseEntityTypes();
|
|
|
|
|
|
|
|
const { data: entityCountData } = useGetEntityCountsQuery({
|
|
|
|
variables: {
|
|
|
|
input: {
|
|
|
|
types: browseEntityList,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const orderedEntityCounts =
|
|
|
|
entityCountData?.getEntityCounts?.counts?.sort((a, b) => {
|
|
|
|
return browseEntityList.indexOf(a.entityType) - browseEntityList.indexOf(b.entityType);
|
|
|
|
}) || PERMANENT_ENTITY_TYPES.map((entityType) => ({ count: 0, entityType }));
|
2021-07-21 02:42:21 +08:00
|
|
|
|
2021-02-23 12:45:42 -08:00
|
|
|
return (
|
2021-03-09 23:14:52 -08:00
|
|
|
<BodyContainer>
|
|
|
|
<Title>
|
2021-02-23 12:45:42 -08:00
|
|
|
<b>Explore</b> your data
|
2021-03-09 23:14:52 -08:00
|
|
|
</Title>
|
2021-04-23 00:18:39 -07:00
|
|
|
<EntityGridRow gutter={[16, 24]}>
|
2021-10-19 22:20:31 -07:00
|
|
|
{orderedEntityCounts.map(
|
|
|
|
(entityCount) =>
|
|
|
|
entityCount &&
|
|
|
|
(entityCount.count !== 0 || PERMANENT_ENTITY_TYPES.indexOf(entityCount.entityType) !== -1) && (
|
|
|
|
<Col xs={24} sm={24} md={8} key={entityCount.entityType}>
|
|
|
|
<BrowseEntityCard entityType={entityCount.entityType} />
|
|
|
|
</Col>
|
|
|
|
),
|
|
|
|
)}
|
2021-03-09 23:14:52 -08:00
|
|
|
</EntityGridRow>
|
|
|
|
</BodyContainer>
|
2021-02-23 12:45:42 -08:00
|
|
|
);
|
|
|
|
};
|