unbridled-41 opened a new issue, #4598:
URL: https://github.com/apache/rocketmq-dashboard/issues/4598

   ## Problem
   
   The Topic CSV import patches the loaded page in local state instead of 
reloading the server page, so the rows, the header count and the pagination 
total stop matching the server.
   
   ## Evidence
   
   `web/src/pages/instance/topic.tsx` (`handleImportTopics`), before the fix:
   
   ```ts
   if (createdTopics.length > 0) {
     setTopics((previous) => {
       const createdNames = new Set(createdTopics.map((topic) => topic.name));
       return [...createdTopics, ...previous.filter((topic) => 
!createdNames.has(topic.name))];
     });
   }
   ```
   
   - `totalTopics` is only ever written by `loadTopicPage` 
(`setTotalTopics(result.total)`), so `共 N 个 Topic` and the pagination `total` 
keep the pre-import value.
   - The table renders the loaded page without client-side paging, so importing 
while on page ≥ 2 prepends the new rows onto the rows of that server page and 
can exceed the page size.
   - Regression test added with this report (`TopicPage.test.tsx`, `reloads the 
paginated inventory after importing topics`) fails on the pre-fix code: `Unable 
to find an element with the text: /共 1 个 Topic/`.
   
   ## Impact
   
   After an import the operator sees a wrong inventory size in the header and 
pagination footer, and a page that mixes rows from different server pages until 
the next manual page change or reload.
   
   ## Expected behavior
   
   An import reloads the authoritative server page, exactly like the create, 
update and delete paths on the same page (`topic.tsx`: `await 
reloadTopicPage()`), so the header count, the pagination total and the rows all 
come from the server.
   
   ## Related work
   
   - #3337 (closed, fixed by #3339): the same "local mutation instead of a 
server-page refresh" defect for topic creation, which replaced the local 
prepend with `await reloadTopicPage()`.
   - #4244 (closed, fixed by #4245): the same defect for the consumer-group 
create and CSV import flows.
   - The Topic CSV import was the remaining copy of that anti-pattern.
   
   ## PR
   
   Fix incoming.
   


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