@@ -21,6 +21,7 @@ import {
21
21
SegmentedControlOption ,
22
22
} from '@mongodb-js/compass-components' ;
23
23
import { useConnectionInfo } from '@mongodb-js/compass-connections/provider' ;
24
+ import semver from 'semver' ;
24
25
25
26
import type { RootState } from '../../modules' ;
26
27
import { createSearchIndexOpened } from '../../modules/search-indexes' ;
@@ -53,6 +54,19 @@ const createIndexButtonContainerStyles = css({
53
54
width : 'fit-content' ,
54
55
} ) ;
55
56
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
+
56
70
type IndexesToolbarProps = {
57
71
namespace : string ;
58
72
indexView : IndexView ;
@@ -62,6 +76,7 @@ type IndexesToolbarProps = {
62
76
isRefreshing : boolean ;
63
77
onRefreshIndexes : ( ) => void ;
64
78
onIndexViewChanged : ( newView : IndexView ) => void ;
79
+ serverVersion : string ;
65
80
// connected:
66
81
isReadonlyView : boolean ;
67
82
isWritable : boolean ;
@@ -88,6 +103,7 @@ export const IndexesToolbar: React.FunctionComponent<IndexesToolbarProps> = ({
88
103
isSearchIndexesSupported,
89
104
onRefreshIndexes,
90
105
onIndexViewChanged,
106
+ serverVersion,
91
107
readOnly, // preferences readOnly.
92
108
} ) => {
93
109
const isSearchManagementActive = usePreference ( 'enableAtlasSearchIndexes' ) ;
@@ -188,16 +204,27 @@ export const IndexesToolbar: React.FunctionComponent<IndexesToolbarProps> = ({
188
204
</ SegmentedControlOption >
189
205
}
190
206
>
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
+ ) }
201
228
</ Tooltip >
202
229
) }
203
230
{ isSearchIndexesSupported && (
0 commit comments