messere1 opened a new pull request, #6134:
URL: https://github.com/apache/rocketmq-dashboard/pull/6134
### What problem does this PR solve?
The alert-rule dialog can start duplicate save requests and can be torn down
while a save is in flight.
`handleSubmit` in `web/src/pages/ops/alerts.tsx` sets `submitting` only
after `await form.validateFields()` resolves. Until React re-renders, the
dialog is not locked, so:
- a rapid second click on the confirm button enters `handleSubmit` a second
time and starts a duplicate `createAlertRule`/`updateAlertRule` request;
- the modal stays closable while the request is pending, so the X button,
Esc, the mask and both cancel buttons tear down the form and bump
`metricRequestVersion` mid-save — the operation still completes afterwards, but
the UI already looks cancelled.
Original report: #1575 (issue closed as not planned by the stale sweep, not
invalidated as fixed).
### What is changed and how it works?
- `handleSubmit` now takes a synchronous `submitInFlightRef` guard and flips
`submitting` before validation starts, so the dialog locks in the same tick as
the first click (same ref-guard style the page already uses for metric
requests).
- The modal becomes `closable={false}` / `keyboard={false}` /
`maskClosable={false}` and both cancel handlers no-op while a submission is in
flight; the dialog unlocks in `finally`.
Scope is `AlertsPage` and its test only, as requested in the issue.
### Verifies
- [x] `npx vitest run src/pages/ops/__tests__/AlertsPage.test.tsx` — 31/31
pass, including the new regression test which fails on the unpatched tip
(confirm button not locked after the first click).
- [x] `npx eslint` on the touched files — 0 errors (only the pre-existing
warnings).
The new test double-clicks the confirm button while the update request is
held pending, asserts exactly one `updateAlertRule` call, asserts a cancel
click cannot close the dialog mid-flight, and then resolves the save.
--
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]