2021-05-11 15:41:42 -07:00
|
|
|
import React, { useEffect } from 'react';
|
2021-02-03 11:49:51 -08:00
|
|
|
import { useParams } from 'react-router-dom';
|
|
|
|
import { EntityType } from '../../types.generated';
|
|
|
|
import { BrowsableEntityPage } from '../browse/BrowsableEntityPage';
|
2021-04-03 11:13:25 -07:00
|
|
|
import LineageExplorer from '../lineage/LineageExplorer';
|
|
|
|
import useIsLineageMode from '../lineage/utils/useIsLineageMode';
|
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';
|
2021-05-11 15:41:42 -07:00
|
|
|
import analytics, { EventType } from '../analytics';
|
2021-02-03 11:49:51 -08:00
|
|
|
|
|
|
|
interface RouteParams {
|
|
|
|
urn: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
entityType: EntityType;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Responsible for rendering an Entity Profile
|
|
|
|
*/
|
|
|
|
export const EntityPage = ({ entityType }: Props) => {
|
2021-06-03 11:08:43 -07:00
|
|
|
const { urn: encodedUrn } = useParams<RouteParams>();
|
|
|
|
const urn = decodeURIComponent(encodedUrn);
|
2021-02-03 11:49:51 -08:00
|
|
|
const entityRegistry = useEntityRegistry();
|
2021-03-13 07:55:29 -08:00
|
|
|
const isBrowsable = entityRegistry.getEntity(entityType).isBrowseEnabled();
|
2021-04-23 00:18:39 -07:00
|
|
|
const isLineageSupported = entityRegistry.getEntity(entityType).isLineageEnabled();
|
|
|
|
const ContainerPage = isBrowsable || isLineageSupported ? BrowsableEntityPage : SearchablePage;
|
2021-04-03 11:13:25 -07:00
|
|
|
const isLineageMode = useIsLineageMode();
|
2021-05-11 15:41:42 -07:00
|
|
|
useEffect(() => {
|
|
|
|
analytics.event({
|
|
|
|
type: EventType.EntityViewEvent,
|
|
|
|
entityType,
|
|
|
|
entityUrn: urn,
|
|
|
|
});
|
|
|
|
}, [entityType, urn]);
|
2021-04-03 11:13:25 -07:00
|
|
|
|
2021-08-31 22:00:56 -07:00
|
|
|
// show new page for datasets
|
2021-09-28 10:30:37 -07:00
|
|
|
if (
|
|
|
|
entityType === EntityType.Dataset ||
|
|
|
|
entityType === EntityType.Dashboard ||
|
|
|
|
entityType === EntityType.Chart ||
|
|
|
|
entityType === EntityType.DataFlow ||
|
|
|
|
entityType === EntityType.DataJob
|
|
|
|
) {
|
2021-08-31 22:00:56 -07:00
|
|
|
return <SearchablePage>{entityRegistry.renderProfile(entityType, urn)}</SearchablePage>;
|
|
|
|
}
|
|
|
|
|
|
|
|
// show legacy page for other entities
|
2021-02-03 11:49:51 -08:00
|
|
|
return (
|
2021-04-23 00:18:39 -07:00
|
|
|
<ContainerPage isBrowsable={isBrowsable} urn={urn} type={entityType} lineageSupported={isLineageSupported}>
|
2021-04-09 11:55:25 -07:00
|
|
|
{isLineageMode && isLineageSupported ? (
|
|
|
|
<LineageExplorer type={entityType} urn={urn} />
|
|
|
|
) : (
|
|
|
|
entityRegistry.renderProfile(entityType, urn)
|
|
|
|
)}
|
2021-03-13 07:55:29 -08:00
|
|
|
</ContainerPage>
|
2021-02-03 11:49:51 -08:00
|
|
|
);
|
|
|
|
};
|