Skip to content
Merged
Show file tree
Hide file tree
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
24 changes: 21 additions & 3 deletions src/components/AppShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1060,8 +1060,8 @@ const NESTED_LIST_BREADCRUMBS: Record<
{ parentLabel: string; parentHref: string; label: string }
> = {}

// Pattern: /<prefix>/<slug>/show/<id> or /<prefix>/<slug>/edit/<id>
const DETAIL_PATTERN = /\/([a-z0-9-]+)\/(show|edit)\/([^/]+)$/
// Pattern: /<prefix>/<slug>/show/<id>, /edit/<id>, or /pdf-preview/<id>
const DETAIL_PATTERN = /\/([a-z0-9-]+)\/(show|edit|pdf-preview)\/([^/]+)$/

function NestedListBreadcrumb({
parentLabel,
Expand Down Expand Up @@ -1092,6 +1092,7 @@ function HeaderBreadcrumb() {
const nestedList = NESTED_LIST_BREADCRUMBS[location.pathname]
const routeMatch = location.pathname.match(DETAIL_PATTERN)
const slug = routeMatch?.[1] ?? ''
const action = routeMatch?.[2] ?? ''
const id = routeMatch?.[3] ?? ''
const resourceInfo = BREADCRUMB_RESOURCES[slug]

Expand All @@ -1111,6 +1112,7 @@ function HeaderBreadcrumb() {
if (!routeMatch || !resourceInfo) return null

const recordLabel = recordName ?? `#${id}`
const isPdfPreview = action === 'pdf-preview'

return (
<nav aria-label="breadcrumb" className="flex items-center gap-1 text-sm shrink-0">
Expand All @@ -1121,7 +1123,23 @@ function HeaderBreadcrumb() {
{resourceInfo.label}
</Link>
<ChevronRight className="h-3.5 w-3.5 text-muted-foreground/40 shrink-0" aria-hidden="true" />
<span className="text-foreground font-medium">{recordLabel}</span>
{isPdfPreview ? (
<>
<Link
to={`/ocotillo/${slug}/show/${id}`}
className="text-muted-foreground hover:text-foreground transition-colors no-underline"
>
{recordLabel}
</Link>
<ChevronRight
className="h-3.5 w-3.5 text-muted-foreground/40 shrink-0"
aria-hidden="true"
/>
<span className="text-foreground font-medium">PDF Preview</span>
</>
) : (
<span className="text-foreground font-medium">{recordLabel}</span>
)}
</nav>
)
}
Expand Down
11 changes: 1 addition & 10 deletions src/pages/ocotillo/thing/well-show-pdf-preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import { getLabelFromOptionalPdfFieldKey } from '@/utils'
import { useAccessCapabilities, useWellPdfData } from '@/hooks'
import { IWell } from '@/interfaces/ocotillo'
import { IHydrographDatasource } from '@/interfaces/st2'
import { AppBreadcrumb } from '@/components/AppBreadcrumb'
import {
ocotilloCardHeaderProps,
OcotilloHeaderButtons,
Expand Down Expand Up @@ -226,15 +225,7 @@ export const WellShowPdfPreview = () => {
resource="thing-well"
recordItemId={id}
goBack={false}
breadcrumb={
<AppBreadcrumb
items={[
{ label: 'Wells', href: '/ocotillo/well' },
{ label: 'Show', href: `/ocotillo/well/show/${id}` },
{ label: 'PDF Preview' },
]}
/>
}
breadcrumb={false}
wrapperProps={{
elevation: 0,
sx: {
Expand Down
Loading