Skip to content

feat(topic): edit topic configuration from the topic page - #4249

Closed
unbridled-41 wants to merge 1 commit into
apache:rocketmq-studiofrom
unbridled-41:feat/topic-config-edit
Closed

unbridled-41 wants to merge 1 commit into
apache:rocketmq-studiofrom
unbridled-41:feat/topic-config-edit

Conversation

@unbridled-41

Copy link
Copy Markdown
Contributor

Fixes #4248.

Source

  • Parent project (classic dashboard, master of this repo): the topic list's row action "Topic CONFIG" (frontend-new/src/pages/Topic/topic.jsx:498-500) opens TopicModifyDialog in update mode (frontend-new/src/components/topic/TopicModifyDialog.jsx, bIsUpdate) — name and message type are disabled while write/read queue counts and perm stay editable, submitted via createOrUpdateTopic (frontend-new/src/api/remoteApi/remoteApi.js:674). Verified with git show master:....
  • In-repo evidence that this is an omission, not a design decision: POST /api/topics/update is documented in the project's own API reference (docs/api-spec.md §5.4), implemented for all three providers (ApacheInstanceProvider.updateTopic → RocketMQAdminClientImpl.updateTopic, plus AliyunInstanceProvider / TencentInstanceProvider), and the web service wrapper topicService.updateTopic exists with demo-mode support — but git grep updateTopic -- web/src shows no page ever calls it. RocketMQAdminClientImpl.updateTopic even comments on preserving values "on partial updates (e.g. perm or remark only)", written for update callers that never arrived in the UI.

Current gap

Studio's topic page row actions are detail / send / delete only. Resizing queues, tightening permission (RW → RO/WO) or fixing a remark requires CLI access, while the whole backend path for it already exists.

Project fit

  • Zero new server code: this wires the UI to an endpoint the project already ships and documents.
  • Follows the established Studio pattern of reusing the create dialog for resource management (vendor gating, in-flight guard, server-page reload) rather than porting the classic per-broker dialog wholesale.
  • Cloud instances are covered honestly: the Aliyun/Tencent providers accept remark(-only) updates, so the edit dialog keeps the create dialog's vendor gating (no queue/perm fields for cloud), exactly matching what those APIs accept.

Scope

Included: a 配置 row action opening the create dialog in edit mode (prefilled, name/type disabled per classic semantics), submit through updateTopic with the selected instance id, server-page reload, success/error feedback, and a state reset that keeps the create flow independent.

Not included: per-broker queue editing (Studio updates the topic through the provider API, not per broker), message-type changes (classic also disables them on update), AI tool surface changes, new server endpoints.

Implementation

  • web/src/pages/instance/topic.tsx: editingTopic state; openEditConfig prefills the form and opens the shared dialog; handleCreate branches to topicService.updateTopic when editing; modal title/okText switch (编辑 Topic / 保存); name input and type Segmented disabled in edit mode; the toolbar create button and dialog cancel clear editingTopic so the create flow can never submit an update; 配置 row button (all vendors, mirroring the server-side provider support).
  • Tests in web/src/pages/instance/__tests__/TopicPage.test.tsx (3 new cases).

Tests

Red first (feature absent on baseline 6c24d2ed):

  • npx vitest run src/pages/instance/__tests__/TopicPage.test.tsx -t "topic" → Tests 2 failed | 13 passed | 11 skipped (26): both new edit cases failed at getByRole('button', { name: /配\s*置/ }) (no such row button on baseline).
  • -t "clean create dialog" → Tests 1 failed | 25 skipped (26) (same missing action).

Green after the change:

  • npx vitest run src/pages/instance/__tests__/TopicPage.test.tsx → Test Files 1 passed (1), Tests 26 passed (26) (23 pre-existing + 3 new: edit submit reloads the server page with updateTopic called with the changed queues/perm; cloud edit hides broker-only fields and submits remark-only; a cancelled edit leaves a clean create dialog — updateTopic not called).
  • Full web npx vitest run: 984 tests, 8 failures / 7 files — 6 failures in files untouched by this change (MetricsExplorer, ClientsPage, ClusterPage, MessagePage, AuditPage, NotificationDeliveriesPage — the documented load-flaky family) and 2 in TopicPage; TopicPage re-run in isolation right after: Tests 26 passed (26) (the full run executed concurrently with npm run build, the same overload pattern recorded in previous rounds).
  • npx tsc --noEmit clean; eslint clean on both touched files; npm run build ✓ (built in 1m 21s). No backend changes — the update endpoint was already tested server-side.

Compatibility & Risk

  • Additive UI only; no API or data-model changes. Users of the existing create dialog see identical behavior (title, OK label and validation unchanged in create mode).
  • The update call relies on the existing partial-update semantics of UpdateTopicDTO (cloud payloads omit queue/perm fields; the Apache provider preserves unset values) — the exact path its own comments were written for.
  • Head: 3696930 (single commit, branch feat/topic-config-edit off rocketmq-studio @ 6c24d2e).

The classic dashboard exposes a per-row CONFIG action that reopens the
topic dialog in update mode (name and type fixed, queue counts, perm and
remark editable). Studio's server side already implements the update API
for Apache, Aliyun and Tencent providers and its own api-spec documents
POST /api/topics/update, but the service wrapper has no caller — the
topic page only offers detail, send and delete.

Reuse the create dialog in edit mode: a 配置 row action prefills the
saved values, disables name and type like the classic dialog, submits
through topicService.updateTopic with the selected instance, and reloads
the server-paged list. Cloud instances keep the create dialog's vendor
gating, so their edit is remark-only, matching what the Aliyun/Tencent
providers accept. Fixes apache#4248.
@unbridled-41

unbridled-41 commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Verification evidence

CI: head 3696930d3b8419ab67043e8f9cfebac2256785be has exactly one workflow run — "CI" (pull_request), id 34692651778, conclusion startup_failure; check-runs not resolvable for the fork commit pre-PR and 0 on the upstream ref. The upstream workflow fails at startup on every branch (including recent merges to rocketmq-studio), so no CI signal exists for any PR; local verification below covers web vitest, tsc, eslint and build — this diff touches only 2 web files, no backend code. For backend health on the shared base: a full backend mvn -o test on the sibling branch feat/consumer-group-consume-tps (same base 6c24d2ed plus small additive backend changes) ended with only the baseline failures (2153 tests, 3 failures), and the untouched update endpoint is covered server-side in the base itself (updateTopic cases in MetadataServiceTest, TopicControllerTest.updateTopicShouldRejectBlankName, and RocketMQAdminClientImplTest.updateTopic*, verified during audit).

Red (baseline 6c24d2ed, new tests only):

  • npx vitest run src/pages/instance/__tests__/TopicPage.test.tsx -t "topic" → Tests 2 failed | 13 passed | 11 skipped (26): both new edit cases failed at getByRole('button', { name: /配\s*置/ }) — the row action does not exist on baseline (error dump lists only 详情/发送/删除 buttons in the row).
  • npx vitest run src/pages/instance/__tests__/TopicPage.test.tsx -t "clean create dialog" → Tests 1 failed | 25 skipped (26) (same missing action).

Green (module run):

  • npx vitest run src/pages/instance/__tests__/TopicPage.test.tsx → Test Files 1 passed (1), Tests 26 passed (26) (23 pre-existing + 3 new). First run caught one test bug (typed into the prefilled remark instead of replacing it → assertion updated to clear-then-type; no product code change).

Full suite + baseline comparison:

  • Full web npx vitest run: 984 tests, 8 failures / 7 files (981 baseline + 3 new = 984). Failures: MetricsExplorer, ClientsPage, ClusterPage, MessagePage, AuditPage, NotificationDeliveriesPage (files untouched by this change — the documented load-flaky family) + 2 TopicPage cases. TopicPage re-run in isolation immediately after: Test Files 1 passed (1), Tests 26 passed (26) — the full run executed concurrently with npm run build, matching the overload pattern recorded in previous rounds' baselines. Zero deterministic new failures.

Build: npx tsc --noEmit clean; eslint clean on both touched files; npm run build ✓ (built in 1m 21s).

Diff self-check (git show 3696930d --numstat): 2 files, +150/−13 — web/src/pages/instance/topic.tsx +57/−13 (edit state/action/dialog-mode wiring; the −13 are the create handler, modal header and row-action block restructured to branch on edit mode) and web/src/pages/instance/__tests__/TopicPage.test.tsx +93/−0 (mock key updateTopic + 3 new cases). No unrelated changes, no backend files touched.

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Wires the existing updateTopic backend endpoint to a new "配置" row action on the topic page, reusing the create dialog in edit mode with name/type disabled — matching classic dashboard semantics.

The implementation is clean and well-tested:

  • Proper state management with editingTopic to distinguish create vs edit
  • Form fields correctly disabled based on mode
  • State reset on cancel/switch prevents stale data
  • Three test cases covering update flow, cloud vendor gating, and state isolation

LGTM.


Automated review by github-manager-bot

lizhimins pushed a commit that referenced this pull request Sep 16, 2026
#4331)

Incorporates ten related front-end fixes from the same author:

- #4175 render the rule last-triggered time as UTC
- #4189 keep the selected range when the metrics instance changes
- #4245 reload the paginated group list after creating groups
- #4249 edit topic configuration from the topic page
- #4254 reset the silence form when the maintenance dialog is dismissed
- #4263 export users against the committed search term
- #4265 re-run the custom query when the dashboard instance changes
- #4283 reset the queue browser pull indicators when the queue list reloads
- #4285 surface the validation reason when a silence cannot be built
- #4322 invalidate the in-flight connection query when the topic changes
@lizhimins

Copy link
Copy Markdown
Member

Merged as part of #4331 — squashed into rocketmq-studio as 6334f9238.

Your change here (editing topic configuration from the topic page) is included. One adjustment was needed on top of your patch: the action column now renders four buttons but still declared width: 200, so tableScrollX under-counted and the table overflowed its container — we widened it to 280.

We grouped 11 of your related front-end fixes into a single commit so the history stays reviewable; the other PRs in the group are closed with the same note. Everything was cherry-picked onto the current baseline with you kept as the author, and your tests came along with the change.

Thanks for the consistently well-tested patches.

@lizhimins lizhimins closed this Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants