Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ describe('IndexesToolbar Component', function () {
onCreateSearchIndexClick={() => {}}
namespace=""
showAtlasSearchLink={false}
serverVersion={'8.0.11'}
{...props}
/>
</PreferencesProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we might want this to be false if we couldn't parse the version (usually when we encounter this people are running some unexpected server builds / versions), but I trust you know better. It's also a rare case, so maybe not worth overthinking too much

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah that makes sense, fixed it

}
};

type IndexesToolbarProps = {
namespace: string;
indexView: IndexView;
Expand All @@ -62,6 +76,7 @@ type IndexesToolbarProps = {
isRefreshing: boolean;
onRefreshIndexes: () => void;
onIndexViewChanged: (newView: IndexView) => void;
serverVersion: string;
// connected:
isReadonlyView: boolean;
isWritable: boolean;
Expand All @@ -88,6 +103,7 @@ export const IndexesToolbar: React.FunctionComponent<IndexesToolbarProps> = ({
isSearchIndexesSupported,
onRefreshIndexes,
onIndexViewChanged,
serverVersion,
readOnly, // preferences readOnly.
}) => {
const isSearchManagementActive = usePreference('enableAtlasSearchIndexes');
Expand Down Expand Up @@ -188,16 +204,27 @@ export const IndexesToolbar: React.FunctionComponent<IndexesToolbarProps> = ({
</SegmentedControlOption>
}
>
<p>
Atlas Search index management in Compass is only available
for Atlas local deployments and clusters running MongoDB
6.0.7 or newer.
</p>
<p>
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.
</p>
{serverSupportsSearchIndexManagement(serverVersion) ? (
<p>
Unable to fetch search indexes. This can occur when your
cluster does not support search indexes or the listing
search indexes request failed.
</p>
) : (
<>
<p>
Atlas Search index management in Compass is only
available for Atlas local deployments and clusters
running MongoDB 6.0.7 or newer.
</p>
<p>
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.
</p>
</>
)}
</Tooltip>
)}
{isSearchIndexesSupported && (
Expand Down
Loading