feat(react): fix browse link of last breadcrumb linked to unknown page (#2391)

This commit is contained in:
Brian 2021-04-14 05:22:43 +08:00 committed by GitHub
parent 7c54004b93
commit dfc99d6b6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 3 deletions

View File

@ -22,7 +22,12 @@ export const BrowsableEntityPage = ({ urn: _urn, type: _type, children: _childre
<SearchablePage> <SearchablePage>
{data && data.browsePaths && data.browsePaths.length > 0 && ( {data && data.browsePaths && data.browsePaths.length > 0 && (
<Affix offsetTop={80}> <Affix offsetTop={80}>
<BrowsePath type={_type} path={data.browsePaths[0].path} lineageSupported={lineageSupported} /> <BrowsePath
type={_type}
path={data.browsePaths[0].path}
lineageSupported={lineageSupported}
isProfilePage
/>
</Affix> </Affix>
)} )}
{_children} {_children}

View File

@ -16,6 +16,7 @@ interface Props {
type: EntityType; type: EntityType;
path: Array<string>; path: Array<string>;
lineageSupported?: boolean; lineageSupported?: boolean;
isProfilePage?: boolean;
} }
const LineageIconGroup = styled.div` const LineageIconGroup = styled.div`
@ -56,7 +57,7 @@ const BrowseRow = styled(Row)`
/** /**
* Responsible for rendering a clickable browse path view. * Responsible for rendering a clickable browse path view.
*/ */
export const BrowsePath = ({ type, path, lineageSupported }: Props) => { export const BrowsePath = ({ type, path, lineageSupported, isProfilePage }: Props) => {
const entityRegistry = useEntityRegistry(); const entityRegistry = useEntityRegistry();
const history = useHistory(); const history = useHistory();
const location = useLocation(); const location = useLocation();
@ -70,7 +71,15 @@ export const BrowsePath = ({ type, path, lineageSupported }: Props) => {
const pathCrumbs = path.map((part, index) => ( const pathCrumbs = path.map((part, index) => (
<Breadcrumb.Item key={`${part || index}`}> <Breadcrumb.Item key={`${part || index}`}>
<Link to={`${baseBrowsePath}/${createPartialPath(path.slice(0, index + 1))}`}>{part}</Link> <Link
to={
isProfilePage && index === path.length - 1
? '#'
: `${baseBrowsePath}/${createPartialPath(path.slice(0, index + 1))}`
}
>
{part}
</Link>
</Breadcrumb.Item> </Breadcrumb.Item>
)); ));