Skip to content

Commit 37259f9

Browse files
committed
Link to vector search docs when editing vector indexes
1 parent ff0d0c9 commit 37259f9

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

packages/compass-indexes/src/components/search-indexes-modals/base-search-index-modal.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,16 @@ export const BaseSearchIndexModal: React.FunctionComponent<
157157
onSubmit,
158158
onClose,
159159
}) => {
160+
const initialSearchIndexType: SearchIndexType =
161+
initialIndexType === 'search' || initialIndexType === 'vectorSearch'
162+
? initialIndexType
163+
: 'search';
160164
const editorRef = useRef<EditorRef>(null);
161165
const connectionInfoRef = useConnectionInfoRef();
162166

163167
const [indexName, setIndexName] = useState(initialIndexName);
164-
const [searchIndexType, setSearchIndexType] = useState<string>(
165-
initialIndexType ?? searchIndexTypes[0].value
168+
const [searchIndexType, setSearchIndexType] = useState<SearchIndexType>(
169+
initialSearchIndexType
166170
);
167171
const [indexDefinition, setIndexDefinition] = useState(
168172
initialIndexDefinition
@@ -211,7 +215,7 @@ export const BaseSearchIndexModal: React.FunctionComponent<
211215

212216
useEffect(() => {
213217
if (isModalOpen) {
214-
setSearchIndexType('search');
218+
setSearchIndexType(initialSearchIndexType);
215219
setIndexName(initialIndexName);
216220
setIndexDefinition(initialIndexDefinition);
217221
setParsingError(undefined);

packages/compass-indexes/src/components/search-indexes-modals/update-search-index-modal.spec.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,36 @@ describe('Base Search Index Modal', function () {
5757
expect(screen.getByRole('option', { name: knnVectorText })).to.be.visible;
5858
});
5959
});
60+
61+
it('renders search index info by default', function () {
62+
renderUpdateSearchIndexModal();
63+
expect(
64+
screen
65+
.getByText('View Atlas Search tutorials')
66+
.closest('a')
67+
?.getAttribute('href')
68+
).to.equal('https://www.mongodb.com/docs/atlas/atlas-search/tutorial/');
69+
});
70+
71+
it('renders search index info for regular search indexes', function () {
72+
renderUpdateSearchIndexModal({ indexType: 'search' });
73+
expect(
74+
screen
75+
.getByText('View Atlas Search tutorials')
76+
.closest('a')
77+
?.getAttribute('href')
78+
).to.equal('https://www.mongodb.com/docs/atlas/atlas-search/tutorial/');
79+
});
80+
81+
it('renders vector search index info for vector search indexes', function () {
82+
renderUpdateSearchIndexModal({ indexType: 'vectorSearch' });
83+
expect(
84+
screen
85+
.getByText('View Atlas Vector Search tutorials')
86+
.closest('a')
87+
?.getAttribute('href')
88+
).to.equal(
89+
'https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-tutorial/'
90+
);
91+
});
6092
});

0 commit comments

Comments
 (0)