refactor(ui): centralize Jira dispatch flow#12092
Conversation
A changelog fragment is a small Markdown file named If this PR does not need a changelog entry, add the |
|
✅ No Conflicts No conflict markers, and the branch merges cleanly into its base. |
📝 WalkthroughWalkthroughThe PR centralizes finding-group filter loading and refactors Jira dispatch around shared payloads, global state, reusable action components, batch execution, retry handling, and modal hosting. Findings tables, drawers, drill-downs, and selection actions now use the shared flow. ChangesJira dispatch and findings filtering
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant FindingsSelection
participant JiraDispatchActionItem
participant useJiraDispatchStore
participant JiraDispatchModalHost
participant SendToJiraModal
participant executeJiraDispatchBatches
FindingsSelection->>JiraDispatchActionItem: provide Jira payload
JiraDispatchActionItem->>useJiraDispatchStore: openJiraDispatch(payload)
useJiraDispatchStore->>JiraDispatchModalHost: expose activePayload
JiraDispatchModalHost->>SendToJiraModal: render payload and dispatch settings
SendToJiraModal->>executeJiraDispatchBatches: execute selected batches
executeJiraDispatchBatches-->>SendToJiraModal: aggregate success, warnings, errors, retry batch
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
🔒 Container Security ScanImage: ✅ No Vulnerabilities DetectedThe container image passed all security checks. No known CVEs were found.📋 Resources:
|
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
ui/components/findings/table/data-table-row-actions.tsx (1)
154-159: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick winDuplicate selection-resolution logic between
getDisplayIdsandgetJiraTargetIds.Both functions have identical bodies (same condition, same fallback). Consolidate into a single computed value shared by mute and Jira dispatch paths to avoid future divergence.
♻️ Proposed consolidation
- const getDisplayIds = (): string[] => { - if (isCurrentSelected && hasMultipleSelected) { - return selectedFindingIds; - } - return [muteKey]; - }; + const getDisplayIds = (): string[] => + isCurrentSelected && hasMultipleSelected ? selectedFindingIds : [muteKey]; ... - const getJiraTargetIds = (): string[] => { - if (isCurrentSelected && hasMultipleSelected) { - return selectedFindingIds; - } - return [muteKey]; - }; - - const jiraTargetIds = getJiraTargetIds(); + const jiraTargetIds = getDisplayIds();Also applies to: 170-175
🤖 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 `@ui/components/findings/table/data-table-row-actions.tsx` around lines 154 - 159, Consolidate the duplicate selection-resolution logic currently in getDisplayIds and getJiraTargetIds into one shared computed value within the row-actions component. Use that value for both mute and Jira dispatch paths, preserving the existing selectedFindingIds condition and muteKey fallback.
🤖 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.
Inline comments:
In `@ui/components/findings/table/column-finding-resources.tsx`:
- Around line 84-95: Extract the repeated jiraSelection/jiraPayload construction
into a shared buildJiraDispatchPayload helper alongside
createJiraTargetSelection, preserving the JiraDispatchModalPayload fields and
optional-result behavior. Update column-finding-resources.tsx lines 84-95,
findings-group-drill-down.tsx lines 119-130, resource-detail-drawer-content.tsx
lines 415-423, and OtherFindingRow’s inline payload construction at lines
1571-1669 to call the helper, passing only the fields required by each context.
---
Outside diff comments:
In `@ui/components/findings/table/data-table-row-actions.tsx`:
- Around line 154-159: Consolidate the duplicate selection-resolution logic
currently in getDisplayIds and getJiraTargetIds into one shared computed value
within the row-actions component. Use that value for both mute and Jira dispatch
paths, preserving the existing selectedFindingIds condition and muteKey
fallback.
🪄 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 Plus
Run ID: 7dc84965-db2d-4f6d-a54c-c7ee59154c53
📒 Files selected for processing (34)
ui/app/(prowler)/findings/page.test.tsui/app/(prowler)/findings/page.tsxui/components/findings/floating-selection-actions.test.tsxui/components/findings/floating-selection-actions.tsxui/components/findings/jira-dispatch-action-item.test.tsxui/components/findings/jira-dispatch-action-item.tsxui/components/findings/jira-dispatch-modal-host.test.tsxui/components/findings/jira-dispatch-modal-host.tsxui/components/findings/jira-dispatch-task-handler.test.tsxui/components/findings/jira-dispatch-task-handler.tsxui/components/findings/send-to-jira-modal.test.tsxui/components/findings/send-to-jira-modal.tsxui/components/findings/table/column-finding-resources.test.tsxui/components/findings/table/column-finding-resources.tsxui/components/findings/table/data-table-row-actions.test.tsxui/components/findings/table/data-table-row-actions.tsxui/components/findings/table/findings-group-drill-down.test.tsui/components/findings/table/findings-group-drill-down.tsxui/components/findings/table/findings-group-table.test.tsxui/components/findings/table/findings-group-table.tsxui/components/findings/table/resource-detail-drawer/resource-detail-drawer-content.test.tsxui/components/findings/table/resource-detail-drawer/resource-detail-drawer-content.tsxui/components/layout/main-layout/main-layout.test.tsxui/components/layout/main-layout/main-layout.tsxui/components/resources/table/resource-detail-content.tsxui/lib/finding-group-filter-options.test.tsui/lib/finding-group-filter-options.tsui/lib/jira-dispatch-action.test.tsui/lib/jira-dispatch-action.tsui/lib/jira-dispatch-execution.test.tsui/lib/jira-dispatch-execution.tsui/store/index.tsui/store/jira-dispatch/store.tsui/types/jira-dispatch.ts
💤 Files with no reviewable changes (2)
- ui/components/findings/table/findings-group-drill-down.test.ts
- ui/app/(prowler)/findings/page.test.ts
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
ui/components/findings/send-to-jira-modal.test.tsx (1)
33-33: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winKeep the
ToastActionmock clickable.The mock drops
onClick, so tests cannot exercise the “Retry failed” path. Render the action as a button and assert that retry invokesexecuteJiraDispatchBatcheswith the retry batch.🤖 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 `@ui/components/findings/send-to-jira-modal.test.tsx` at line 33, Update the ToastAction mock to render a clickable button that forwards its onClick handler, then add or update the retry test to click “Retry failed” and assert executeJiraDispatchBatches is called with the retry batch.
🤖 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.
Inline comments:
In `@ui/components/findings/send-to-jira-modal.test.tsx`:
- Around line 184-207: Update the “closes the modal before navigating to Jira
configuration” test around configureLink to mock or observe the navigation
target, then assert that onOpenChange(false) is recorded before navigation
occurs. Preserve the existing click flow and modal-closure assertion while
explicitly verifying the required ordering.
---
Outside diff comments:
In `@ui/components/findings/send-to-jira-modal.test.tsx`:
- Line 33: Update the ToastAction mock to render a clickable button that
forwards its onClick handler, then add or update the retry test to click “Retry
failed” and assert executeJiraDispatchBatches is called with the retry batch.
🪄 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 Plus
Run ID: 91f1339c-15ac-449a-b586-f7e878be42f7
📒 Files selected for processing (3)
ui/components/findings/send-to-jira-modal.test.tsxui/components/findings/send-to-jira-modal.tsxui/components/shadcn/custom/custom-banner.tsx
|
Addressed the two outside-diff CodeRabbit findings: |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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.
Inline comments:
In `@ui/components/findings/send-to-jira-modal.test.tsx`:
- Around line 234-249: Update the test around executeJiraDispatchBatchesMock and
partialToast to wait until a toast titled "Partial success" with an action has
been emitted before extracting partialToast.action and rendering it. Keep the
existing executor-call assertion, rerender flow, and retry-action rendering
unchanged.
In `@ui/components/findings/table/data-table-row-actions.tsx`:
- Around line 165-176: Update selectedResourceCount in the
createJiraDispatchPayload call to use actionTargetIds.length when dispatching
multiple Finding Group selections, while preserving the current
finding.resourcesFail value for a single group and leaving non-group targets
undefined.
🪄 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 Plus
Run ID: 6728f464-8d96-4e1d-8fd4-a7b85a2b4ec1
📒 Files selected for processing (6)
ui/components/findings/send-to-jira-modal.test.tsxui/components/findings/table/column-finding-resources.tsxui/components/findings/table/data-table-row-actions.tsxui/components/findings/table/findings-group-drill-down.tsxui/components/findings/table/resource-detail-drawer/resource-detail-drawer-content.tsxui/lib/jira-dispatch-selection.ts
Context
Follow-up to #12001. The grouped Jira dispatch UI worked through several independent entry points, but each one owned part of the Cloud gating, modal state, labels, dispatch modes, polling, and retry behavior. This made the flow harder to maintain and caused inconsistent behavior between the selection menu and row actions.
Description
No npm dependencies are added or updated. The existing
ui/changelog.d/grouped-jira-dispatch-ui.added.mdfragment from #12001 already covers this functionality.Steps to review
Send 1 Finding Group to Jiraopens the same modal.Available only in Prowler Cloudappears only in the tooltip; clicking it opens the upgrade modal.cd ui && pnpm typecheckcd ui && pnpm lint:checkcd ui && pnpm format:checkcd ui && pnpm test:unitLocal result: 342 test files and 2,243 tests passed.
Checklist
Community Checklist
SDK/CLI
UI
API
MCP Server
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Summary by CodeRabbit
New Features
Bug Fixes