22541 consolidate static text breadcrumb route branches
This commit is contained in:
+23
-101
@@ -92,6 +92,27 @@ const Breadcrumbs = (props) => {
|
||||
return labelsByKey[viewKey] || null;
|
||||
};
|
||||
|
||||
const getStaticTextCrumbLabel = (path) => {
|
||||
const staticTextCrumbByPath = {
|
||||
"/account/register": t("account:register-new-account-heading"),
|
||||
"/dns": t("dnsCommon:service-name"),
|
||||
"/dnsapplications": t("dnsCommon:service-name"),
|
||||
"/dns/application-process": "Guidance",
|
||||
"/dns/help": "Help",
|
||||
"/dns/contact-us": t("common:footer-contact-us-link-label"),
|
||||
"/dns/applications": t("dnsApplications:page-title"),
|
||||
"/help/cookies": t("cookies:cookie-breadcrumb"),
|
||||
"/privacy": t("common:footer-privacy-link-label"),
|
||||
"/accessibility": t("common:footer-accessibility-link-label"),
|
||||
"/details-about-cookies": t("cookies:cookie-policy-title-heading"),
|
||||
"/auth/signin": t("auth:auth-page-title"),
|
||||
"/auth/verify-request": t("auth:auth-check-email-page-title"),
|
||||
"/auth/error": t("auth:auth-error-signin-error-title")
|
||||
};
|
||||
|
||||
return staticTextCrumbByPath[path] || null;
|
||||
};
|
||||
|
||||
const renderMyPortalCrumb = () => (
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
<Link href={myPortalHref} className="govuk-breadcrumbs__link">
|
||||
@@ -554,13 +575,6 @@ const Breadcrumbs = (props) => {
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
{isPath("/account/register") && (
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("account:register-new-account-heading")}
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
{isPath("/account/changepassword") && (
|
||||
<>
|
||||
{renderLinkCrumb(
|
||||
@@ -572,21 +586,6 @@ const Breadcrumbs = (props) => {
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
{isPath("/dns") && (
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("dnsCommon:service-name")}
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
|
||||
{isPath("/dnsapplications") && (
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("dnsCommon:service-name")}
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
{isPath("/dnsdetails") && (
|
||||
<>
|
||||
{renderLinkCrumb(
|
||||
@@ -609,34 +608,6 @@ const Breadcrumbs = (props) => {
|
||||
{renderCaseReferenceCrumb(caseReferenceDisplay)}
|
||||
</>
|
||||
)}
|
||||
{isPath("/dns/application-process") && (
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
Guidance
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
{isPath("/dns/help") && (
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
Help
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
{isPath("/dns/contact-us") && (
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("common:footer-contact-us-link-label")}
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
{isPath("/dns/applications") && (
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("dnsApplications:page-title")}
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
{isPath("/dns/application-view") && (
|
||||
<>
|
||||
{renderLinkCrumb(
|
||||
@@ -650,57 +621,8 @@ const Breadcrumbs = (props) => {
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
{isPath("/help/cookies") && (
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("cookies:cookie-breadcrumb")}
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
{isPath("/privacy") && (
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("common:footer-privacy-link-label")}
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
{isPath("/accessibility") && (
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t(
|
||||
"common:footer-accessibility-link-label"
|
||||
)}
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
{isPath("/details-about-cookies") && (
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("cookies:cookie-policy-title-heading")}
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
{isPath("/auth/signin") && (
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("auth:auth-page-title")}
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
{isPath("/auth/verify-request") && (
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("auth:auth-check-email-page-title")}
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
{isPath("/auth/error") && (
|
||||
<>
|
||||
<li className="govuk-breadcrumbs__list-item">
|
||||
{t("auth:auth-error-signin-error-title")}
|
||||
</li>
|
||||
</>
|
||||
)}
|
||||
{getStaticTextCrumbLabel(pathname) &&
|
||||
renderTextCrumb(getStaticTextCrumbLabel(pathname))}
|
||||
</ol>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
@@ -275,6 +275,36 @@ Follow-ups:
|
||||
|
||||
- Next slice recommendation: consider extracting a small, route-keyed breadcrumb branch map/helper grouping in `components/breadcrumbs.js` (purely structural) to reduce the long inline conditional chain while keeping one-slice behavior parity.
|
||||
|
||||
### CL-22541-J: breadcrumbs static text-only route crumb consolidation
|
||||
|
||||
date: 2026-04-09
|
||||
author: Cline
|
||||
scope: `components/breadcrumbs.js`
|
||||
type: change
|
||||
rationale: Continue the same bounded refactor cadence by consolidating repeated static text-only breadcrumb route branches into one route-label resolver.
|
||||
impact: Refactor-only structural deduplication/readability improvement; no intended route/auth/session/API/EN-CY/a11y behavior change.
|
||||
status: completed
|
||||
|
||||
Summary:
|
||||
|
||||
- Added `getStaticTextCrumbLabel(path)` in `components/breadcrumbs.js` to centralize static text-only crumb labels by pathname.
|
||||
- Replaced repeated single-line static crumb branches with one generic render path:
|
||||
- `renderTextCrumb(getStaticTextCrumbLabel(pathname))` when mapping returns a label.
|
||||
- Consolidated static branch handling for routes including:
|
||||
- account register
|
||||
- DNS index/help/contact/applications process pages
|
||||
- cookies/privacy/accessibility/static auth routes.
|
||||
- Preserved route labels (including translation keys and legacy hardcoded labels where already present).
|
||||
|
||||
Validation:
|
||||
|
||||
- `npx eslint components/breadcrumbs.js` -> pass.
|
||||
- `node tests/phase22/index.test.cjs` -> pass (combined suite).
|
||||
|
||||
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.
|
||||
|
||||
### CL-00X: 22500 `components/elements/index.js` Phase 1 helper extraction
|
||||
|
||||
date: 2026-04-07
|
||||
|
||||
Reference in New Issue
Block a user