Frun1na opened a new pull request, #6543:
URL: https://github.com/apache/rocketmq-dashboard/pull/6543
### Which Issue(s) This PR Fixes
- Fixes #6542
### Brief Description
The alert rules table's "Last Triggered" column ranked a rule that has never
fired as if it had
fired before every stamped rule (`web/src/pages/ops/alerts.tsx:706`).
`AlertRule.lastTriggered` is
null for such a rule — the cell renders `t('alerts.neverTriggered')` ("从未触发
/ Never") for it — and
the sorter compared the absent value as an empty string, which orders before
every real timestamp in
an ascending sort, so a reader looking for what fired recently walked past
rows that never fired.
The column now uses a comparator that keeps an absent stamp last in both
directions. Ant Design
negates the comparator for a descending column, so an absent stamp cannot
simply be treated as the
smallest text — the same reasoning the broker cluster page applies to an
unmeasured TPS and the Lite
topic table to an unset TTL.
User-visible change: sorting by last trigger time lists never-triggered
rules after the rules that
carry a timestamp, ascending and descending. No copy is added.
### How Did You Test This Change?
```
$ cd web && npx eslint src/pages/ops/alerts.tsx
src/pages/ops/__tests__/AlertsPage.test.tsx
# clean
$ cd web && npx prettier --check src/pages/ops/alerts.tsx
src/pages/ops/__tests__/AlertsPage.test.tsx
# clean
$ cd web && npx vitest run src/pages/ops/__tests__/AlertsPage.test.tsx
--maxWorkers=1 --fileParallelism=false
✓ src/pages/ops/__tests__/AlertsPage.test.tsx (34 tests) 41.4s
✓ keeps a never-triggered rule out of the first position when sorting
by the last trigger
Test Files 1 passed (1)
Tests 34 passed (34)
$ cd web && npx tsc -b
# clean
```
The new test fails without the fix (this is the mutation check: the sorter
is restored to the
`?? ''` form, the test is kept):
```
$ cd web && npx vitest run src/pages/ops/__tests__/AlertsPage.test.tsx
--maxWorkers=1 --fileParallelism=false
FAIL src/pages/ops/__tests__/AlertsPage.test.tsx > AlertsPage > keeps a
never-triggered rule out of the first position when sorting by the last trigger
AssertionError: expected 1 to be greater than 2
Test Files 1 failed (1)
Tests 1 failed | 33 passed (34)
```
The assertions are the row order after each sort click — the never-triggered
rule must follow the
stamped one in the ascending direction and stay behind it after the second
click flips the column to
descending — plus the `从未触发` cell that documents the absent value; the
existing column tests pin
that a stamped rule still renders its UTC timestamp.
### Checklist
- [x] One coherent change; unrelated modifications are not bundled in
- [x] Commit subject follows Conventional Commits (`feat:` / `fix:` /
`refactor:` / `chore:` / `docs:` / `perf:`)
- [x] Tests added or updated for non-trivial changes, test methods named
`...Test`
- [ ] New UI text has both Chinese and English entries under `web/src/i18n/`
- [ ] Architecture constraints stay green (`mvn test` runs the ArchUnit
checks)
- [ ] New source files carry the ASF license header
- [ ] Documentation touched where behaviour changed (README / `docs` /
in-app help)
--
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]