@@ -21,6 +21,7 @@ import {
2121 SegmentedControlOption ,
2222} from '@mongodb-js/compass-components' ;
2323import { useConnectionInfo } from '@mongodb-js/compass-connections/provider' ;
24+ import semver from 'semver' ;
2425
2526import type { RootState } from '../../modules' ;
2627import { createSearchIndexOpened } from '../../modules/search-indexes' ;
@@ -53,6 +54,19 @@ const createIndexButtonContainerStyles = css({
5354 width : 'fit-content' ,
5455} ) ;
5556
57+ const MIN_SEARCH_INDEX_MANAGEMENT_SERVER_VERSION = '6.0.7' ;
58+
59+ const serverSupportsSearchIndexManagement = ( serverVersion : string ) => {
60+ try {
61+ return semver . gte (
62+ serverVersion ,
63+ MIN_SEARCH_INDEX_MANAGEMENT_SERVER_VERSION
64+ ) ;
65+ } catch {
66+ return false ;
67+ }
68+ } ;
69+
5670type IndexesToolbarProps = {
5771 namespace : string ;
5872 indexView : IndexView ;
@@ -62,6 +76,7 @@ type IndexesToolbarProps = {
6276 isRefreshing : boolean ;
6377 onRefreshIndexes : ( ) => void ;
6478 onIndexViewChanged : ( newView : IndexView ) => void ;
79+ serverVersion : string ;
6580 // connected:
6681 isReadonlyView : boolean ;
6782 isWritable : boolean ;
@@ -88,6 +103,7 @@ export const IndexesToolbar: React.FunctionComponent<IndexesToolbarProps> = ({
88103 isSearchIndexesSupported,
89104 onRefreshIndexes,
90105 onIndexViewChanged,
106+ serverVersion,
91107 readOnly, // preferences readOnly.
92108} ) => {
93109 const isSearchManagementActive = usePreference ( 'enableAtlasSearchIndexes' ) ;
@@ -188,16 +204,27 @@ export const IndexesToolbar: React.FunctionComponent<IndexesToolbarProps> = ({
188204 </ SegmentedControlOption >
189205 }
190206 >
191- < p >
192- Atlas Search index management in Compass is only available
193- for Atlas local deployments and clusters running MongoDB
194- 6.0.7 or newer.
195- </ p >
196- < p >
197- For clusters running an earlier version of MongoDB, you
198- can manage your Atlas Search indexes from the Atlas web
199- Ul, with the CLI, or with the Administration API.
200- </ p >
207+ { serverSupportsSearchIndexManagement ( serverVersion ) ? (
208+ < p >
209+ Unable to fetch search indexes. This can occur when your
210+ cluster does not support search indexes or the request
211+ to list search indexes failed.
212+ </ p >
213+ ) : (
214+ < >
215+ < p >
216+ Atlas Search index management in Compass is only
217+ available for Atlas local deployments and clusters
218+ running MongoDB 6.0.7 or newer.
219+ </ p >
220+ < p >
221+ For clusters running an earlier version of MongoDB,
222+ you can manage your Atlas Search indexes from the
223+ Atlas web Ul, with the CLI, or with the Administration
224+ API.
225+ </ p >
226+ </ >
227+ ) }
201228 </ Tooltip >
202229 ) }
203230 { isSearchIndexesSupported && (
0 commit comments