Skip to content

[MAIN-IMP] Updating useJobsHook and integrating with the jobsList#97

Merged
moda20 merged 2 commits into
masterfrom
Improvement/misc-ui-ux-fixes
May 21, 2026
Merged

[MAIN-IMP] Updating useJobsHook and integrating with the jobsList#97
moda20 merged 2 commits into
masterfrom
Improvement/misc-ui-ux-fixes

Conversation

@moda20
Copy link
Copy Markdown
Owner

@moda20 moda20 commented Apr 23, 2026

Improvements :

  • Updating useJobs hook to fetch jobs using advanced filters, via the POST request. Added a jobs refresh function to invalidate the query cache.
  • Updated JobsPage to use useJobs hook, and refresh on each destructive action
  • [UI/UX] Updated the dashboard cards to have wrapping header on smaller screens

Notes :

  • This is a partial update for the useJobs hook and the jobs page, w'll see if we need to use mutations for the job actions and if we can integrate them into the custom hook

Summary by CodeRabbit

  • Style

    • Improved responsive layout for chart headers and controls with adaptive wrapping on smaller screens
    • Enhanced notification services list display with multi-line support for names and descriptions
  • Refactor

    • Dashboard now focuses on stats components for a cleaner overview
    • Jobs list and page now use a centralized job-fetching approach with more reliable refresh and loading indicators

Updating useJobs to handle advanced filtering
Updating Jobs page to use the useJobs hook for jobs fetching
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

📝 Walkthrough

Walkthrough

Refactors job fetching to React Query via an updated useJobs hook, updates jobsPage to consume that hook and call forceJobRefresh, removes job-table imports from dashboard, and adjusts responsive layout and text-clamping in AllEventStats and NotificationServicesPanel.

Changes

Cohort / File(s) Summary
Data fetching hook & consumers
src/hooks/useJobs.tsx, src/features/jobsTable/jobsPage.tsx
useJobs now uses React Query (useQuery) with composite queryKey, returns jobs, isJobFetching, and forceJobRefresh; jobsPage removed local fetch/state/refetch effects and now relies on useJobs, dispatching setJobsList when jobs updates and calling forceJobRefresh() for actions.
Dashboard cleanup
src/features/dashboard/dashboard.tsx
Removed unused job-table/pagination imports and now renders only stat components (StatsBar, AllJobsStats, AllEventStats).
UI layout adjustments
src/components/custom/charts/AllEventStats.tsx, src/components/custom/notifications/NotificationServicesPanel.tsx
AllEventStats: responsive header/container wrapping, period InputGroup width constrained and label changed to “Period”; NotificationServicesPanel: replaced single-line truncation with multi-line line-clamp for name/description and adjusted text column width for better wrapping.

Sequence Diagram(s)

sequenceDiagram
  participant JobsPage
  participant useJobsHook as useJobs
  participant ReactQueryCache as Cache
  participant JobsService as API
  participant ReduxStore as Store

  JobsPage->>useJobsHook: mount / call useJobs(params)
  useJobsHook->>Cache: check queryKey (limit,offset,sorting,status,advancedFilters,targetServer)
  alt cache miss or stale
    useJobsHook->>JobsService: fetchJobs(params)
    JobsService-->>useJobsHook: jobs[]
    useJobsHook->>Cache: store result
  end
  useJobsHook-->>JobsPage: return { jobs, isJobFetching, forceJobRefresh }
  JobsPage->>Store: dispatch setJobsList(jobs)

  Note over JobsPage,useJobsHook: On actions (row action, import, confirm)
  JobsPage->>useJobsHook: call forceJobRefresh()
  useJobsHook->>Cache: invalidate queryKey
  Cache->>useJobsHook: refetch
  useJobsHook->>JobsService: fetchJobs(updated params)
  JobsService-->>useJobsHook: jobs[]
  useJobsHook-->>JobsPage: updated jobs
  JobsPage->>Store: dispatch setJobsList(updated jobs)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 I hopped through hooks and queries bright,
Replaced old fetches with React Query light.
Dashboard trimmed, layouts neatly spun,
Jobs refresh quick — a carrot well won! 🥕✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 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: refactoring the useJobs hook and integrating it with the jobs list across the JobsPage and Dashboard components.
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.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch Improvement/misc-ui-ux-fixes

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.

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.

Actionable comments posted: 9

Caution

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

⚠️ Outside diff range comments (1)
src/features/jobsTable/jobsPage.tsx (1)

361-370: ⚠️ Potential issue | 🟠 Major

Use isPending or separate background-refetch indicator instead of isFetching for the Spinner overlay.

isJobFetching maps directly to React Query's isFetching, which is true during every fetch—including background refetches triggered by forceJobRefresh(), window refocus, and reconnect. The LoadingOverlay renders a full backdrop covering the table each time isFetching changes, creating a flashing overlay UX that hides existing data unnecessarily. For the initial loading state, use isPending. For background refetches, either:

  • Reserve isFetching for a subtle indicator (e.g., a header badge) instead of a full overlay, or
  • Use isRefetching (true only during background refetches when data exists) to avoid covering the table during initial load.

Modify useJobs to export isPending from the query, or manage these states directly in the component.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/features/jobsTable/jobsPage.tsx` around lines 361 - 370, The Spinner
currently uses isJobFetching (which maps to React Query's isFetching) and causes
a full overlay on background refetches; update the component to use the query's
isPending for the full LoadingOverlay and use isRefetching (or a separate subtle
flag) for background refresh UI instead of isFetching: change the hook useJobs
to re-export isPending and isRefetching alongside existing values, then replace
usage of isJobFetching in the Spinner with the new isPending variable and handle
isRefetching elsewhere (e.g., header badge) so forceJobRefresh/window refocus
won't trigger the full overlay.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/custom/notifications/NotificationServicesPanel.tsx`:
- Line 363: Remove the redundant text-ellipsis utility from the className in the
NotificationServicesPanel component: locate the div using className "text-sm
font-bold text-ellipsis line-clamp-2" inside NotificationServicesPanel and drop
"text-ellipsis" so the element only uses "line-clamp-2" (and other classes) —
line-clamp-2 already provides the overflow and ellipsis behavior.

In `@src/features/jobsTable/jobsPage.tsx`:
- Around line 59-64: The jobsPage useJobs call currently hard-codes limit: 99999
and offset: 0 which bypasses server-side pagination; change the call in
jobsPage.tsx to omit limit and offset (or pass undefined) so you don’t
force-fetch everything (e.g., call useJobs({ sorting, advancedFilters }) ), add
a clear TODO comment explaining this is a temporary client-side full-fetch for
the partial migration and must be revisited when pagination is reintroduced, and
verify/update useJobs to avoid silently dropping limit/offset when
advancedFilters is present so parameters are passed through consistently.
- Around line 113-120: Update the useMemo/useCallback dependency arrays so they
include only the actual stable functions used and include any non-stable
callbacks referenced: for tableEventsMemoized include
[filterAndPaginationChange, forceJobRefresh] (remove selectedRowIds), for
takeJobsAction change deps to [forceJobRefresh], for confirmBatchJobAction
change deps to [takeBatchJobsAction], and for importJobs include forceJobRefresh
in its deps (no longer []). Re-audit other hooks in this file (notably the
blocks around takeJobsAction, confirmBatchJobAction, tableEventsMemoized, and
importJobs) to ensure each dependency array exactly matches the referenced
symbols (e.g., filterAndPaginationChange, forceJobRefresh, takeBatchJobsAction)
to avoid stale closures.
- Line 224: Remove the no-op promise handler: drop the empty .finally(() => {})
from the promise chain in jobsPage.tsx (where the async fetch/update sequence
uses .finally(() => {})), leaving the chain without that redundant call so
behavior is unchanged and code is cleaner.
- Around line 66-68: The effect currently dispatches setJobsList on every
refetch because useQuery returns new array references and also omits dispatch
from deps; change the effect to only run when jobs is defined and include
dispatch in the dependency array (e.g., useEffect(() => { if (jobs !==
undefined) dispatch(setJobsList(jobs)); }, [dispatch, jobs])), and in the query
call remove placeholderData: [] or switch to keepPreviousData to avoid the
initial empty array overwriting store state; update references to the useEffect,
dispatch, setJobsList, jobs, and the query hook accordingly.

In `@src/hooks/useJobs.tsx`:
- Line 33: The local state variable const [loading, setLoading] =
useState<boolean>(false) is misleading because it only tracks the event-fetching
path (getEventsPerJobs/getJobEvents) while the main jobs fetch uses React
Query's isJobFetching; rename loading to isEventsLoading (and setLoading to
setIsEventsLoading) or remove it if not used, then update all references inside
useJobs (including getEventsPerJobs, any callers that check loading, and the
returned object at the bottom around lines ~140-148) so the hook returns a clear
isEventsLoading flag instead of loading and consumers use isJobFetching for the
primary fetch.
- Around line 44-52: The fetchJobs callback drops limit/offset when
advancedFilters is present causing inconsistent paging; update the branch that
calls jobsService.filterJobs from fetchJobs to include limit and offset (and
sorting) in the payload (e.g., merge limit and offset into the advancedFilters
body) so filtered requests respect paging, or alternatively change
jobsService.filterJobs to accept limit/offset as arguments and forward them to
the API; ensure you update references to fetchJobs and the filterJobs call
accordingly to preserve symmetric behavior with getAllJobs.
- Around line 44-52: The useCallback-wrapped fetchJobs is misleading because it
doesn't use any closure variables (only its parameters) and its dependency array
([limit, offset, status, sorting, advancedFilters]) is incorrect; also memoizing
it doesn't stabilize the queryFn passed to React Query. Fix by removing
useCallback and either inline the existing branch directly into the queryFn used
for the query or convert fetchJobs to a plain top-level function that calls
jobsService.filterJobs(...) or jobsService.getAllJobs(...); update any call
sites (the queryFn) to call the new plain function or use the inlined logic so
no stale dependency array or unnecessary memoization remains (referencing
fetchJobs, jobsService.filterJobs, jobsService.getAllJobs, and queryFn).
- Around line 134-138: The useCallback for forceJobRefresh currently omits
queryClient from its dependency array; update the useCallback that defines
forceJobRefresh (the function that calls queryClient.invalidateQueries with
queryKey ["allJobs"]) to include queryClient in its dependencies so React hooks
lint rules are satisfied and the callback stays correct when queryClient changes
(i.e., change the empty deps array to [queryClient]).

---

Outside diff comments:
In `@src/features/jobsTable/jobsPage.tsx`:
- Around line 361-370: The Spinner currently uses isJobFetching (which maps to
React Query's isFetching) and causes a full overlay on background refetches;
update the component to use the query's isPending for the full LoadingOverlay
and use isRefetching (or a separate subtle flag) for background refresh UI
instead of isFetching: change the hook useJobs to re-export isPending and
isRefetching alongside existing values, then replace usage of isJobFetching in
the Spinner with the new isPending variable and handle isRefetching elsewhere
(e.g., header badge) so forceJobRefresh/window refocus won't trigger the full
overlay.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 38e5414d-6db9-4455-84c5-7590528eac32

📥 Commits

Reviewing files that changed from the base of the PR and between 356611d and d1a2a24.

📒 Files selected for processing (5)
  • src/components/custom/charts/AllEventStats.tsx
  • src/components/custom/notifications/NotificationServicesPanel.tsx
  • src/features/dashboard/dashboard.tsx
  • src/features/jobsTable/jobsPage.tsx
  • src/hooks/useJobs.tsx
💤 Files with no reviewable changes (1)
  • src/features/dashboard/dashboard.tsx

Comment thread src/components/custom/notifications/NotificationServicesPanel.tsx Outdated
Comment thread src/features/jobsTable/jobsPage.tsx
Comment thread src/features/jobsTable/jobsPage.tsx
Comment thread src/features/jobsTable/jobsPage.tsx
Comment thread src/features/jobsTable/jobsPage.tsx Outdated
Comment thread src/hooks/useJobs.tsx
Comment thread src/hooks/useJobs.tsx
Comment thread src/hooks/useJobs.tsx
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.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/features/jobsTable/jobsPage.tsx`:
- Around line 59-68: The code duplicates job state between React Query (useJobs
-> jobs) and Redux (setJobsList / JobsList) causing transient mismatch; fix by
consolidating: remove the useEffect that dispatches setJobsList and have
DataTable read directly from the jobs returned by useJobs (use jobs ?? [] as the
DataTable data prop), and delete or stop updating setJobsList for this read path
(leave Redux-only handling for mutation flows if needed) so useJobs is the
single source of truth; alternatively, if you prefer Redux as the single source,
keep the dispatch but remove reliance on useJobs.data and stop using
placeholderData in useJobs—pick one approach and remove the redundant syncing
logic around useJobs, setJobsList, and JobsList.
- Line 363: The Spinner is using isJobFetching which is true for background
refetches; change the Spinner's loading condition to only show when there are no
jobs (e.g., use isJobFetching && !jobs?.length) so background fetches stay
silent; update the Spinner invocation that currently passes isJobFetching to
instead pass a combined condition using the jobs array (refer to Spinner,
isJobFetching, and jobs in jobsPage.tsx).

In `@src/hooks/useJobs.tsx`:
- Around line 54-69: The useQuery call currently destructures only data and
isFetching, so consumers can't tell if an empty jobs array is from a failed
fetch; update the destructuring to also capture the query error (e.g., error:
jobsError) from useQuery and include that jobsError in the hook's returned
object so callers like JobsPage can render error UI; reference the existing
useQuery invocation and the jobs/isFetching identifiers and ensure the hook
return shape exposes jobsError.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 842f8f8d-4ab8-406e-97d6-b7ae8d8e915d

📥 Commits

Reviewing files that changed from the base of the PR and between d1a2a24 and 925beaf.

📒 Files selected for processing (3)
  • src/components/custom/notifications/NotificationServicesPanel.tsx
  • src/features/jobsTable/jobsPage.tsx
  • src/hooks/useJobs.tsx

Comment thread src/features/jobsTable/jobsPage.tsx
Comment thread src/features/jobsTable/jobsPage.tsx
Comment thread src/hooks/useJobs.tsx
@moda20 moda20 merged commit 05afdc7 into master May 21, 2026
1 check passed
@moda20 moda20 deleted the Improvement/misc-ui-ux-fixes branch May 21, 2026 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant