diff --git a/packages/compass-indexes/src/components/indexes-toolbar/indexes-toolbar.spec.tsx b/packages/compass-indexes/src/components/indexes-toolbar/indexes-toolbar.spec.tsx index cf28af29f70..9bac366ab8e 100644 --- a/packages/compass-indexes/src/components/indexes-toolbar/indexes-toolbar.spec.tsx +++ b/packages/compass-indexes/src/components/indexes-toolbar/indexes-toolbar.spec.tsx @@ -44,6 +44,7 @@ describe('IndexesToolbar Component', function () { onCreateSearchIndexClick={() => {}} namespace="" showAtlasSearchLink={false} + serverVersion={'8.0.11'} {...props} /> diff --git a/packages/compass-indexes/src/components/indexes-toolbar/indexes-toolbar.tsx b/packages/compass-indexes/src/components/indexes-toolbar/indexes-toolbar.tsx index 9399bdac717..0989e4edee1 100644 --- a/packages/compass-indexes/src/components/indexes-toolbar/indexes-toolbar.tsx +++ b/packages/compass-indexes/src/components/indexes-toolbar/indexes-toolbar.tsx @@ -21,6 +21,7 @@ import { SegmentedControlOption, } from '@mongodb-js/compass-components'; import { useConnectionInfo } from '@mongodb-js/compass-connections/provider'; +import semver from 'semver'; import type { RootState } from '../../modules'; import { createSearchIndexOpened } from '../../modules/search-indexes'; @@ -53,6 +54,19 @@ const createIndexButtonContainerStyles = css({ width: 'fit-content', }); +const MIN_SEARCH_INDEX_MANAGEMENT_SERVER_VERSION = '6.0.7'; + +const serverSupportsSearchIndexManagement = (serverVersion: string) => { + try { + return semver.gte( + serverVersion, + MIN_SEARCH_INDEX_MANAGEMENT_SERVER_VERSION + ); + } catch { + return false; + } +}; + type IndexesToolbarProps = { namespace: string; indexView: IndexView; @@ -62,6 +76,7 @@ type IndexesToolbarProps = { isRefreshing: boolean; onRefreshIndexes: () => void; onIndexViewChanged: (newView: IndexView) => void; + serverVersion: string; // connected: isReadonlyView: boolean; isWritable: boolean; @@ -88,6 +103,7 @@ export const IndexesToolbar: React.FunctionComponent = ({ isSearchIndexesSupported, onRefreshIndexes, onIndexViewChanged, + serverVersion, readOnly, // preferences readOnly. }) => { const isSearchManagementActive = usePreference('enableAtlasSearchIndexes'); @@ -188,16 +204,27 @@ export const IndexesToolbar: React.FunctionComponent = ({ } > -

- Atlas Search index management in Compass is only available - for Atlas local deployments and clusters running MongoDB - 6.0.7 or newer. -

-

- For clusters running an earlier version of MongoDB, you - can manage your Atlas Search indexes from the Atlas web - Ul, with the CLI, or with the Administration API. -

+ {serverSupportsSearchIndexManagement(serverVersion) ? ( +

+ Unable to fetch search indexes. This can occur when your + cluster does not support search indexes or the request + to list search indexes failed. +

+ ) : ( + <> +

+ Atlas Search index management in Compass is only + available for Atlas local deployments and clusters + running MongoDB 6.0.7 or newer. +

+

+ For clusters running an earlier version of MongoDB, + you can manage your Atlas Search indexes from the + Atlas web Ul, with the CLI, or with the Administration + API. +

+ + )} )} {isSearchIndexesSupported && (