22541 extract grouped breadcrumb pair helpers for myportal and dns routes
This commit is contained in:
+35
-46
@@ -121,6 +121,13 @@ const Breadcrumbs = (props) => {
|
|||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const renderMyPortalSectionCrumbs = (sectionLabel) => (
|
||||||
|
<>
|
||||||
|
{renderMyPortalCrumb()}
|
||||||
|
{renderTextCrumb(sectionLabel)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
const renderCaseReferenceCrumb = (referenceValue) => (
|
const renderCaseReferenceCrumb = (referenceValue) => (
|
||||||
<li className="govuk-breadcrumbs__list-item">
|
<li className="govuk-breadcrumbs__list-item">
|
||||||
{t("common:breadcrumb-case-reference")}: {referenceValue}
|
{t("common:breadcrumb-case-reference")}: {referenceValue}
|
||||||
@@ -165,6 +172,18 @@ const Breadcrumbs = (props) => {
|
|||||||
listItemClass = "govuk-breadcrumbs__link-item backChevron"
|
listItemClass = "govuk-breadcrumbs__link-item backChevron"
|
||||||
) => renderAnchorCrumb("#", t("common:back-link"), onClick, listItemClass);
|
) => renderAnchorCrumb("#", t("common:back-link"), onClick, listItemClass);
|
||||||
|
|
||||||
|
const renderDnsCaseReferenceCrumbs = (referenceValue) => (
|
||||||
|
<>
|
||||||
|
{renderLinkCrumb(
|
||||||
|
isWelsh
|
||||||
|
? router.locale + "/dnsapplications"
|
||||||
|
: "/dnsapplications",
|
||||||
|
t("dnsCommon:service-name")
|
||||||
|
)}
|
||||||
|
{renderCaseReferenceCrumb(referenceValue)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
const { breadcrumbHref, caseResultsHref, breadcrumbLabel } =
|
const { breadcrumbHref, caseResultsHref, breadcrumbLabel } =
|
||||||
resolveCaseBreadcrumbState({
|
resolveCaseBreadcrumbState({
|
||||||
query: router.query,
|
query: router.query,
|
||||||
@@ -226,30 +245,18 @@ const Breadcrumbs = (props) => {
|
|||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{isPath("/myportal/addresssearch") && (
|
{isPath("/myportal/addresssearch") &&
|
||||||
<>
|
renderMyPortalSectionCrumbs(
|
||||||
{renderMyPortalCrumb()}
|
t("common:breadcrumb-address-search")
|
||||||
{renderTextCrumb(
|
)}
|
||||||
t("common:breadcrumb-address-search")
|
{isPath("/myportal/advancedsearch") &&
|
||||||
)}
|
renderMyPortalSectionCrumbs(
|
||||||
</>
|
t("common:breadcrumb-advanced-search")
|
||||||
)}
|
)}
|
||||||
{isPath("/myportal/advancedsearch") && (
|
{isPath("/myportal/contactus") &&
|
||||||
<>
|
renderMyPortalSectionCrumbs(
|
||||||
{renderMyPortalCrumb()}
|
t("common:footer-contact-us-link-label")
|
||||||
{renderTextCrumb(
|
)}
|
||||||
t("common:breadcrumb-advanced-search")
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{isPath("/myportal/contactus") && (
|
|
||||||
<>
|
|
||||||
{renderMyPortalCrumb()}
|
|
||||||
{renderTextCrumb(
|
|
||||||
t("common:footer-contact-us-link-label")
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{isPath("/contactus") && (
|
{isPath("/contactus") && (
|
||||||
<>
|
<>
|
||||||
{renderTextCrumb(
|
{renderTextCrumb(
|
||||||
@@ -586,28 +593,10 @@ const Breadcrumbs = (props) => {
|
|||||||
</li>
|
</li>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{isPath("/dnsdetails") && (
|
{isPath("/dnsdetails") &&
|
||||||
<>
|
renderDnsCaseReferenceCrumbs(currentReference)}
|
||||||
{renderLinkCrumb(
|
{isPath("/dns/[developmentName]") &&
|
||||||
isWelsh
|
renderDnsCaseReferenceCrumbs(caseReferenceDisplay)}
|
||||||
? router.locale + "/dnsapplications"
|
|
||||||
: "/dnsapplications",
|
|
||||||
t("dnsCommon:service-name")
|
|
||||||
)}
|
|
||||||
{renderCaseReferenceCrumb(currentReference)}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{isPath("/dns/[developmentName]") && (
|
|
||||||
<>
|
|
||||||
{renderLinkCrumb(
|
|
||||||
isWelsh
|
|
||||||
? router.locale + "/dnsapplications"
|
|
||||||
: "/dnsapplications",
|
|
||||||
t("dnsCommon:service-name")
|
|
||||||
)}
|
|
||||||
{renderCaseReferenceCrumb(caseReferenceDisplay)}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{isPath("/dns/application-view") && (
|
{isPath("/dns/application-view") && (
|
||||||
<>
|
<>
|
||||||
{renderLinkCrumb(
|
{renderLinkCrumb(
|
||||||
|
|||||||
@@ -305,6 +305,34 @@ Follow-ups:
|
|||||||
|
|
||||||
- Next slice recommendation: extract a small grouped helper for recurring two-crumb route pairs (e.g., my-portal + section label, dns list + case reference) to reduce the remaining conditional chain while preserving explicit route behavior.
|
- Next slice recommendation: extract a small grouped helper for recurring two-crumb route pairs (e.g., my-portal + section label, dns list + case reference) to reduce the remaining conditional chain while preserving explicit route behavior.
|
||||||
|
|
||||||
|
### CL-22541-K: breadcrumbs grouped two-crumb helper extraction
|
||||||
|
|
||||||
|
date: 2026-04-09
|
||||||
|
author: Cline
|
||||||
|
scope: `components/breadcrumbs.js`
|
||||||
|
type: change
|
||||||
|
rationale: Continue the same bounded refactor cadence by extracting recurring two-crumb patterns into small grouped helpers while preserving explicit route branches.
|
||||||
|
impact: Refactor-only readability/deduplication improvement; no intended route/auth/session/API/EN-CY/a11y behavior change.
|
||||||
|
status: completed
|
||||||
|
|
||||||
|
Summary:
|
||||||
|
|
||||||
|
- Added grouped helper `renderMyPortalSectionCrumbs(sectionLabel)` for recurring my-portal + section text pairs.
|
||||||
|
- Added grouped helper `renderDnsCaseReferenceCrumbs(referenceValue)` for recurring DNS applications link + case-reference pairs.
|
||||||
|
- Replaced duplicated route branches with grouped helper usage for:
|
||||||
|
- `/myportal/addresssearch`, `/myportal/advancedsearch`, `/myportal/contactus`
|
||||||
|
- `/dnsdetails`, `/dns/[developmentName]`
|
||||||
|
- Preserved existing href behavior (including EN/CY DNS applications link), labels, and case-reference rendering.
|
||||||
|
|
||||||
|
Validation:
|
||||||
|
|
||||||
|
- `npx eslint components/breadcrumbs.js` -> pass.
|
||||||
|
- `node tests/phase22/index.test.cjs` -> pass (combined suite).
|
||||||
|
|
||||||
|
Follow-ups:
|
||||||
|
|
||||||
|
- Next slice recommendation: extract a small route-to-renderer map for static single-branch crumbs (where branch has no bespoke side-effects) so the main JSX conditional chain shrinks further without altering explicit behavior in dynamic/sensitive branches.
|
||||||
|
|
||||||
### CL-00X: 22500 `components/elements/index.js` Phase 1 helper extraction
|
### CL-00X: 22500 `components/elements/index.js` Phase 1 helper extraction
|
||||||
|
|
||||||
date: 2026-04-07
|
date: 2026-04-07
|
||||||
|
|||||||
Reference in New Issue
Block a user