Skip to content

Feat/mongo index edit - #6159

Open
a2468947480 wants to merge 3 commits into
t8y2:mainfrom
a2468947480:feat/mongo-index-edit
Open

Feat/mongo index edit#6159
a2468947480 wants to merge 3 commits into
t8y2:mainfrom
a2468947480:feat/mongo-index-edit

Conversation

@a2468947480

Copy link
Copy Markdown

变更说明 / Summary

  • 在 MongoDB 索引管理面板新增「编辑索引」功能,仿 Navicat 的工作流
  • 选中已有索引后点击 Edit Index,表单自动预填索引键和选项(唯一/稀疏/TTL/部分过滤器/background/bucketSize)
  • 保存时弹出二次确认窗口,预览 dropIndex + createIndex 两条命令,确认后依次执行
  • _id_ 默认索引不可编辑(与不可删除一致)
  • 编辑模式复用现有创建表单,零后端改动(drop + create 复用现有 API)

Add an "Edit Index" action to the MongoDB index manager panel, mirroring the Navicat workflow. Selecting an existing index and clicking Edit Index prefills the create form with its keys and options (unique/sparse/TTL/partial filter/background/bucketSize). Saving shows a confirmation previewing the dropIndex + createIndex commands, then runs them in sequence. The protected _id_ index stays read-only. The edit mode reuses the existing create form with no backend changes (drop + create reuse existing APIs).

变更类型 / Type of Change

  • 新功能 / New feature
  • Bug 修复 / Bug fix
  • 性能优化 / Performance improvement
  • 代码重构 / Refactor
  • 文档更新 / Documentation
  • CI / 构建 / CI / Build

涉及前端 / Frontend Changes

  • 本 PR 涉及前端改动,已附截图/录屏(见下方)

  • This PR includes frontend changes

  • 索引管理面板工具栏新增 Edit Index 按钮(铅笔图标)

  • 选中已有索引后点击 Edit 进入编辑模式,表单预填,保存按钮触发 drop+create 确认

  • 新增 i18n 文案已同步适配 en / zh-CN / zh-TW 三语言

Added an Edit Index button (pencil icon) to the index manager toolbar. Selecting an index and clicking Edit enters edit mode with the form prefilled; the Save button triggers a drop+create confirmation. All new i18n strings are provided in en / zh-CN / zh-TW.

验证 / Verification

  • pnpm vitest run apps/desktop/src/lib/sidebar/__tests__/mongoCollectionMutation.spec.ts apps/desktop/src/composables/__tests__/useSidebarDatabaseSpecificMutationRuntime.mongo.spec.ts(57 项通过 / 57 tests passed)
  • pnpm vitest run apps/desktop/src/components/sidebar/__tests__/SidebarTreeItemDialogs.mongoIndex.spec.ts packages/app-tests/productionGuardEntrypoints.test.ts(5 项通过 / 5 tests passed)
  • pnpm typecheck(vue-tsc --noEmit 无错误 / no errors)
  • pnpm dev:tauri 桌面窗口手动验证:编辑索引 → drop + create → 列表刷新 → 新索引选中 / Manual verification in desktop dev window: edit index → drop + create → list refresh → new index selected

关联 Issue / Related Issue

无关联 Issue,为索引管理面板的功能增强。
No related issue; this is a feature enhancement for the index manager panel.
bb26ef7d0f774685855843d0def05902
2912e7b9e7f54ac7bb9f8d7fa640115c
c222022e322e4abd9ab8100ea8e2f5e1

Add a Navicat-style index manager panel for MongoDB collections:
list, create and drop indexes. Native driver reads the full option set
(sparse/TTL/partial filter/background/bucketSize/hidden) via raw
listIndexes; Legacy Agent connections degrade with
properties_complete=false rather than presenting defaults as truth.
# Conflicts:
#	apps/desktop/src/composables/__tests__/useSidebarDatabaseSpecificMutationRuntime.mongo.spec.ts
#	apps/desktop/src/lib/backend/tauri.ts
Reuse the create-index form in a new 'edit' mode: selecting an index
and clicking Edit prefills the form with its keys and options. Saving
shows a confirmation previewing the dropIndex + createIndex commands,
then runs them in sequence. Protected _id indexes stay read-only.
@github-actions github-actions Bot added area/multiple Touches more than three repository areas db/mongodb Database: MongoDB (Legacy) ui-change Changes user-visible interface, text, or visual assets labels Aug 13, 2026

@t8y2 t8y2 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This edit path can currently lose or replace indexes without preserving their server-side semantics, so it is not safe to merge yet.

  1. The edit form does not round-trip all options returned by the server. hidden, collation, text weights/default language, geo options, wildcardProjection, and other extraOptions can be silently dropped when the old index is deleted and recreated.
  2. The update is a non-atomic drop followed by create with no recovery. A name conflict, duplicate data for a unique index, permission/version error, or network failure after the drop permanently leaves the collection without the original index.
  3. The cached index specification is not re-read immediately before deletion. If another client recreates the same index while the dialog is open, this operation can delete the newer index.

Please preserve the complete index specification, preflight the replacement, add a safe failure/restore strategy, and re-read/compare the current server spec before destructive execution. Add regression coverage for unsupported options, create failure after drop, and concurrent replacement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/multiple Touches more than three repository areas db/mongodb Database: MongoDB (Legacy) ui-change Changes user-visible interface, text, or visual assets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants