Skip to content

Commit e7b7d3e

Browse files
authored
feat(indexes): add Atlas search indexes link when banner dismissed COMPASS-9158 (#6880)
* update banner * add dismissed * Update banner * fix test
1 parent f02c3a4 commit e7b7d3e

File tree

3 files changed

+52
-8
lines changed

3 files changed

+52
-8
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ describe('IndexesToolbar Component', function () {
4242
onIndexViewChanged={() => {}}
4343
onCreateRegularIndexClick={() => {}}
4444
onCreateSearchIndexClick={() => {}}
45+
namespace=""
46+
showAtlasSearchLink={false}
4547
{...props}
4648
/>
4749
</PreferencesProvider>

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

+22
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
ErrorSummary,
1010
Tooltip,
1111
WarningSummary,
12+
Link,
1213
css,
1314
spacing,
1415
Icon,
@@ -19,9 +20,11 @@ import {
1920
SegmentedControl,
2021
SegmentedControlOption,
2122
} from '@mongodb-js/compass-components';
23+
import { useConnectionInfo } from '@mongodb-js/compass-connections/provider';
2224

2325
import type { RootState } from '../../modules';
2426
import { createSearchIndexOpened } from '../../modules/search-indexes';
27+
import { getAtlasSearchIndexesLink } from '../../utils/atlas-search-indexes-link';
2528
import { createIndexOpened } from '../../modules/create-index';
2629
import type { IndexView } from '../../modules/index-view';
2730
import { indexViewChanged } from '../../modules/index-view';
@@ -46,9 +49,11 @@ const createIndexButtonContainerStyles = css({
4649
});
4750

4851
type IndexesToolbarProps = {
52+
namespace: string;
4953
indexView: IndexView;
5054
errorMessage: string | null;
5155
hasTooManyIndexes: boolean;
56+
showAtlasSearchLink: boolean;
5257
isRefreshing: boolean;
5358
onRefreshIndexes: () => void;
5459
onIndexViewChanged: (newView: IndexView) => void;
@@ -64,6 +69,7 @@ type IndexesToolbarProps = {
6469
};
6570

6671
export const IndexesToolbar: React.FunctionComponent<IndexesToolbarProps> = ({
72+
namespace,
6773
indexView,
6874
errorMessage,
6975
isReadonlyView,
@@ -73,12 +79,14 @@ export const IndexesToolbar: React.FunctionComponent<IndexesToolbarProps> = ({
7379
isRefreshing,
7480
writeStateDescription,
7581
hasTooManyIndexes,
82+
showAtlasSearchLink,
7683
isSearchIndexesSupported,
7784
onRefreshIndexes,
7885
onIndexViewChanged,
7986
readOnly, // preferences readOnly.
8087
}) => {
8188
const isSearchManagementActive = usePreference('enableAtlasSearchIndexes');
89+
const { atlasMetadata } = useConnectionInfo();
8290
const showInsights = usePreference('showInsights') && !errorMessage;
8391
const showCreateIndexButton = !isReadonlyView && !readOnly && !errorMessage;
8492
const refreshButtonIcon = isRefreshing ? (
@@ -124,6 +132,18 @@ export const IndexesToolbar: React.FunctionComponent<IndexesToolbarProps> = ({
124132
>
125133
Refresh
126134
</Button>
135+
{showAtlasSearchLink && atlasMetadata && (
136+
<Link
137+
href={getAtlasSearchIndexesLink({
138+
clusterName: atlasMetadata.clusterName,
139+
namespace,
140+
})}
141+
hideExternalIcon
142+
arrowAppearance="persist"
143+
>
144+
Manage your search indexes
145+
</Link>
146+
)}
127147
{showInsights && hasTooManyIndexes && (
128148
<SignalPopover
129149
signals={PerformanceSignals.get('too-many-indexes')}
@@ -263,6 +283,7 @@ export const CreateIndexButton: React.FunctionComponent<
263283
};
264284

265285
const mapState = ({
286+
namespace,
266287
isWritable,
267288
isReadonlyView,
268289
isSearchIndexesSupported,
@@ -271,6 +292,7 @@ const mapState = ({
271292
searchIndexes,
272293
indexView,
273294
}: RootState) => ({
295+
namespace,
274296
isWritable,
275297
isReadonlyView,
276298
isSearchIndexesSupported,

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

+28-8
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,28 @@ const containerStyles = css({
4848
flexGrow: 1,
4949
});
5050

51-
const linkTitle = 'Atlas Search.';
51+
const linkTitle = 'Search and Vector Search.';
5252

5353
const DISMISSED_SEARCH_INDEXES_BANNER_LOCAL_STORAGE_KEY =
5454
'mongodb_compass_dismissedSearchIndexesBanner' as const;
5555

56-
const AtlasIndexesBanner = ({ namespace }: { namespace: string }) => {
56+
const AtlasIndexesBanner = ({
57+
namespace,
58+
dismissed,
59+
onDismissClick,
60+
}: {
61+
namespace: string;
62+
dismissed: boolean;
63+
onDismissClick: () => void;
64+
}) => {
5765
const { atlasMetadata } = useConnectionInfo();
58-
const [dismissed, setDismissed] = usePersistedState(
59-
DISMISSED_SEARCH_INDEXES_BANNER_LOCAL_STORAGE_KEY,
60-
false
61-
);
6266

6367
if (!atlasMetadata || dismissed) {
6468
return null;
6569
}
6670

6771
return (
68-
<Banner variant="info" dismissible onClose={() => setDismissed(true)}>
72+
<Banner variant="info" dismissible onClose={onDismissClick}>
6973
<Body weight="medium">Looking for search indexes?</Body>
7074
These indexes can be created and viewed under{' '}
7175
{atlasMetadata ? (
@@ -117,6 +121,11 @@ export function Indexes({
117121
refreshRegularIndexes,
118122
refreshSearchIndexes,
119123
}: IndexesProps) {
124+
const [atlasBannerDismissed, setDismissed] = usePersistedState(
125+
DISMISSED_SEARCH_INDEXES_BANNER_LOCAL_STORAGE_KEY,
126+
false
127+
);
128+
120129
const errorMessage =
121130
currentIndexesView === 'regular-indexes'
122131
? regularIndexes.error
@@ -147,12 +156,23 @@ export function Indexes({
147156
hasTooManyIndexes={hasTooManyIndexes}
148157
isRefreshing={isRefreshing}
149158
onRefreshIndexes={onRefreshIndexes}
159+
showAtlasSearchLink={
160+
!isReadonlyView &&
161+
!enableAtlasSearchIndexes &&
162+
atlasBannerDismissed
163+
}
150164
/>
151165
}
152166
>
153167
<div className={indexesContainersStyles}>
154168
{!isReadonlyView && !enableAtlasSearchIndexes && (
155-
<AtlasIndexesBanner namespace={namespace} />
169+
<AtlasIndexesBanner
170+
namespace={namespace}
171+
dismissed={atlasBannerDismissed}
172+
onDismissClick={() => {
173+
setDismissed(true);
174+
}}
175+
/>
156176
)}
157177
{!isReadonlyView && currentIndexesView === 'regular-indexes' && (
158178
<RegularIndexesTable />

0 commit comments

Comments
 (0)