Frun1na opened a new pull request, #6539:
URL: https://github.com/apache/rocketmq-dashboard/pull/6539
### Which Issue(s) This PR Fixes
- Fixes #6537
### Brief Description
Two sortable columns of the Lite topic table ranked a pattern the provider
could not measure as if it
were the smallest value — the average TTL as a zero TTL and the last-active
instant as epoch 0 —
while the cells render `-` for the same rows
(`web/src/pages/studio/LiteTopic.tsx:453` and `:466`).
The provider leaves both fields unset:
`RocketMQLiteTopicProvider.buildSummary` sets `lastActiveTime`
only after a session reported an access, so a pattern with no connected
consumer carries none, and
`toMillis` returns null when the broker has no TTL attribute — exactly the
case whose TTL status the
page already renders as unknown. Sorting either column ascending therefore
put those patterns first,
where a reader looking for the shortest TTL or the longest idle time saw
unmeasured rows claim those
positions.
Both sorters now use a sort-order-aware key that keeps an unset value last
in both directions, the
same technique `BrokerCluster.tsx` uses for an unmeasured TPS: Ant Design
negates the comparator for
a descending column, so an unset value cannot simply sort as the lowest
number. The other three
sortable columns stay as they are because their fields are always set
(`topicCount` is floored at 0,
`consumerCount` and `totalBacklog` are counters), and the backlog column
already has its own change
in flight.
User-visible change: sorting by average TTL or last-active time no longer
places the patterns whose
value the column renders as `-` at the top of an ascending sort. No copy is
added.
### How Did You Test This Change?
```
$ cd web && npx eslint src/pages/studio/LiteTopic.tsx
src/pages/studio/__tests__/LiteTopic.test.tsx
# clean
$ cd web && npx prettier --check src/pages/studio/LiteTopic.tsx
src/pages/studio/__tests__/LiteTopic.test.tsx
# clean
$ cd web && npx vitest run src/pages/studio/__tests__/LiteTopic.test.tsx
--maxWorkers=1 --fileParallelism=false
✓ src/pages/studio/__tests__/LiteTopic.test.tsx (18 tests) 11.3s
✓ sorts a pattern whose TTL and last-active value are unset after the
measurable ones
Test Files 1 passed (1)
Tests 18 passed (18)
$ cd web && npx tsc -b
# clean
```
The new test fails without the fix (this is the mutation check: the two
sorters are restored to the
`|| 0` form, the test is kept):
```
$ cd web && npx vitest run src/pages/studio/__tests__/LiteTopic.test.tsx
--maxWorkers=1 --fileParallelism=false
FAIL src/pages/studio/__tests__/LiteTopic.test.tsx > LiteTopic Page > sorts
a pattern whose TTL and last-active value are unset after the measurable ones
AssertionError: expected 1 to be greater than 2
Test Files 1 failed (1)
Tests 1 failed | 17 passed (18)
```
The assertions are the row order after each sort click (the measured
pattern's row must come first in
the ascending direction and stay first after the second click flips the
column to descending), so
they only pass once an unset value stops sorting as zero; the existing page
cases pin the rest of the
table.
### 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]