Skip to content

OCPBUGS-54248: Fix empty state Create button links#423

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
pcbailey:bug-fix/54248--search-empty-state-create-button-links-broken
Jun 2, 2026
Merged

OCPBUGS-54248: Fix empty state Create button links#423
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
pcbailey:bug-fix/54248--search-empty-state-create-button-links-broken

Conversation

@pcbailey
Copy link
Copy Markdown
Contributor

@pcbailey pcbailey commented Jun 1, 2026

This PR fixes the links used for the Create button in the resource list page empty state component.

Jira: https://redhat.atlassian.net/browse/OCPBUGS-54248

Summary by CodeRabbit

  • Bug Fixes

    • Fixed create resource button functionality across multiple resource list views (ingress, network policies, network attachment definitions, routes, services).
    • Corrected component property naming inconsistencies affecting empty state rendering.
  • Refactor

    • Enhanced link component to support more flexible content rendering options.
    • Improved resource creation URL construction for consistency across list views.

@openshift-ci-robot openshift-ci-robot added jira/severity-important Referenced Jira bug's severity is important for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Jun 1, 2026
@openshift-ci-robot
Copy link
Copy Markdown

@pcbailey: This pull request references Jira Issue OCPBUGS-54248, which is invalid:

  • expected the bug to target the "5.0.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

This PR fixes the links used for the Create button in the resource list page empty state component.

Jira: https://redhat.atlassian.net/browse/OCPBUGS-54248

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

Walkthrough

This PR enhances the ExternalLink component with optional children prop support and refactors ListEmptyState to remove URL construction logic, delegating that responsibility to parent components. Multiple list views are updated to construct and pass create-button URLs consistently using a shared getResourceURL helper.

Changes

List view refactoring

Layer / File(s) Summary
ExternalLink children prop support
src/utils/components/ExternalLink/ExternalLink.tsx
ExternalLinkProps now includes an optional children?: ReactNode property, allowing flexible content composition.
ListEmptyState refactoring
src/utils/components/ListEmptyState/ListEmptyState.tsx
ListEmptyState removes useParams dependency and inline URL construction. The prop is renamed from createButtonlink to createButtonLink. The create button now navigates directly to the provided link instead of conditionally building URLs from route parameters.
IngressesList URL consolidation
src/views/ingresses/list/IngressesList.tsx
IngressesList consolidates URL construction into a single ingressURL variable computed via getResourceURL using the validated namespace, model, and YAML path. This URL is reused for both the link prop and click handler.
NAD and NetworkPolicy lists adopt getResourceURL
src/views/nads/list/NetworkAttachmentDefinitionList.tsx, src/views/networkpolicies/list/MultiNetworkPolicyList.tsx, src/views/networkpolicies/list/NetworkPolicyList.tsx
NetworkAttachmentDefinitionList, MultiNetworkPolicyList, and NetworkPolicyList import and use getResourceURL to compute namespace-aware create-button URLs. Each applies the helper with the appropriate namespace, resource model, and path constant.
RoutesList and ServiceList property corrections
src/views/routes/list/RoutesList.tsx, src/views/services/list/ServiceList.tsx
RoutesList corrects the prop name from createButtonlink to createButtonLink. ServiceList applies the same prop-name correction and switches the shared form path constant from FORM to YAML for its create-button link.

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing empty state Create button links across multiple components and files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed This is a TypeScript/React frontend project with no Ginkgo tests or Go code. The PR only modifies component files, not test files. The custom check for Ginkgo test names is not applicable.
Test Structure And Quality ✅ Passed PR contains no Ginkgo test code. This is a TypeScript/React frontend project with no Go tests; the check is not applicable.
Microshift Test Compatibility ✅ Passed No Ginkgo e2e tests are added in this PR; it contains only TypeScript/React UI component changes for a console plugin.
Single Node Openshift (Sno) Test Compatibility ✅ Passed PR contains only TypeScript/React component changes; no Ginkgo e2e tests are added. SNO compatibility check is not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies only TypeScript/React console plugin UI components (button links, empty states). Check applies only to deployment manifests, operator code, or controllers—none modified here.
Ote Binary Stdout Contract ✅ Passed PR contains only TypeScript/React component changes; no Go code, OTE binaries, or test frameworks present. Check not applicable to this codebase.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PR contains only React/TypeScript component changes with no Ginkgo e2e tests added. Custom check for IPv6/disconnected network compatibility of e2e tests is not applicable.
No-Weak-Crypto ✅ Passed PR contains no cryptographic code. Changes involve UI components, prop naming, and URL construction only—no weak crypto, custom implementations, or insecure comparisons detected.
Container-Privileges ✅ Passed PR modifies only TypeScript React UI components, not Kubernetes manifests or container configs. Container-privileges check is not applicable.
No-Sensitive-Data-In-Logs ✅ Passed No logging statements, hardcoded credentials, tokens, API keys, PII, session IDs, or customer data detected in any of the 8 modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci Bot requested review from avivtur and galkremer1 June 1, 2026 15:03
@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 1, 2026
@pcbailey
Copy link
Copy Markdown
Contributor Author

pcbailey commented Jun 1, 2026

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Jun 1, 2026
@openshift-ci-robot
Copy link
Copy Markdown

@pcbailey: This pull request references Jira Issue OCPBUGS-54248, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @lkladnit

Details

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci Bot requested a review from lkladnit June 1, 2026 15:04
@openshift-ci-robot
Copy link
Copy Markdown

@pcbailey: This pull request references Jira Issue OCPBUGS-54248, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @lkladnit

Details

In response to this:

This PR fixes the links used for the Create button in the resource list page empty state component.

Jira: https://redhat.atlassian.net/browse/OCPBUGS-54248

Summary by CodeRabbit

  • Bug Fixes

  • Fixed create resource button functionality across multiple resource list views (ingress, network policies, network attachment definitions, routes, services).

  • Corrected component property naming inconsistencies affecting empty state rendering.

  • Refactor

  • Enhanced link component to support more flexible content rendering options.

  • Improved resource creation URL construction for consistency across list views.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/utils/components/ListEmptyState/ListEmptyState.tsx (1)

65-72: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Guard against navigate(undefined) in the default create button.

createButtonLink is optional and canCreate defaults to true; if a consumer renders the default button without providing onCreate and also omits createButtonLink, the current handler calls navigate(createButtonLink) where createButtonLink is undefined (and this won’t necessarily be caught by TS since strict/strictNullChecks aren’t enabled in the repo tsconfig files).

🛡️ Proposed guard
     <Button
-      onClick={onCreate ? onCreate : () => navigate(createButtonLink)}
+      onClick={onCreate ? onCreate : () => createButtonLink && navigate(createButtonLink)}
       variant={ButtonVariant.primary}
     >
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/utils/components/ListEmptyState/ListEmptyState.tsx` around lines 65 - 72,
The defaultCreateButton's onClick can call navigate(createButtonLink) when
createButtonLink is undefined; update the handler in defaultCreateButton (and
related canCreate logic) to guard against this by checking for onCreate first,
then if createButtonLink is defined call navigate(createButtonLink), otherwise
disable the button or no-op and/or show a console warning; ensure you reference
the defaultCreateButton, onCreate, createButtonLink and navigate symbols so the
button never invokes navigate(undefined).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/utils/components/ListEmptyState/ListEmptyState.tsx`:
- Around line 65-72: The defaultCreateButton's onClick can call
navigate(createButtonLink) when createButtonLink is undefined; update the
handler in defaultCreateButton (and related canCreate logic) to guard against
this by checking for onCreate first, then if createButtonLink is defined call
navigate(createButtonLink), otherwise disable the button or no-op and/or show a
console warning; ensure you reference the defaultCreateButton, onCreate,
createButtonLink and navigate symbols so the button never invokes
navigate(undefined).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 6b9b9c80-b472-48c3-b759-4d16ce351b72

📥 Commits

Reviewing files that changed from the base of the PR and between ab4676c and 1bf4df7.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (8)
  • src/utils/components/ExternalLink/ExternalLink.tsx
  • src/utils/components/ListEmptyState/ListEmptyState.tsx
  • src/views/ingresses/list/IngressesList.tsx
  • src/views/nads/list/NetworkAttachmentDefinitionList.tsx
  • src/views/networkpolicies/list/MultiNetworkPolicyList.tsx
  • src/views/networkpolicies/list/NetworkPolicyList.tsx
  • src/views/routes/list/RoutesList.tsx
  • src/views/services/list/ServiceList.tsx

createButtonlink={SHARED_DEFAULT_PATH_NEW_RESOURCE_FORM}
createButtonLink={getResourceURL({
activeNamespace: namespace,
model: { ...NetworkPolicyModel, crd: true },
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why you need the crd: true part? and destructing the model?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

getResourceURL checks for crd: true and only builds the group~version~kind portion of the URL if it's true. I need to go through at some point and ensure all the URLs are consistent, but until then I figured this was an easier way to handle the issue.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

well sounds weird the the function is getResourceURL and the crd is true, but it's not in the scope for this PR in my opinion.

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Jun 1, 2026

@pcbailey: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jun 2, 2026
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented Jun 2, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: avivtur, pcbailey

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

@openshift-merge-bot openshift-merge-bot Bot merged commit 0380051 into openshift:main Jun 2, 2026
6 checks passed
@openshift-ci-robot
Copy link
Copy Markdown

@pcbailey: Jira Issue OCPBUGS-54248: All pull requests linked via external trackers have merged:

Jira Issue OCPBUGS-54248 has been moved to the MODIFIED state.

Details

In response to this:

This PR fixes the links used for the Create button in the resource list page empty state component.

Jira: https://redhat.atlassian.net/browse/OCPBUGS-54248

Summary by CodeRabbit

  • Bug Fixes

  • Fixed create resource button functionality across multiple resource list views (ingress, network policies, network attachment definitions, routes, services).

  • Corrected component property naming inconsistencies affecting empty state rendering.

  • Refactor

  • Enhanced link component to support more flexible content rendering options.

  • Improved resource creation URL construction for consistency across list views.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

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. jira/severity-important Referenced Jira bug's severity is important for the branch this PR is targeting. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants