This is an automated email from the ASF dual-hosted git repository.

lizhimins pushed a commit to branch rocketmq-studio
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git


The following commit(s) were added to refs/heads/rocketmq-studio by this push:
     new a1bd84fe fix(topic): preserve instance context on rebuild (#1452)
a1bd84fe is described below

commit a1bd84fefe8266673331df1a8e35d0b64450d2fc
Author: 0 <[email protected]>
AuthorDate: Mon Aug 10 20:59:09 2026 +0800

    fix(topic): preserve instance context on rebuild (#1452)
---
 .../pages/instance/__tests__/TopicPage.test.tsx    | 30 ++++++++++++++++++++++
 web/src/pages/instance/topic.tsx                   |  4 ++-
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/web/src/pages/instance/__tests__/TopicPage.test.tsx 
b/web/src/pages/instance/__tests__/TopicPage.test.tsx
index fde8eaa9..6e70fcd8 100644
--- a/web/src/pages/instance/__tests__/TopicPage.test.tsx
+++ b/web/src/pages/instance/__tests__/TopicPage.test.tsx
@@ -239,6 +239,36 @@ describe('TopicPage', () => {
     
expect(within(getTableBody()).queryByText('topic-01')).not.toBeInTheDocument();
   });
 
+  it('keeps the selected instance when rebuilding a topic without a broker 
route', async () => {
+    const user = userEvent.setup();
+    const topic = { ...buildTopics(1)[0], instanceId: 'instance-a' };
+    instanceServiceMocks.listInstances.mockResolvedValue([
+      {
+        ...selectedInstance,
+        id: 'instance-a',
+        name: 'Instance A',
+        type: 'DIRECT',
+      },
+    ]);
+    topicServiceMocks.listTopics.mockResolvedValue([topic]);
+    renderWithProviders('/instance/instance-a/topic');
+
+    expect(await screen.findByText('topic-01')).toBeInTheDocument();
+    await user.click(screen.getByRole('button', { name: /详情/ }));
+    await user.click(await screen.findByRole('button', { name: '在 Broker 上重建' 
}));
+
+    await waitFor(() =>
+      expect(topicServiceMocks.createTopic).toHaveBeenCalledWith({
+        name: 'topic-01',
+        type: 'NORMAL',
+        writeQueues: 8,
+        readQueues: 8,
+        instanceId: 'instance-a',
+      }),
+    );
+    
expect(topicServiceMocks.getTopicRoutes).toHaveBeenLastCalledWith('topic-01', 
'instance-a');
+  });
+
   it('keeps failed topics selected after a partially successful batch 
deletion', async () => {
     const user = userEvent.setup();
     topicServiceMocks.listTopics.mockResolvedValue(buildTopics(3));
diff --git a/web/src/pages/instance/topic.tsx b/web/src/pages/instance/topic.tsx
index 64f74386..7b574dd5 100644
--- a/web/src/pages/instance/topic.tsx
+++ b/web/src/pages/instance/topic.tsx
@@ -376,6 +376,7 @@ const TopicPage = () => {
 
   // Metadata lives in the database, so a record can exist without a broker 
route.
   const rebuildTopic = async (topic: Topic) => {
+    const instanceId = topic.instanceId || selectedInstanceId || undefined;
     setRebuilding(true);
     try {
       await createTopic({
@@ -383,8 +384,9 @@ const TopicPage = () => {
         type: topic.type,
         writeQueues: topic.writeQueues,
         readQueues: topic.readQueues,
+        instanceId,
       });
-      const routes = await getTopicRoutes(topic.name);
+      const routes = await getTopicRoutes(topic.name, instanceId);
       setRoutesByTopic((previous) => ({ ...previous, [topic.name]: routes }));
       message.success(`Topic「${topic.name}」已在 Broker 上重建`);
     } catch {

Reply via email to