Skip to content

Fixes #39340 - PageLayout accept JSX to title prop#10992

Open
andreilakatos wants to merge 1 commit into
theforeman:developfrom
andreilakatos:page-layout-allow-components
Open

Fixes #39340 - PageLayout accept JSX to title prop#10992
andreilakatos wants to merge 1 commit into
theforeman:developfrom
andreilakatos:page-layout-allow-components

Conversation

@andreilakatos
Copy link
Copy Markdown
Contributor

Summary

Improves PageLayout reliability and regression coverage:

  • Changes PropTypes on header (PropTypes.string must not be invoked), which prevented the test file from importing the component.
  • Makes <title> / react-helmet safe when header is not a primitive: document title uses optional documentTitle, otherwise the string or number form of header; avoids passing a React tree into <title>.
  • Extends PageLayout tests for breadcrumbOptions, beforeToolbarComponent, and header as a React component (composite heading inside the PF h1).

Prerequisites for testing

  • Node/npm per repo engines in package.json
  • Dependencies installed (npm install as usual)

No extra Foreman infra (proxies, compute, DB fixtures beyond normal dev).

Test plan

  • Automated: npm test -- --testPathPattern=PageLayout.test.js
  • Smoke: Open a React page using PageLayout with string header — heading and browser title unchanged from before.

If anything uses header as a React node, optionally verify documentTitle sets the intended tab/window title when needed.

@MariaAga
Copy link
Copy Markdown
Member

MariaAga commented May 20, 2026

This seems to work similarly to


I think we should think how to unite them a bit better so we dont fix issues in only one of our templates

@andreilakatos andreilakatos force-pushed the page-layout-allow-components branch from 241f797 to cd90e4c Compare May 20, 2026 16:56
@andreilakatos andreilakatos changed the title Fixes #39294 - allow react component as git status Fixes #39339 - allow react component as git status May 20, 2026
@andreilakatos andreilakatos force-pushed the page-layout-allow-components branch from cd90e4c to 2f67677 Compare May 20, 2026 17:00
@andreilakatos andreilakatos force-pushed the page-layout-allow-components branch from 2f67677 to f79816b Compare May 20, 2026 17:00
@andreilakatos andreilakatos changed the title Fixes #39339 - allow react component as git status PageLayout accept JSX to title prop May 20, 2026
@andreilakatos andreilakatos changed the title PageLayout accept JSX to title prop Fixes #39340 - PageLayout accept JSX to title prop May 20, 2026
@andreilakatos andreilakatos force-pushed the page-layout-allow-components branch 4 times, most recently from fd7afdc to eaeba28 Compare May 21, 2026 09:03
@MariaAga MariaAga requested a review from Copilot May 21, 2026 11:13
@MariaAga MariaAga self-assigned this May 21, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors PageLayout to better support non-primitive headings and expands regression coverage, while also reusing PageLayout inside TableIndexPage to reduce duplicated page-structure code.

Changes:

  • Updated PageLayout to introduce customHeader, customToolbar, wrapper/className customization, and safer <title> handling.
  • Expanded PageLayout tests to cover breadcrumbs via breadcrumbOptions, custom header rendering, and additional layout slots.
  • Refactored TableIndexPage to render via PageLayout (moving title/breadcrumb/toolbar structure responsibility into PageLayout).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
webpack/assets/javascripts/react_app/routes/common/PageLayout/PageLayout.js Adds new layout customization props and adjusts title/header rendering logic.
webpack/assets/javascripts/react_app/routes/common/PageLayout/PageLayout.test.js Adds test coverage for new PageLayout behaviors and slots.
webpack/assets/javascripts/react_app/routes/Audits/AuditsPage/tests/snapshots/AuditsPage.test.js.snap Updates snapshots to reflect new PageLayout props/defaults.
webpack/assets/javascripts/react_app/components/PF4/TableIndexPage/TableIndexPage.js Replaces bespoke page chrome with PageLayout usage and a custom toolbar.
Comments suppressed due to low confidence (2)

webpack/assets/javascripts/react_app/routes/common/PageLayout/PageLayout.js:76

  • The <title> is now forced to '' whenever header is not a string/number (or when only customHeader is provided), which can silently clear the browser tab title. The PR description mentions falling back to an explicit documentTitle—that prop isn’t implemented here, so consider adding it and using it as the <title> source when header is a React node.
      <Head>
        <title>{titleForHead}</title>
      </Head>

webpack/assets/javascripts/react_app/routes/common/PageLayout/PageLayout.js:205

  • header is typed as PropTypes.string, but the implementation explicitly supports numbers (typeof header === 'number') and the PR intent is to allow JSX/ReactNode headings. Update the prop type to reflect the supported inputs (e.g., string/number/node) to avoid misleading warnings and to document the intended API.
  toolbarButtons: PropTypes.node,
  customToolbar: PropTypes.node,
  header: PropTypes.string,
  customHeader: PropTypes.node,
  headerTitleOuiaId: PropTypes.string,
  alwaysShowStandaloneTitleSection: PropTypes.bool,

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread webpack/assets/javascripts/react_app/routes/common/PageLayout/PageLayout.js Outdated
Comment thread webpack/assets/javascripts/react_app/routes/common/PageLayout/PageLayout.test.js Outdated
Comment thread webpack/assets/javascripts/react_app/routes/common/PageLayout/PageLayout.js Outdated
@andreilakatos andreilakatos force-pushed the page-layout-allow-components branch from d0e5e9c to 0311bb4 Compare May 21, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants