Skip to content

frontend: CustomResourceDetails: Use DetailsGrid to allow plugins extend CR instance pages#5046

Open
sniok wants to merge 1 commit intokubernetes-sigs:mainfrom
sniok:cr-sections
Open

frontend: CustomResourceDetails: Use DetailsGrid to allow plugins extend CR instance pages#5046
sniok wants to merge 1 commit intokubernetes-sigs:mainfrom
sniok:cr-sections

Conversation

@sniok
Copy link
Copy Markdown
Contributor

@sniok sniok commented Apr 3, 2026

Custom Resource Instance details pages were not displaying custom details page sections registered by the plugins

This PR adjusts CustomResourceDetails component to use DetailsGrid that handles that already

How to test

  1. Register custom section (paste pluginLib.registerDetailsViewSection(() => "custom section") in console)
  2. Navigate to any custom resource instance page (not custom resource definition)
  3. Observe custom section on the page

Screenshots (if applicable)

CR instance page, after running pluginLib.registerDetailsViewSection(() => "custom section") in console

image

@k8s-ci-robot k8s-ci-robot requested review from ashu8912 and yolossn April 3, 2026 19:42
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sniok

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 3, 2026
@sniok sniok added the frontend Issues related to the frontend label Apr 3, 2026
@illume illume requested a review from Copilot April 4, 2026 18:33
Copy link
Copy Markdown
Contributor

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 updates the Custom Resource instance details view to use the shared DetailsGrid layout so that plugin-registered details sections (via the detailsViewSections mechanism) are rendered on CR instance pages.

Changes:

  • Replaced the CR instance details page layout (PageGrid/MainInfoSection/manual events) with DetailsGrid.
  • Wired CR instance metadata “extra info” and extra sections (conditions + legacy DetailsViewSection) through DetailsGrid props.
  • Updated storyshot snapshots to reflect the new rendered DOM structure.

Reviewed changes

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

File Description
frontend/src/components/crd/CustomResourceDetails.tsx Switches CR instance details rendering to DetailsGrid and moves extra info/sections/events into DetailsGrid props.
frontend/src/components/crd/snapshots/CustomResourceDetails.NoError.stories.storyshot Snapshot updates for the new DetailsGrid DOM structure in the success case.
frontend/src/components/crd/snapshots/CustomResourceDetails.ErrorGettingCR.stories.storyshot Snapshot updates for the new DetailsGrid DOM structure in the error case.

Comment on lines +141 to +147
<DetailsGrid
resourceType={CRClass}
name={crName}
namespace={namespace}
cluster={cluster}
backLink=""
extraInfo={item =>
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

Switching to DetailsGrid changes the loading/error UI for the CR instance: on fetch errors it now renders error.toString() (e.g. "TypeError: Failed to fetch") without including the CR kind/name (and the header title is blank while item is null). This is a regression from the previous contextual message ("Error getting custom resource {{crName}}: …"). Consider passing an explicit title to DetailsGrid (e.g. from the CRD’s kind + crName) so the page remains identifiable during loading/error, and/or adding a contextualized error presentation if you want to preserve the prior UX.

Copilot uses AI. Check for mistakes.
Comment on lines 141 to +190
@@ -172,17 +160,33 @@ function CustomResourceDetailsRenderer(props: CustomResourceDetailsRendererProps
</Link>
),
},
...getExtraInfo(extraColumns, item!.jsonData as KubeCRD),
]}
backLink=""
/>
{item!.jsonData.status?.conditions && (
<SectionBox>
<ConditionsTable resource={item.jsonData} showLastUpdate={false} />
</SectionBox>
)}
<DetailsViewSection resource={item} />
{item && <ObjectEventList object={item} />}
</PageGrid>
...getExtraInfo(
getExtraColumns(crd, item.jsonData.apiVersion?.split('/')[1] || '') || [],
item.jsonData as KubeCRD
),
]
}
extraSections={item =>
item && [
...(item.jsonData.status?.conditions
? [
{
id: 'headlamp.cr-conditions',
section: (
<SectionBox>
<ConditionsTable resource={item.jsonData} showLastUpdate={false} />
</SectionBox>
),
},
]
: []),
{
id: 'headlamp.cr-details-view',
section: <DetailsViewSection resource={item} />,
},
]
}
withEvents
/>
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

This change is specifically intended to make plugin-registered details sections appear on CR instance pages, but the existing storyshots only cover the baseline/no-error and error states and don’t assert that a registerDetailsViewSection-style section is actually rendered. Adding a story/storyshot that seeds the Redux store with a detailsViewSections entry (or uses the plugin registration helper) would prevent regressions in the plugin extension behavior this PR targets.

Copilot uses AI. Check for mistakes.
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. frontend Issues related to the frontend size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants