Skip to content

Commit

Permalink
add empty check and cleaned up breadcrumbs implementation (harness#833)
Browse files Browse the repository at this point in the history
  • Loading branch information
vardanbansal-harness authored Jan 24, 2025
1 parent 0170b63 commit ee7a1da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 5 additions & 6 deletions apps/gitness/src/components-v2/breadcrumbs/breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@ import { CustomHandle } from '../../framework/routing/types'

function Breadcrumbs() {
const matches = useMatches()
const matchesWithBreadcrumb = matches.filter(match => (match.handle as CustomHandle)?.breadcrumb)

return (
<Topbar.Root>
<Topbar.Left>
<Breadcrumb.Root className="select-none">
<Breadcrumb.List>
{matches.map((match, index) => {
{matchesWithBreadcrumb.map((match, index) => {
const { breadcrumb, asLink = true } = (match.handle || {}) as CustomHandle
if (!breadcrumb) return null

const isFirst = index === 1
const isLast = index === matches.length - 1
const breadcrumbContent = breadcrumb(match.params)
const isFirst = index === 0
const isLast = index === matchesWithBreadcrumb.length - 1
const breadcrumbContent = breadcrumb!(match.params)

return (
<Breadcrumb.Item key={match.pathname}>
Expand Down
6 changes: 4 additions & 2 deletions apps/gitness/src/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -859,12 +859,14 @@ export const mfeRoutes = (mfeProjectId = '', mfeRouteRenderer: JSX.Element | nul
<AppShellMFE />
</>
),
handle: { routeName: 'toHome' },
handle: { routeName: RouteConstants.toHome },
children: [
{
path: '',
handle: {
breadcrumb: () => <span>{mfeProjectId ?? ''}</span>
...(mfeProjectId && {
breadcrumb: () => <Text>{mfeProjectId}</Text>
})
},
children: repoRoutes
}
Expand Down

0 comments on commit ee7a1da

Please sign in to comment.