Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions studio/src/components/PageHeader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ function Pageheader() {
: pathSnippets[0];

const isBreadCrumbsHidden =
(pathSnippets.includes('edit') || pathSnippets.includes('create')) &&
(entity === 'posts' || entity === 'pages' || entity === 'fact-checks'); // redundant entity check for fact-checks?
(pathSnippets.includes('edit') || pathSnippets.includes('create')) &&
['posts', 'pages', 'fact-checks'].includes(entity);
const breadcrumbItems = useMemo(() => {
const urlBreadcrumbItems = pathSnippets.map((empty, index) => {
const url = `/${pathSnippets.slice(0, index + 1).join('/')}`;
Expand Down Expand Up @@ -78,8 +78,8 @@ function Pageheader() {
}
});
return _.filter(urlBreadcrumbItems);

}, [pathSnippets, location.pathname]);

const handleOnBack = () => {
if (isBreadCrumbsHidden) {
if (
Expand All @@ -106,19 +106,21 @@ function Pageheader() {
}
};
const itemRender = (route, params, routes, paths) => {

const breadcrumbItem = breadcrumbItems.find(item => item.path === route.path);
const last = routes.indexOf(route) === routes.length - 1;
if (last && routes.length > 1) {
if (last) {
return (
!isBreadCrumbsHidden && (
<h2 style={{ display: 'inline', color: '#000000d9' }}>{route.breadcrumbName}</h2>
<h2 style={{ display: 'inline', color: '#000000d9' }}>{breadcrumbItem?.breadcrumbName}</h2>
)
);
}
return (
!isBreadCrumbsHidden && (
<h2 style={{ display: 'inline' }}>
<Link style={routes.length === 1 ? { color: '#000000d9' } : null} to={route.path}>
{route.breadcrumbName}
{breadcrumbItem?.breadcrumbName}
</Link>
</h2>
)
Expand All @@ -130,6 +132,7 @@ function Pageheader() {
['members', 'advanced', 'website', 'admin'].includes(entity) ||
location.pathname.split('/').pop() === 'create'
)

return (
<AntPageHeader
backIcon={isBreadCrumbsHidden ? <LeftOutlined /> : null}
Expand Down