Skip to content

Commit 87a791a

Browse files
authored
feat(compass-web): disable search indexes via preferences COMPASS-7595 (#5533)
* add banner * hardcode link
1 parent 10826aa commit 87a791a

File tree

8 files changed

+43
-41
lines changed

8 files changed

+43
-41
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export const Breadcrumbs = ({
6666
if (isLast) {
6767
return (
6868
<Body
69+
key={item.name}
6970
className={cx(
7071
textStyles,
7172
darkMode ? lastItemStylesDark : lastItemStylesLight

packages/compass-e2e-tests/tests/search-indexes.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,7 @@ describe.skip('Search Indexes', function () {
161161
if (!serverSatisfies('>= 4.1.11')) {
162162
this.skip();
163163
}
164-
compass = await init(this.test?.fullTitle(), {
165-
extraSpawnArgs: ['--enableAtlasSearchIndexManagement'],
166-
});
164+
compass = await init(this.test?.fullTitle());
167165
browser = compass.browser;
168166
});
169167

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ describe('IndexesToolbar Component', function () {
4747
describe('with atlas search index management is disabled', function () {
4848
beforeEach(async function () {
4949
await preferences.savePreferences({
50-
enableAtlasSearchIndexManagement: false,
5150
showInsights: true,
5251
});
5352

@@ -65,7 +64,6 @@ describe('IndexesToolbar Component', function () {
6564
describe('when cluster has Atlas Search available', function () {
6665
beforeEach(async function () {
6766
await preferences.savePreferences({
68-
enableAtlasSearchIndexManagement: true,
6967
showInsights: true,
7068
});
7169

@@ -91,7 +89,6 @@ describe('IndexesToolbar Component', function () {
9189
describe('when cluster does not support Atlas Search', function () {
9290
beforeEach(async function () {
9391
await preferences.savePreferences({
94-
enableAtlasSearchIndexManagement: true,
9592
showInsights: true,
9693
});
9794

@@ -172,12 +169,6 @@ describe('IndexesToolbar Component', function () {
172169
});
173170

174171
describe('allows creating of indexes', function () {
175-
beforeEach(async function () {
176-
await preferences.savePreferences({
177-
enableAtlasSearchIndexManagement: true,
178-
});
179-
});
180-
181172
context('when search indexes is not supported', function () {
182173
it('calls onCreateRegularIndex when index button is clicked', function () {
183174
const onCreateRegularIndexSpy = sinon.spy();
@@ -298,7 +289,6 @@ describe('IndexesToolbar Component', function () {
298289

299290
beforeEach(async function () {
300291
await preferences.savePreferences({
301-
enableAtlasSearchIndexManagement: true,
302292
showInsights: true,
303293
});
304294

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

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ import { showCreateModal as onCreateRegularIndex } from '../../modules/regular-i
3030
import type { IndexView } from '../../modules/index-view';
3131
import { changeIndexView } from '../../modules/index-view';
3232

33-
const containerStyles = css({
34-
margin: `${spacing[3]}px 0`,
35-
});
36-
3733
const toolbarButtonsContainer = css({
3834
display: 'flex',
3935
flexDirection: 'row',
@@ -46,7 +42,6 @@ const alignSelfEndStyles = css({
4642
marginLeft: 'auto',
4743
});
4844

49-
const errorStyles = css({ marginTop: spacing[2] });
5045
const spinnerStyles = css({ marginRight: spacing[2] });
5146

5247
const createIndexButtonContainerStyles = css({
@@ -87,10 +82,7 @@ export const IndexesToolbar: React.FunctionComponent<IndexesToolbarProps> = ({
8782
onChangeIndexView,
8883
readOnly, // preferences readOnly.
8984
}) => {
90-
const isSearchManagementActive = usePreference(
91-
'enableAtlasSearchIndexManagement'
92-
);
93-
85+
const isSearchManagementActive = usePreference('enableAtlasSearchIndexes');
9486
const showInsights = usePreference('showInsights') && !errorMessage;
9587
const showCreateIndexButton = !isReadonlyView && !readOnly && !errorMessage;
9688
const refreshButtonIcon = isRefreshing ? (
@@ -102,7 +94,7 @@ export const IndexesToolbar: React.FunctionComponent<IndexesToolbarProps> = ({
10294
);
10395

10496
return (
105-
<div className={containerStyles} data-testid="indexes-toolbar-container">
97+
<div data-testid="indexes-toolbar-container">
10698
{!isReadonlyView && (
10799
<div data-testid="indexes-toolbar">
108100
<div className={toolbarButtonsContainer}>
@@ -210,13 +202,10 @@ export const IndexesToolbar: React.FunctionComponent<IndexesToolbarProps> = ({
210202
)}
211203
{isReadonlyView ? (
212204
<WarningSummary
213-
className={errorStyles}
214205
warnings={['Readonly views may not contain indexes.']}
215206
/>
216207
) : (
217-
!!errorMessage && (
218-
<ErrorSummary className={errorStyles} errors={[errorMessage]} />
219-
)
208+
!!errorMessage && <ErrorSummary errors={[errorMessage]} />
220209
)}
221210
</div>
222211
);

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

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import React, { useCallback, useEffect } from 'react';
22
import { connect } from 'react-redux';
3-
import { css, spacing } from '@mongodb-js/compass-components';
3+
import {
4+
Banner,
5+
Body,
6+
Link,
7+
css,
8+
spacing,
9+
} from '@mongodb-js/compass-components';
410

511
import IndexesToolbar from '../indexes-toolbar/indexes-toolbar';
612
import RegularIndexesTable from '../regular-indexes-table/regular-indexes-table';
@@ -17,19 +23,33 @@ import {
1723
UpdateSearchIndexModal,
1824
} from '../search-indexes-modals';
1925
import type { IndexView } from '../../modules/index-view';
26+
import { usePreference } from 'compass-preferences-model/provider';
2027

2128
// This constant is used as a trigger to show an insight whenever number of
2229
// indexes in a collection is more than what is specified here.
2330
const IDEAL_NUMBER_OF_MAX_INDEXES = 10;
2431

2532
const containerStyles = css({
2633
margin: spacing[3],
27-
marginTop: 0,
34+
gap: spacing[3],
2835
display: 'flex',
2936
flexDirection: 'column',
3037
width: '100%',
3138
});
3239

40+
const AtlasIndexesBanner = () => {
41+
return (
42+
<Banner variant="info">
43+
<Body weight="medium">Looking for search indexes?</Body>
44+
These indexes can be created and viewed under{' '}
45+
<Link href={'#/clusters/atlasSearch'} target="_blank" hideExternalIcon>
46+
Atlas Search
47+
</Link>
48+
.
49+
</Banner>
50+
);
51+
};
52+
3353
type IndexesProps = {
3454
isReadonlyView?: boolean;
3555
regularIndexes: Pick<
@@ -88,6 +108,8 @@ export function Indexes({
88108
loadIndexes();
89109
}, [loadIndexes]);
90110

111+
const enableAtlasSearchIndexes = usePreference('enableAtlasSearchIndexes');
112+
91113
return (
92114
<div className={containerStyles}>
93115
<IndexesToolbar
@@ -96,6 +118,7 @@ export function Indexes({
96118
isRefreshing={isRefreshing}
97119
onRefreshIndexes={onRefreshIndexes}
98120
/>
121+
{!isReadonlyView && !enableAtlasSearchIndexes && <AtlasIndexesBanner />}
99122
{!isReadonlyView && currentIndexesView === 'regular-indexes' && (
100123
<RegularIndexesTable />
101124
)}

packages/compass-preferences-model/src/feature-flags.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export type FeatureFlags = {
1717
enableOidc: boolean; // Not capitalized "OIDC" for spawn arg casing.
1818
newExplainPlan: boolean;
1919
showInsights: boolean;
20-
enableAtlasSearchIndexManagement: boolean;
2120
enableBulkUpdateOperations: boolean;
2221
enableBulkDeleteOperations: boolean;
2322
enableRenameCollectionModal: boolean;
@@ -54,17 +53,6 @@ export const featureFlags: Required<{
5453
},
5554
},
5655

57-
/**
58-
* Feature flag for Atlas Search Index Management.
59-
* Epic: COMPASS-6599
60-
*/
61-
enableAtlasSearchIndexManagement: {
62-
stage: 'released',
63-
description: {
64-
short: 'Enable Atlas Search Index management.',
65-
long: 'Allows listing, creating, updating and deleting Atlas Search indexes.',
66-
},
67-
},
6856
/**
6957
* Feature flag bulk updates
7058
* Epic: COMPASS-6671

packages/compass-preferences-model/src/preferences-schema.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export type UserConfigurablePreferences = PermanentFeatureFlags &
5050
// Features that are enabled by default in Compass, but are disabled in Data
5151
// Explorer
5252
enableExplainPlan: boolean;
53+
enableAtlasSearchIndexes: boolean;
5354
enableImportExport: boolean;
5455
enableAggregationBuilderRunPipeline: boolean;
5556
enableAggregationBuilderExtraOptions: boolean;
@@ -646,6 +647,17 @@ export const storedUserPreferencesProps: Required<{
646647
type: 'string',
647648
},
648649

650+
enableAtlasSearchIndexes: {
651+
ui: true,
652+
cli: true,
653+
global: true,
654+
description: {
655+
short: 'Enable Atlas Search Indexes',
656+
},
657+
validator: z.boolean().default(true),
658+
type: 'boolean',
659+
},
660+
649661
enableImportExport: {
650662
ui: true,
651663
cli: true,

packages/compass-web/src/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ const CompassWeb = ({
153153
enableExplainPlan: true,
154154
enableAggregationBuilderRunPipeline: true,
155155
enableAggregationBuilderExtraOptions: true,
156+
enableAtlasSearchIndexes: false,
156157
enableImportExport: false,
157158
enableGenAIFeatures: false,
158159
cloudFeatureRolloutAccess: {

0 commit comments

Comments
 (0)