Uploaded image for project: 'OCMUI - OpenShift Cluster Manager UI'
  1. OCMUI - OpenShift Cluster Manager UI
  2. OCMUI-3299

Refactor hook calls with fallback cluster.id || '' pattern across the app

    • Icon: Epic Epic
    • Resolution: Done
    • Icon: Undefined Undefined
    • None
    • None
    • Core UI
    • Refactor hook calls with fallback cluster.id || '' pattern across the app
    • Quality / Stability / Reliability
    • False
    • Hide

      None

      Show
      None
    • False
    • 0% To Do, 0% In Progress, 100% Done
    • Done by Michal

      Throughout the codebase, there are multiple instances where hooks are being called using cluster.id || '' as a fallback for undefined cluster IDs This pattern can lead to unclear or unintended behavior, especially when the hook assumes a valid, non-empty string for clusterID.

      👉 If we do want to allow hook calls with undefined IDs, the hook itself (e.g., useEditCluster) should be updated to:
       * Either allow undefined and handle it explicitly internally

       * Or declare a default parameter value like ''

      That way, we avoid needing to update every usage across the app and improve the consistency of hook usage.

      Otherwise, if passing undefined doesn't make sense — we should audit and refactor all such hook calls to avoid calling them unless a valid cluster.id exists.

      Rationale:
      Inline fallbacks using '' hide the problem of undefined IDs and may lead to hard-to-debug issues. This issue became more prominent during recent TypeScript refactors and was noted in #[https://github.com/RedHatInsights/uhc-portal/pull/282], but is out of scope for that PR. 

              mgold@redhat.com Michal Gold
              mgold@redhat.com Michal Gold
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: