messere1 opened a new pull request, #6383: URL: https://github.com/apache/rocketmq-dashboard/pull/6383
## What The ACL rule and user dialogs (`web/src/pages/instance/acl.tsx`) guard their OK buttons with the `ruleSubmitting` / `userSubmitting` states, but those flags only flip **after** `validateFields()` resolves and React re-renders. A second confirmation click inside that window runs the submit handler again: - **Rules**: `createAclRule` fires twice. The server-side `AclService.createRule` stores whatever it receives, so two identical rules land in the repository — `AclService` only checks that principal/resource are non-blank, not that the rule is unique. - **Users**: `createAclUser` fires twice; the first creates the user and the second is answered with the duplicate-username 409 (from #5072), so the operator sees a success toast and an "operation failed" toast for the same confirmation. ## How Guard `handleRuleSubmit` and `handleUserSubmit` with synchronous refs (`ruleSubmittingRef`, `userSubmittingRef`) flipped before any `await`, following the existing in-flight-ref convention already used by the admin toggle (`adminUpdateInFlightRef`) on the same page. The submitting states move ahead of `validateFields` so `confirmLoading` reflects the lock from the first click. ## Verification Red/green with `web/src/pages/instance/__tests__/AclPage.test.tsx` (vitest + testing-library): - New test `creates each ACL rule once per dialog confirmation` fills the add-rule dialog (principal, resource type, resource; the dialog opens with the default `actions: ['PUB']`), clicks the confirm button twice inside the validate window, and asserts `createAclRule` is called exactly once. - New test `creates each ACL user once per dialog confirmation` does the same for the add-user dialog and `createAclUser`. - Both tests were run against the patch (pass) and against the unpatched source (both fail because the button never locks before the second click). -- 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]
