2021-02-03 11:49:51 -08:00
|
|
|
import React from 'react';
|
|
|
|
import { useParams } from 'react-router-dom';
|
|
|
|
import { EntityType } from '../../types.generated';
|
|
|
|
import { BrowsableEntityPage } from '../browse/BrowsableEntityPage';
|
2021-03-13 07:55:29 -08:00
|
|
|
import { SearchablePage } from '../search/SearchablePage';
|
2021-02-03 11:49:51 -08:00
|
|
|
import { useEntityRegistry } from '../useEntityRegistry';
|
|
|
|
|
|
|
|
interface RouteParams {
|
|
|
|
urn: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
entityType: EntityType;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Responsible for rendering an Entity Profile
|
|
|
|
*/
|
|
|
|
export const EntityPage = ({ entityType }: Props) => {
|
|
|
|
const { urn } = useParams<RouteParams>();
|
|
|
|
const entityRegistry = useEntityRegistry();
|
2021-03-13 07:55:29 -08:00
|
|
|
const isBrowsable = entityRegistry.getEntity(entityType).isBrowseEnabled();
|
|
|
|
const ContainerPage = isBrowsable ? BrowsableEntityPage : SearchablePage;
|
2021-02-03 11:49:51 -08:00
|
|
|
return (
|
2021-03-13 07:55:29 -08:00
|
|
|
<ContainerPage urn={urn} type={entityType}>
|
2021-02-03 11:49:51 -08:00
|
|
|
{entityRegistry.renderProfile(entityType, urn)}
|
2021-03-13 07:55:29 -08:00
|
|
|
</ContainerPage>
|
2021-02-03 11:49:51 -08:00
|
|
|
);
|
|
|
|
};
|