Skip to content

Commit 5a430a8

Browse files
committed
Update banner
1 parent 024f26a commit 5a430a8

File tree

2 files changed

+41
-30
lines changed

2 files changed

+41
-30
lines changed

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

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
DropdownMenuButton,
2020
SegmentedControl,
2121
SegmentedControlOption,
22-
usePersistedState,
2322
} from '@mongodb-js/compass-components';
2423
import { useConnectionInfo } from '@mongodb-js/compass-connections/provider';
2524

@@ -54,6 +53,7 @@ type IndexesToolbarProps = {
5453
indexView: IndexView;
5554
errorMessage: string | null;
5655
hasTooManyIndexes: boolean;
56+
showAtlasSearchLink: boolean;
5757
isRefreshing: boolean;
5858
onRefreshIndexes: () => void;
5959
onIndexViewChanged: (newView: IndexView) => void;
@@ -68,9 +68,6 @@ type IndexesToolbarProps = {
6868
readOnly?: boolean;
6969
};
7070

71-
const DISMISSED_SEARCH_INDEXES_BANNER_LOCAL_STORAGE_KEY =
72-
'mongodb_compass_dismissedSearchIndexesBanner' as const;
73-
7471
export const IndexesToolbar: React.FunctionComponent<IndexesToolbarProps> = ({
7572
namespace,
7673
indexView,
@@ -82,16 +79,13 @@ export const IndexesToolbar: React.FunctionComponent<IndexesToolbarProps> = ({
8279
isRefreshing,
8380
writeStateDescription,
8481
hasTooManyIndexes,
82+
showAtlasSearchLink,
8583
isSearchIndexesSupported,
8684
onRefreshIndexes,
8785
onIndexViewChanged,
8886
readOnly, // preferences readOnly.
8987
}) => {
9088
const isSearchManagementActive = usePreference('enableAtlasSearchIndexes');
91-
const [dismissed, setDismissed] = usePersistedState(
92-
DISMISSED_SEARCH_INDEXES_BANNER_LOCAL_STORAGE_KEY,
93-
false
94-
);
9589
const { atlasMetadata } = useConnectionInfo();
9690
const showInsights = usePreference('showInsights') && !errorMessage;
9791
const showCreateIndexButton = !isReadonlyView && !readOnly && !errorMessage;
@@ -138,21 +132,18 @@ export const IndexesToolbar: React.FunctionComponent<IndexesToolbarProps> = ({
138132
>
139133
Refresh
140134
</Button>
141-
{!isReadonlyView &&
142-
!isSearchManagementActive &&
143-
dismissed &&
144-
atlasMetadata && (
145-
<Link
146-
href={getAtlasSearchIndexesLink({
147-
clusterName: atlasMetadata.clusterName,
148-
namespace,
149-
})}
150-
hideExternalIcon
151-
arrowAppearance="persist"
152-
>
153-
Manage your search indexes
154-
</Link>
155-
)}
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+
)}
156147
{showInsights && hasTooManyIndexes && (
157148
<SignalPopover
158149
signals={PerformanceSignals.get('too-many-indexes')}

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

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,23 @@ const linkTitle = 'Search and Vector Search.';
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)