unbridled-41 opened a new pull request, #4602:
URL: https://github.com/apache/rocketmq-dashboard/pull/4602
Fixes #4598.
## Problem
The Topic CSV import patched the loaded page in local state instead of
reloading the authoritative server page, so the header count, the pagination
total and the rows stopped matching the server.
## Evidence
Regression test added with this PR
(`web/src/pages/instance/__tests__/TopicPage.test.tsx` → `reloads the paginated
inventory after importing topics`). On the pre-fix code (baseline
`origin/master` = d50ffecc, source restored with `git checkout origin/master --
web/src/pages/instance/topic.tsx` while keeping the new test):
```
× reloads the paginated inventory after importing topics 7830ms
TestingLibraryElementError: Unable to find an element with the text: /共 1 个
Topic/.
```
After the fix the same test passes and the header shows the server total.
## Root cause and fix
`handleImportTopics` prepended the created topics to the loaded page:
```ts
setTopics((previous) => {
const createdNames = new Set(createdTopics.map((topic) => topic.name));
return [...createdTopics, ...previous.filter((topic) =>
!createdNames.has(topic.name))];
});
```
`totalTopics` is only written by `loadTopicPage`
(`setTotalTopics(result.total)`), and the table renders one server page without
client-side paging, so the local patch could not keep the header (`共 N 个
Topic`), the pagination total and the row set consistent — and importing from
page ≥ 2 mixed rows of different server pages. The fix reloads the server page
(`await reloadTopicPage()`), exactly like the create, update and delete paths
on the same page.
## Priority and scoring
PRIORITY 70 = impact 26 + scope 12 + reproducibility 18 + maintenance value
14.
- Impact 26: after an import the operator sees a wrong inventory size and
(on page ≥ 2) a page mixing rows from different server pages.
- Scope 12: every user of the topic inventory CSV import.
- Reproducibility 18: deterministic, covered by the added test; two merged
sibling fixes prove the defect class.
- Maintenance value 14: the third and last copy of an anti-pattern the
project already fixed twice (#3339, #4245).
FIX_CONFIDENCE 92: one call replaced by the sibling reload, no API or
contract change, module suite green.
## Tests
- Red (baseline source + new test): `Unable to find an element with the
text: /共 1 个 Topic/` → 1 failed | 26 skipped.
- Green: `npx vitest run --maxWorkers=2
src/pages/instance/__tests__/TopicPage.test.tsx` → **27 passed (27)** (26
pre-existing + 1 new).
- Full web suite: see the verification comment below.
- `npx tsc -b` clean; `npx eslint` on both changed files → no output (0
errors, 0 warnings).
## Risk
Low. The import dialog's own row statuses (`nextRows`) are unchanged; only
the inventory refresh changed. The one behavioural difference is an extra
`listTopicsPage` request after a successful import — the same request the
create/update/delete paths already issue. If that reload fails, the existing
catch in `loadTopicPage` reports `Topic 列表加载失败,请稍后重试` and the rows stay as they
were before the import.
--
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]