Skip to content

feat: add Copy Reference context menu for databases and collections [reviewed]#587

Merged
tnaum-ms merged 8 commits intonextfrom
reviews/copy-reference
Apr 16, 2026
Merged

feat: add Copy Reference context menu for databases and collections [reviewed]#587
tnaum-ms merged 8 commits intonextfrom
reviews/copy-reference

Conversation

@tnaum-ms
Copy link
Copy Markdown
Collaborator

@tnaum-ms tnaum-ms commented Apr 16, 2026

Reviewing and merging: #545


Summary

Thanks to @bgaeddert for kicking this off and for the inspiration! 🎉

Starting from the original contribution that added "Copy Reference" for databases and collections, we've expanded and refined the feature:

What changed

  • Unified into a single command — One copyReference command handles all node types, detecting the node via instanceof at runtime. No more separate commands per node type.
  • Extended to Index nodes — "Copy Reference…" now appears on database, collection, and index context menus.
  • QuickPick format picker — Instead of copying a single fixed format, the user picks from contextual options:
    • Database: Name, Shell Command (use dbName), Qualified Name (host/dbName)
    • Collection: Name, Namespace (db.coll), Shell Reference (db.coll), Shell Command (db.getCollection("coll"))
    • Index: Name, Key Definition ({ field: 1 }), Shell Command (db.coll.getIndexes().find(...))
  • Smart escaping — Names with special characters (spaces, parens, etc.) automatically use the db.getCollection("...") form. Dot-notation options are hidden when they would produce broken syntax.
  • Consistent menu placement — "Copy Reference…" always appears in its own group just above the Refresh group, across all node types.
  • Uses context.ui.showQuickPick with suppressPersistence: true for stable ordering — follows the same pattern as other wizard-style commands in the codebase.

Feedback requested

@bgaeddert — the main change from your original PR is the addition of a QuickPick step to choose the format. We'd love your feedback on whether that extra step is acceptable to you. If you'd prefer a zero-click experience, we could follow up with a PR that adds a user setting to define a preferred default format — when set, it would copy directly without showing the picker.

bgaeddert and others added 5 commits April 9, 2026 19:31
Adds a "Copy Reference" right-click option to database and collection
nodes in the sidebar. Database copies the db name, collection copies
db.collection dot notation.
…iate titles

Extracts shared logic into copyReferenceInternal helper. Renames command
titles to "Copy Database Reference" and "Copy Collection Reference" to
avoid duplicate labels in VS Code command/keybinding lists.
@tnaum-ms tnaum-ms requested a review from a team as a code owner April 16, 2026 08:32
Copilot AI review requested due to automatic review settings April 16, 2026 08:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds new “Copy Reference” actions to the extension’s tree view so users can quickly copy database/collection references from the sidebar.

Changes:

  • Registered two new commands (copyDatabaseReference, copyCollectionReference) in the extension command wiring.
  • Implemented clipboard-copy behavior for database name and db.collection reference formats.
  • Contributed the commands to VS Code menus (context menu) and added a localized confirmation message.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/documentdb/ClustersExtension.ts Registers the new tree-item commands so they can be invoked from the UI.
src/commands/copyReference/copyReference.ts Implements the clipboard write + user confirmation message for database/collection references.
package.json Declares the new commands and adds context-menu entries for database/collection nodes.
l10n/bundle.l10n.json Adds localization entry for the “copied to clipboard” confirmation message.

Comment thread package.json Outdated
@tnaum-ms
Copy link
Copy Markdown
Collaborator Author

@bgaeddert

first-contribution

@tnaum-ms tnaum-ms merged commit 113ee27 into next Apr 16, 2026
10 of 11 checks passed
@tnaum-ms tnaum-ms deleted the reviews/copy-reference branch April 16, 2026 12:55
@tnaum-ms tnaum-ms mentioned this pull request Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

4 participants