fix: respect namespace selection when fetching jobs#294
Conversation
Signed-off-by: A69SHUBHAM <spacekrai0@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Code Review
This pull request implements server-side namespace filtering for jobs, updating the UI columns, management component, tRPC router, schemas, and Kubernetes API fetch helper to support querying namespaced custom objects. The reviewer identified a critical issue where filtering jobs on the server side causes the list of available namespaces to shrink to only the selected one, making it impossible to switch namespaces without resetting. A state-based accumulation solution was suggested to preserve the full list of namespaces.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
|
||
| const utils = trpc.useUtils() | ||
|
|
||
| const [namespaceFilter, setNamespaceFilter] = useState<string | undefined>() |
There was a problem hiding this comment.
Issue: Since jobs are now filtered on the server side, once a namespace is selected, the jobs state will only contain jobs from that specific namespace. Because availableNamespaces (defined at line 82) is derived directly from the current jobs list, it will shrink to only contain the selected namespace. This makes it impossible for the user to switch to any other namespace from the dropdown without first selecting "All" to reset the list.
Solution: To preserve the list of all available namespaces, we can accumulate namespaces in a state variable as they are loaded.
Please apply the suggestion below to add the state and accumulation logic, and then update the createColumns call (around line 161) to pass accumulatedNamespaces instead of availableNamespaces.
const [namespaceFilter, setNamespaceFilter] = useState<string | undefined>()
const [accumulatedNamespaces, setAccumulatedNamespaces] = useState<string[]>([])
useEffect(() => {
if (jobs) {
const namespaces = jobs.map(job => job.namespace).filter(Boolean)
setAccumulatedNamespaces(prev => {
const next = Array.from(new Set([...prev, ...namespaces])).sort()
if (next.length === prev.length && next.every((v, i) => v === prev[i])) {
return prev
}
return next
})
}
}, [jobs])
Summary
This PR fixes namespace filtering on the Jobs page.
Previously, selecting a namespace only filtered jobs from the currently loaded page of results. Jobs that existed in the selected namespace but were not present in the current paginated dataset would not be displayed.
Changes
Verification
Fixes #159