Skip to content

Commit 83ce1b5

Browse files
fix(compass-web): make banners dismissible COMPASS-8976 (#6764)
* two dismissible banners * changes * use persisted storage * fix * return <></> * Update packages/compass-indexes/src/components/indexes/indexes.tsx Co-authored-by: Sergey Petushkov <[email protected]> * empty * prettier --------- Co-authored-by: Sergey Petushkov <[email protected]>
1 parent e0ecbd0 commit 83ce1b5

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
WorkspaceContainer,
88
css,
99
spacing,
10+
usePersistedState,
1011
} from '@mongodb-js/compass-components';
1112

1213
import IndexesToolbar from '../indexes-toolbar/indexes-toolbar';
@@ -49,13 +50,22 @@ const containerStyles = css({
4950

5051
const linkTitle = 'Atlas Search.';
5152

53+
const DISMISSED_SEARCH_INDEXES_BANNER_LOCAL_STORAGE_KEY =
54+
'mongodb_compass_dismissedSearchIndexesBanner' as const;
55+
5256
const AtlasIndexesBanner = ({ namespace }: { namespace: string }) => {
5357
const { atlasMetadata } = useConnectionInfo();
54-
if (!atlasMetadata) {
58+
const [dismissed, setDismissed] = usePersistedState(
59+
DISMISSED_SEARCH_INDEXES_BANNER_LOCAL_STORAGE_KEY,
60+
false
61+
);
62+
63+
if (!atlasMetadata || dismissed) {
5564
return null;
5665
}
66+
5767
return (
58-
<Banner variant="info">
68+
<Banner variant="info" dismissible onClose={() => setDismissed(true)}>
5969
<Body weight="medium">Looking for search indexes?</Body>
6070
These indexes can be created and viewed under{' '}
6171
{atlasMetadata ? (

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
spacing,
2323
useDarkMode,
2424
WorkspaceContainer,
25+
usePersistedState,
2526
lighten,
2627
Banner,
2728
Body,
@@ -298,6 +299,9 @@ const AnalyzingScreen: React.FunctionComponent<{
298299
);
299300
};
300301

302+
const DISMISSED_SEARCH_INDEXES_BANNER_LOCAL_STORAGE_KEY =
303+
'mongodb_compass_dismissedSearchIndexesBanner' as const;
304+
301305
const FieldList: React.FunctionComponent<{
302306
schema: MongodbSchema | null;
303307
analysisState: AnalysisState;
@@ -341,8 +345,18 @@ const title = 'Atlas’ Performance Advisor.';
341345
const PerformanceAdvisorBanner = () => {
342346
const connectionInfo = useConnectionInfo();
343347
const track = useTelemetry();
348+
349+
const [dismissed, setDismissed] = usePersistedState(
350+
DISMISSED_SEARCH_INDEXES_BANNER_LOCAL_STORAGE_KEY,
351+
false
352+
);
353+
354+
if (dismissed) {
355+
return <></>;
356+
}
357+
344358
return (
345-
<Banner variant="info">
359+
<Banner variant="info" dismissible onClose={() => setDismissed(true)}>
346360
<Body weight="medium">Looking for schema anti-patterns?</Body>
347361
In its place, you may refer to Data Explorer’s performance insights{' '}
348362
<Badge className={insightsBadgeStyles} variant="blue">

0 commit comments

Comments
 (0)