messere1 opened a new pull request, #7045:
URL: https://github.com/apache/rocketmq-dashboard/pull/7045
### Which Issue(s) This PR Fixes
Fixes: none - no issue filed for this defect
### What This PR Does
The bulk-delete confirmation on the alerts page swallowed request-level
failures.
`handleBulkDelete`'s `Modal.confirm` `onOk` had a `finally` but no `catch`,
and antd's
confirm wrapper only closes the dialog on the fulfilled path — a rejected
`onOk` is
silently dropped. So when the bulk delete request failed (network error,
5xx, gateway
timeout) the dialog simply stayed open: no toast, no closed dialog, and the
OK button's
spinner reset as if nothing had happened. The operator could only guess, or
click OK
again into the same void.
Every sibling mutation on this page reports its failures:
- single rule delete surfaces `alerts.ruleDeleteFailed`,
- bulk toggle surfaces `alerts.bulkEnableFailed` /
`alerts.bulkDisableFailed`, and the
existing "keeps all selected alert rules selected when the bulk action
fails" test
already pins that contract,
- save surfaces `alerts.ruleSaveFailed`.
The bulk delete was the only silent one, and its success/partial paths
(`bulkDeleteSuccess` / `bulkDeletePartial`) were already handled.
The fix catches the rejection and surfaces a new `alerts.bulkDeleteFailed`
message with
the requested count (zh: `{count} 条告警规则删除失败`, en: `{count} alert rules
failed to
delete`), matching the `bulkEnableFailed` / `bulkDisableFailed` family. The
selection
stays armed — nothing was deleted, so every selected rule still exists and
the operator
can retry without re-checking rows, mirroring the bulk-toggle failure
behavior.
### Verification
Red/green in `src/pages/ops/__tests__/AlertsPage.test.tsx`:
- new test "shows a failure message and keeps the selection when the bulk
delete request
fails" — rejects `bulkDeleteAlertRules`, clicks 批量删除 → OK, then asserts
the toast,
the preserved checkboxes and the closed dialog. It **fails on unpatched
trunk** with
`Unable to find an element with the text: 2 条告警规则删除失败` and passes with
this patch.
- `npx vitest run src/pages/ops/__tests__/AlertsPage.test.tsx` — **38/38**
(37 pre-existing + 1 new), including the bulk-delete success, partial and
page-clamp
tests.
- `npx vitest run src/i18n/__tests__/translations.test.ts` — **2/2**.
- `npx tsc -b` clean; lint-staged (eslint + prettier) clean on the staged
files.
Assisted-by: ZCode
Signed-off-by: messere1 <[email protected]>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]