unbridled-41 opened a new pull request, #4004: URL: https://github.com/apache/rocketmq-dashboard/pull/4004
Fixes #TBD-ISSUE. ## Problem / Evidence `/ops/alerts` and `/ops/business-alerts` render the *same* `AlertsPage` component (`web/src/App.tsx:187-188`), so React Router preserves the component instance — and all of its state — when navigating between the two primary menu entries (`MainLayout.tsx:204,218`). `page`, `search` and `enabledFilter` (`alerts.tsx:159-162`) are never reset on a `domain` change; the list effect re-runs on `domain` and fetches with the retained values. User-visible failure, deterministic: 1. On 告警规则 (cluster), page to page 2 (21+ rules) and/or type a search term. 2. Click the 业务告警规则 menu entry. 3. The business list is fetched with `page: 2` (and the retained search). `opsService.listAlertRulesPage` slices out-of-range pages to `items: []` with `total` unchanged, so the table is empty while rc-pagination clamps the *displayed* current page to 1 — the page shows an empty rule list that looks like "no business rules exist". Even when the retained page is in range, the retained search silently narrows the other domain's rule list. ## Root cause / Fix Route-element reuse without a domain-state reset. Fix (in `alerts.tsx`): when the `domain` prop changes, drop the previous domain's list state during render (React's documented "adjust state when a prop changes" pattern — avoids cascading effects and the repo's `react-hooks/set-state-in-effect` lint rule): reset `page` to 1 and clear `search` / `enabledFilter` / row selection. ## Priority & scoring PRIORITY 78 = impact 30 (a primary-navigation path shows an empty or silently filtered rule list — operators can conclude business rules are missing) + blast radius 14 (both alert-rule pages, every deployment; navigation between the two menu entries is ordinary usage) + reproducibility 19 (deterministic UI interaction, no timing involved) + maintenance value 15 (restores the invariant every other list page follows: filters/pagination belong to the currently viewed list). FIX_CONFIDENCE 92. ## Tests `npx vitest run src/pages/ops/__tests__/AlertsPage.test.tsx`: - Before the fix, the new regression `resets page, search and status filters when the domain switches` failed: after switching to `domain="BUSINESS"` the fetch still carried the retained `page: 2` / `search: 'disk'` instead of reset values. - After the fix: **23 passed (23)** (22 pre-existing + 1 new). - Full web suite (`npx vitest run`): **Tests run: 923 passed (115 files)** — first full run showed 3 failures in untouched load-fragile files (NotificationDeliveriesPage pointer-events etc.), consistent with this suite's documented load sensitivity; an immediate clean full run passed all 923 with zero failures. - `npx tsc --noEmit` clean; `npx eslint` on the touched files: 0 errors (5 pre-existing warnings verified on the pristine baseline); `npm run build` succeeds. ## Risk Low. The reset only fires when the `domain` prop actually changes — the initial mount already starts from these defaults, so behavior within one domain (pagination, search, bulk selection) is unchanged. No API, route or markup changes. -- 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]
