Skip to content

Commit af80a53

Browse files
make isSearchPipelineQueryable true for not read only views
1 parent d245b89 commit af80a53

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

packages/compass-indexes/src/components/indexes-toolbar/indexes-toolbar.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import type { IndexView } from '../../modules/index-view';
3333
import { indexViewChanged } from '../../modules/index-view';
3434
import type { CollectionStats } from '../../modules/collection-stats';
3535
import { isPipelineSearchQueryable } from '@mongodb-js/compass-utils';
36+
import type { Document } from 'mongodb';
3637

3738
const toolbarButtonsContainer = css({
3839
display: 'flex',
@@ -127,10 +128,9 @@ export const IndexesToolbar: React.FunctionComponent<IndexesToolbarProps> = ({
127128
<Icon glyph="Refresh" title="Refresh Indexes" />
128129
);
129130
const isViewPipelineSearchQueryable =
130-
(isReadonlyView &&
131-
collectionStats?.pipeline &&
132-
isPipelineSearchQueryable(collectionStats.pipeline as Document[])) ??
133-
true;
131+
isReadonlyView && collectionStats?.pipeline
132+
? isPipelineSearchQueryable(collectionStats.pipeline as Document[])
133+
: true;
134134
const pipelineNotSearchQueryableDescription =
135135
'Search indexes can only be created on views containing $addFields, $set or $match stages with the $expr operator.';
136136
return (

packages/compass-indexes/src/components/indexes/indexes.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import semver from 'semver';
3939
import type { SearchIndex } from 'mongodb-data-service';
4040
import type { CollectionStats } from '../../modules/collection-stats';
4141
import { isPipelineSearchQueryable } from '@mongodb-js/compass-utils';
42+
import type { Document } from 'mongodb';
4243

4344
// This constant is used as a trigger to show an insight whenever number of
4445
// indexes in a collection is more than what is specified here.
@@ -232,10 +233,9 @@ export function Indexes({
232233
const enableAtlasSearchIndexes = usePreference('enableAtlasSearchIndexes');
233234
const { atlasMetadata } = useConnectionInfo();
234235
const isViewPipelineSearchQueryable =
235-
(isReadonlyView &&
236-
collectionStats?.pipeline &&
237-
isPipelineSearchQueryable(collectionStats.pipeline as Document[])) ??
238-
true;
236+
isReadonlyView && collectionStats?.pipeline
237+
? isPipelineSearchQueryable(collectionStats.pipeline as Document[])
238+
: true;
239239

240240
const getBanner = () => {
241241
if (isReadonlyView) {

packages/compass-indexes/src/components/search-indexes-table/search-indexes-table.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,10 @@ export const SearchIndexesTable: React.FunctionComponent<
322322
};
323323
}, [tabId, onSearchIndexesOpened, onSearchIndexesClosed]);
324324
const isViewPipelineSearchQueryable =
325-
(isReadonlyView &&
326-
collectionStats?.pipeline &&
327-
isPipelineSearchQueryable(
328-
collectionStats.pipeline as Array<Record<string, any>>
329-
)) ??
330-
true;
325+
isReadonlyView && collectionStats?.pipeline
326+
? isPipelineSearchQueryable(collectionStats.pipeline as Document[])
327+
: true;
328+
331329
const data = useMemo<LGTableDataType<SearchIndexInfo>[]>(
332330
() =>
333331
indexes.map((index) => {

0 commit comments

Comments
 (0)