iloveeyjafjalla opened a new pull request, #6492:
URL: https://github.com/apache/rocketmq-dashboard/pull/6492

   ### Which Issue(s) This PR Fixes
   
   - Fixes #6491
   
   ### Brief Description
   
   The system alerts feed treated a failed read as an empty feed. The list 
effect in
   `web/src/pages/ops/systemAlerts.tsx` announced a failure only through a 
transient toast
   (`message.error(t('sysAlerts.loadFailed'))`), while everything the operator 
reads stayed derived
   from the result that never arrived: the header kept claiming `本页 0 条未确认`, 
because
   `unackCount` is computed from the still-empty `alerts` array, the level 
chips counted the same
   empty array, and the page offered no way to retry without touching a filter.
   
   - The page keeps the failure visible: `Alert type="error"` with 
`common.fetchDataFailed` and a
     retry button that re-runs the query through the existing `refreshNonce`, 
so the feed recovers
     in place.
   - The header stops asserting a count it never read: `{ n: loadFailed ? '-' : 
unackCount }` — the
     same `-` convention this codebase already uses for an unread count.
   - The per-level chip counters are hidden while the failure is on screen, so 
the previous read's
     numbers are not re-presented as current. (On a first failure those 
counters are zeros, which
     antd already hides; after a failed refetch they would otherwise still show 
the previous page's
     counts while the feed claims to be current.)
   - No new UI text: `common.fetchDataFailed` and `common.retry` already exist, 
so there is no
     i18n change.
   
   ### How Did You Test This Change?
   
   Red first, on the current target branch (779b8c0e), with the added tests in 
place and only the
   source change reverted:
   
   ```
   $ cd web && npx vitest run src/pages/ops/__tests__/SystemAlertsPage.test.tsx 
--maxWorkers=1 -t "failed alert read|drops the per-level counters"
    × reports a failed alert read instead of an empty backlog
      TestingLibraryElementError: Unable to find an element with the text: 
获取数据失败
    × drops the per-level counters when a later read fails
      TestingLibraryElementError: Unable to find an element with the text: 
获取数据失败
    Test Files  1 failed (1)
         Tests  2 failed | 21 skipped (23)
   ```
   
   Green with the change:
   
   ```
   $ cd web && npx vitest run src/pages/ops/__tests__/SystemAlertsPage.test.tsx 
--maxWorkers=1
    Test Files  1 passed (1)
         Tests  23 passed (23)
   $ npx eslint src/pages/ops/systemAlerts.tsx 
src/pages/ops/__tests__/SystemAlertsPage.test.tsx
     (0 errors; the one warning is the pre-existing react-hooks/exhaustive-deps 
warning on that effect)
   $ npx prettier --check src/pages/ops/systemAlerts.tsx 
src/pages/ops/__tests__/SystemAlertsPage.test.tsx
    All matched files use Prettier code style!
   $ npx tsc -b
     (clean)
   ```
   
   The two added cases:
   
   - `reports a failed alert read instead of an empty backlog` — the first read 
rejects, so the page
     must show 获取数据失败, must not claim `本页 0 条未确认`, must offer 重试, and that 
retry must
     bring the rows back.
   - `drops the per-level counters when a later read fails` — after one 
successful read a rejected
     refetch must surface the banner and drop the chip counters, while the 
previously loaded page
     stays readable.
   
   ### Checklist
   
   - [x] One coherent change; unrelated modifications are not bundled in
   - [x] Commit subject follows Conventional Commits (`fix(ops): ...`)
   - [x] Tests added or updated for non-trivial changes (new cases in the 
existing
         `web/src/pages/ops/__tests__/SystemAlertsPage.test.tsx`)
   - [x] New UI text has both Chinese and English entries under `web/src/i18n/` 
— no new text, only
         existing keys are reused
   - [x] Architecture constraints stay green — no Java/backend change, so the 
ArchUnit checks are
         untouched
   - [x] New source files carry the ASF license header — no new files
   - [x] Documentation touched where behaviour changed — not applicable, the 
page keeps the same
         controls and wording
   
   Disclosed rather than left to be discovered on merge, because these open PRs 
touch the same file:
   
   - #5527 re-arms the loading flag at the top of this same list effect; this 
change touches only the
     effect's `.then`/`.catch` bodies, so whichever merges second needs a small 
rebase.
   - #5536 removes the level-chip `Badge` block entirely; this change adds a 
`!loadFailed` guard to
     that same conditional. If #5536 lands first, that guard disappears with 
the block and the rest
     of this change is unaffected.
   - #6127 fixed the same class of problem (a failed read reported as an empty 
list) in the
     maintenance-windows dialog of this page; this PR covers the feed itself, 
not the dialog.
   
   AI assistance: the analysis, the change and these tests were produced with 
AI assistance (an agent
   working in this repository) and reviewed by me before submission; the 
verification output above is
   from the actual runs.
   


-- 
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]

Reply via email to