Skip to content

Conversation

@JimmyChoiMDB
Copy link
Collaborator

@JimmyChoiMDB JimmyChoiMDB commented Feb 9, 2026

Description

  • Add indexes-read-write-access.ts file in utils directory that exposes helper functions and hooks to determine whether the user can read or write search or regular indexes
  • Add is-view-search-compatible.ts file that exposes helper functions and hooks to determine whether view version is search compatible and view pipeline is search queryable
  • Moved banner and empty state components to separate files for easy reuse
  • No functional changes

Checklist

  • New tests and/or benchmarks are included
  • Documentation is changed or added
  • If this change updates the UI, screenshots/videos are added and a design review is requested
  • If this change could impact the load on the MongoDB cluster, please describe the expected and worst case impact
  • I have signed the MongoDB Contributor License Agreement (https://www.mongodb.com/legal/contributor-agreement)

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

@github-actions github-actions bot added the feat label Feb 9, 2026
@JimmyChoiMDB JimmyChoiMDB added feature flagged PRs labeled with this label will not be included in the release notes of the next release and removed feat labels Feb 9, 2026
@github-actions github-actions bot added the feat label Feb 9, 2026
@JimmyChoiMDB JimmyChoiMDB marked this pull request as ready for review February 10, 2026 00:49
@JimmyChoiMDB JimmyChoiMDB requested a review from a team as a code owner February 10, 2026 00:49
Copilot AI review requested due to automatic review settings February 10, 2026 00:49
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

Refactors how Compass Indexes determines read/write access and view compatibility for regular vs search indexes, and extracts reusable UI pieces for view-incompatible states.

Changes:

  • Added shared utilities/hooks for index read/write access and view search compatibility.
  • Updated regular/search index fetching + UI rendering to use the new access/compat logic.
  • Extracted view-incompatibility banners/empty states into reusable components and updated tests accordingly.

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
packages/compass-indexes/test/setup-store.ts Updates test preference defaults to include Atlas Search indexes enabled.
packages/compass-indexes/src/utils/is-view-search-compatible.ts Adds hook + helpers for view version/pipeline search compatibility.
packages/compass-indexes/src/utils/indexes-read-write-access.ts Adds hook + helpers for regular/search index read/write gating.
packages/compass-indexes/src/modules/search-indexes.ts Refactors fetch gating for search indexes using new helpers + injected services.
packages/compass-indexes/src/modules/regular-indexes.ts Refactors fetch gating for regular indexes using new helpers.
packages/compass-indexes/src/components/view-version-incompatible-banners/view-version-incompatible-banners.tsx Removes inlined banner component (moved elsewhere).
packages/compass-indexes/src/components/view-incompatible-components/view-version-incompatible-banner.tsx Adds extracted banner component for view version incompatibility.
packages/compass-indexes/src/components/view-incompatible-components/view-standard-indexes-incompatible-empty-state.tsx Adds extracted empty state for standard views/regular index incompatibility messaging.
packages/compass-indexes/src/components/view-incompatible-components/view-pipeline-incompatible-banner.tsx Adds extracted banner for view pipeline incompatibility.
packages/compass-indexes/src/components/search-indexes-table/search-indexes-table.tsx Switches to new access/compat hooks; updates zero state + action gating.
packages/compass-indexes/src/components/search-indexes-table/search-indexes-table.spec.tsx Updates tests to render with Redux Provider + store setup.
packages/compass-indexes/src/components/indexes/indexes.tsx Replaces inline view-incompat components with extracted versions and new hooks.
packages/compass-indexes/src/components/indexes/indexes.spec.tsx Updates a test description/expectation for new messaging behavior.
packages/compass-indexes/package.json Removes @mongodb-js/connection-info dependency.

Comment on lines +35 to +46
export function getIsViewVersionSearchCompatible(
serverVersion: string,
isAtlas: boolean
): boolean {
return isAtlas
? VIEW_PIPELINE_UTILS.isVersionSearchCompatibleForViewsDataExplorer(
serverVersion
)
: VIEW_PIPELINE_UTILS.isVersionSearchCompatibleForViewsCompass(
serverVersion
);
}
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

getIsViewVersionSearchCompatible only keys off isAtlas, but prior behavior distinguished between managing search indexes in Compass (8.1+) vs deferring to Atlas UI/Data Explorer (8.0+). As written, Atlas connections will treat 8.0 as compatible even when Atlas Search indexes are enabled in Compass, which can incorrectly allow UI/actions/fetching on unsupported versions. Consider including the enableAtlasSearchIndexes (or an explicit 'manageInCompass' flag) in the compatibility calculation and using Compass compatibility when in-Compass management is enabled.

Copilot uses AI. Check for mistakes.
Comment on lines +10 to +11
subTitle="Standard views use the indexes of the underlying collection. As a result, you
cannot create, drop or re-build indexes on a standard view directly, nor get a list of indexes on the view."
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

This JSX prop value appears to be a multi-line string literal wrapped in double quotes; in TS/JS, string literals can't contain raw newlines and this will fail to parse/compile. Use a template literal (backticks), string concatenation, or a single-line string (or JSX text via {...}) to avoid introducing a syntax error.

Suggested change
subTitle="Standard views use the indexes of the underlying collection. As a result, you
cannot create, drop or re-build indexes on a standard view directly, nor get a list of indexes on the view."
subTitle="Standard views use the indexes of the underlying collection. As a result, you cannot create, drop or re-build indexes on a standard view directly, nor get a list of indexes on the view."

Copilot uses AI. Check for mistakes.
Comment on lines +12 to +20
const { isWritable, isReadonlyView, isSearchIndexesSupported } = useSelector(
(state: RootState) => ({
serverVersion: state.serverVersion,
isWritable: state.isWritable,
isReadonlyView: state.isReadonlyView,
isSearchIndexesSupported: state.isSearchIndexesSupported,
collectionStats: state.collectionStats,
})
);
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

This useSelector returns a new object every time the store updates, which will force a rerender even when none of the selected values changed. Prefer selecting fields individually (multiple useSelector calls) or pass shallowEqual as the equality function, and avoid including fields in the selection object that aren't needed for this hook.

Suggested change
const { isWritable, isReadonlyView, isSearchIndexesSupported } = useSelector(
(state: RootState) => ({
serverVersion: state.serverVersion,
isWritable: state.isWritable,
isReadonlyView: state.isReadonlyView,
isSearchIndexesSupported: state.isSearchIndexesSupported,
collectionStats: state.collectionStats,
})
);
const isWritable = useSelector((state: RootState) => state.isWritable);
const isReadonlyView = useSelector(
(state: RootState) => state.isReadonlyView
);
const isSearchIndexesSupported = useSelector(
(state: RootState) => state.isSearchIndexesSupported
);

Copilot uses AI. Check for mistakes.
Comment on lines +11 to +16
const { serverVersion, collectionStats } = useSelector(
(state: RootState) => ({
serverVersion: state.serverVersion,
collectionStats: state.collectionStats,
})
);
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

Same pattern here: selecting into a freshly created object will trigger rerenders on any store update. Consider selecting serverVersion and collectionStats via separate selectors or using shallowEqual to prevent unnecessary rerenders.

Suggested change
const { serverVersion, collectionStats } = useSelector(
(state: RootState) => ({
serverVersion: state.serverVersion,
collectionStats: state.collectionStats,
})
);
const serverVersion = useSelector(
(state: RootState) => state.serverVersion
);
const collectionStats = useSelector(
(state: RootState) => state.collectionStats
);

Copilot uses AI. Check for mistakes.
Comment on lines +31 to +37
});

if (state) {
const newState = { ...store.getState(), ...state };
Object.assign(store.getState(), newState);
}

Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

Mutating the object returned by store.getState() is not reliable in Redux tests (it bypasses reducers and may not notify subscribers). Prefer creating the store with a preloaded state (if supported by setupStore/activateIndexesPlugin), or dispatch actions to reach the desired state shape for the scenario under test.

Suggested change
});
if (state) {
const newState = { ...store.getState(), ...state };
Object.assign(store.getState(), newState);
}
...(state ?? {}),
});

Copilot uses AI. Check for mistakes.
<div className={viewContentStyles}>
<span>
Your MongoDB version is {serverVersion}. Creating and managing search
indexes on views {!isAtlas && 'in Compass'} is supported on MongoDB
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

Grammar: 'indexes ... is supported' should be 'indexes ... are supported' (plural subject).

Suggested change
indexes on views {!isAtlas && 'in Compass'} is supported on MongoDB
indexes on views {!isAtlas && 'in Compass'} are supported on MongoDB

Copilot uses AI. Check for mistakes.
Comment on lines +64 to +74
export function getIsSearchIndexesReadable(
enableAtlasSearchIndexes: boolean,
isReadonlyView: boolean,
isViewVersionSearchCompatible: boolean,
isSearchIndexesSupported: boolean
): boolean {
return (
enableAtlasSearchIndexes &&
(isReadonlyView ? isViewVersionSearchCompatible : isSearchIndexesSupported)
);
}
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

New access/compat logic is central to the refactor and has multiple branching cases (readonly view vs collection, Atlas vs non-Atlas, version compatibility, pipeline queryability, preferences). Please add focused unit tests covering at least: (1) Atlas + enableAtlasSearchIndexes=true + serverVersion 8.0 (should be treated as incompatible for in-Compass management if that’s the intended rule), (2) Atlas + enableAtlasSearchIndexes=false + serverVersion 8.0, and (3) non-Atlas + serverVersion 8.0/8.1 boundaries, so regressions are caught.

Copilot generated this review using guidance from repository custom instructions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat feature flagged PRs labeled with this label will not be included in the release notes of the next release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant