Skip to content

Conversation

@Anemy
Copy link
Member

@Anemy Anemy commented Nov 5, 2025

COMPASS-6868

Shows a badge when an index is the collection's shard key.
This adds an extra find which will run every time a new collection tab is opened, as we fetch the indexes then. I started a discussion on if we want to lazy load in slack: https://mongodb.slack.com/archives/G2L10JAV7/p1762310280109129

There are a few drive-by fixes for typecheck issues in the packages that don't have typecheck enabled for the tests.

Previous draft pr #7419. This is also related to @addaleax's visible sharding branch where we add the shard key to the collection model (which we might want to do down the line).

Screenshot
Screenshot 2025-11-05 at 10 33 56

Copilot AI review requested due to automatic review settings November 5, 2025 18:48
@Anemy Anemy requested a review from a team as a code owner November 5, 2025 18:48
@Anemy Anemy requested a review from ivandevp November 5, 2025 18:48
@github-actions github-actions bot added the feat label Nov 5, 2025
Copy link
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

This PR adds functionality to display a "SHARD KEY" badge for indexes that serve as a collection's shard key. The implementation fetches the shard key from config.collections when loading indexes and compares it against each index to identify matches.

Key Changes:

  • Added fetchShardKey method to DataService to query shard key information from config.collections
  • Updated index processing logic to include shard key detection using deep equality comparison
  • Extended index property types and UI to display the shard key badge

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/data-service/src/index-detail-helper.ts Added shard key property type and comparison logic for identifying shard key indexes
packages/data-service/src/index-detail-helper.spec.ts Added test coverage for shard key detection and updated existing tests with the new parameter
packages/data-service/src/data-service.ts Implemented fetchShardKey method and integrated it into the indexes fetching flow
packages/data-service/src/data-service.spec.ts Added comprehensive tests for shard key fetching in both regular and sharded cluster contexts
packages/compass-indexes/src/utils/index-link-helper.ts Added documentation link for shard key property
packages/compass-indexes/src/components/regular-indexes-table/property-field.tsx Added display logic to show "SHARD KEY" text for shard key indexes
packages/compass-crud/src/utils/data-service.ts Updated DataService interface requirements to include fetchShardKey
packages/compass-crud/src/utils/cancellable-queries.ts Refactored to use the new fetchShardKey method instead of direct find query
packages/compass-crud/src/utils/cancellable-queries.spec.ts Fixed type annotations and updated test data

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@ivandevp ivandevp left a comment

Choose a reason for hiding this comment

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

Code changes LGTM

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants