import { buildEntityPath, EntityKind, isAbsolutePath, isDataset, } from '@h5web/shared'; import { capitalize } from 'lodash'; import { Suspense, memo } from 'react'; import { ErrorBoundary } from 'react-error-boundary'; import { useDataContext } from '../providers/DataProvider'; import AttrErrorFallback from './AttrErrorFallback'; import AttrValueLoader from './AttrValueLoader'; import AttributesInfo from './AttributesInfo'; import EntityInfo from './EntityInfo'; import FiltersInfo from './FiltersInfo'; import MetadataTable from './MetadataTable'; import styles from './MetadataViewer.module.css'; interface Props { path: string; fileIndex:number onSelectPath: (path: string) => void; } function MetadataViewer(props: Props) { const { path,fileIndex, onSelectPath } = props; const { entitiesStore } = useDataContext(); const entity = entitiesStore.get(path); const { kind, attributes } = entity; const title = kind === EntityKind.Unresolved ? 'Entity' : capitalize(kind); return (
{attributes.length > 0 && ( }> { const absolutePath = isAbsolutePath(pathToFollow) ? pathToFollow : buildEntityPath(path, pathToFollow); onSelectPath(absolutePath); }} /> )} {isDataset(entity) && entity.filters && ( )}
); } // Optimise consecutive renders when selecting a link in the explorer export default memo(MetadataViewer);