Skip to content

Commit 18d819f

Browse files
authored
feat(compass-web): show performance advisor banner COMPASS-7596 (#5541)
* setup banner without link * fix ux * add link todos
1 parent 2f58eea commit 18d819f

File tree

5 files changed

+109
-41
lines changed

5 files changed

+109
-41
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ const AtlasIndexesBanner = () => {
4242
<Banner variant="info">
4343
<Body weight="medium">Looking for search indexes?</Body>
4444
These indexes can be created and viewed under{' '}
45+
{/* todo: COMPASS-7701 add correct link */}
46+
{/* #/clusters/atlasSearch/{clusterName} */}
4547
<Link href={'#/clusters/atlasSearch'} target="_blank" hideExternalIcon>
46-
Atlas Search
48+
Atlas Search.
4749
</Link>
48-
.
4950
</Banner>
5051
);
5152
};

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ export type UserConfigurablePreferences = PermanentFeatureFlags &
5454
enableImportExport: boolean;
5555
enableAggregationBuilderRunPipeline: boolean;
5656
enableAggregationBuilderExtraOptions: boolean;
57+
enableHackoladeBanner: boolean;
58+
enablePerformanceAdvisorBanner: boolean;
5759
};
5860

5961
export type InternalUserPreferences = {
@@ -703,6 +705,29 @@ export const storedUserPreferencesProps: Required<{
703705
type: 'boolean',
704706
},
705707

708+
enableHackoladeBanner: {
709+
ui: true,
710+
cli: true,
711+
global: true,
712+
description: {
713+
short:
714+
'Show Hackolade banner to users for data modeling and schema design',
715+
},
716+
validator: z.boolean().default(true),
717+
type: 'boolean',
718+
},
719+
720+
enablePerformanceAdvisorBanner: {
721+
ui: true,
722+
cli: true,
723+
global: true,
724+
description: {
725+
short: 'Show performance advisor banner to users for performance tuning',
726+
},
727+
validator: z.boolean().default(false),
728+
type: 'boolean',
729+
},
730+
706731
...allFeatureFlagsProps,
707732
};
708733

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

Lines changed: 79 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,48 @@ import {
2424
useDarkMode,
2525
WorkspaceContainer,
2626
lighten,
27+
Banner,
28+
Body,
29+
Badge,
30+
Icon,
2731
} from '@mongodb-js/compass-components';
2832
import { HackoladePromoBanner } from './promo-banner';
2933
import type { configureActions } from '../actions';
34+
import { usePreference } from 'compass-preferences-model/provider';
3035

31-
const rootStyles = css`
32-
width: 100%;
33-
height: 100%;
34-
display: flex;
35-
flex-direction: column;
36-
align-items: stretch;
37-
flex-grow: 1;
38-
flex-shrink: 1;
39-
`;
36+
const rootStyles = css({
37+
width: '100%',
38+
height: '100%',
39+
display: 'flex',
40+
flexDirection: 'column',
41+
alignItems: 'stretch',
42+
flexGrow: 1,
43+
flexShrink: 1,
44+
});
4045

41-
const loaderStyles = css`
42-
height: 100%;
43-
display: flex;
44-
justify-content: center;
45-
`;
46+
const loaderStyles = css({
47+
height: '100%',
48+
display: 'flex',
49+
justifyContent: 'center',
50+
});
4651

47-
const schemaStyles = css`
48-
width: 100%;
49-
padding: 0 ${spacing[3]}px;
50-
flex-grow: 1;
51-
overflow: auto;
52-
`;
52+
const schemaStyles = css({
53+
width: '100%',
54+
flexGrow: 1,
55+
overflow: 'auto',
56+
});
57+
58+
const contentStyles = css({
59+
paddingLeft: spacing[3],
60+
paddingRight: spacing[3],
61+
display: 'flex',
62+
flexDirection: 'column',
63+
gap: spacing[3],
64+
});
65+
66+
const insightsBadgeStyles = css({
67+
verticalAlign: 'middle',
68+
});
5369

5470
const minichartStyles = (darkMode: boolean) => {
5571
const mcBlue0 = palette.blue.light1;
@@ -314,6 +330,27 @@ const FieldList: React.FunctionComponent<{
314330
);
315331
};
316332

333+
const nbsp = '\u00a0';
334+
const PerformanceAdvisorBanner = () => {
335+
return (
336+
<Banner variant="info">
337+
<Body weight="medium">Looking for schema anti-patterns?</Body>
338+
In its place, you may refer to Data Explorer’s performance insights{' '}
339+
<Badge className={insightsBadgeStyles} variant="blue">
340+
<Icon glyph="Bulb" size="small" />
341+
Insight
342+
</Badge>
343+
{nbsp}or{nbsp}
344+
{/* todo: COMPASS-7701 add correct link */}
345+
{/* #/metrics/replicaSet/{clusterId}/advisor */}
346+
{/* #/serverless/advisor/{clusterName}/createIndexes */}
347+
<Link href="#/" target="_blank" hideExternalIcon>
348+
Atlas’ Performance Advisor.
349+
</Link>
350+
</Banner>
351+
);
352+
};
353+
317354
const Schema: React.FunctionComponent<{
318355
actions: ReturnType<typeof configureActions>;
319356
analysisState: AnalysisState;
@@ -351,6 +388,11 @@ const Schema: React.FunctionComponent<{
351388
actions.startAnalysis();
352389
}, [actions]);
353390

391+
const enableHackoladeBanner = usePreference('enableHackoladeBanner');
392+
const enablePerformanceAdvisorBanner = usePreference(
393+
'enablePerformanceAdvisorBanner'
394+
);
395+
354396
return (
355397
<div className={rootStyles}>
356398
<WorkspaceContainer
@@ -366,20 +408,23 @@ const Schema: React.FunctionComponent<{
366408
/>
367409
}
368410
>
369-
<HackoladePromoBanner></HackoladePromoBanner>
370-
{analysisState === ANALYSIS_STATE_INITIAL && (
371-
<InitialScreen onApplyClicked={onApplyClicked} />
372-
)}
373-
{analysisState === ANALYSIS_STATE_ANALYZING && (
374-
<AnalyzingScreen onCancelClicked={onCancelClicked} />
375-
)}
376-
{analysisState === ANALYSIS_STATE_COMPLETE && (
377-
<FieldList
378-
schema={schema}
379-
analysisState={analysisState}
380-
actions={actions}
381-
/>
382-
)}
411+
<div className={contentStyles}>
412+
{enablePerformanceAdvisorBanner && <PerformanceAdvisorBanner />}
413+
{enableHackoladeBanner && <HackoladePromoBanner />}
414+
{analysisState === ANALYSIS_STATE_INITIAL && (
415+
<InitialScreen onApplyClicked={onApplyClicked} />
416+
)}
417+
{analysisState === ANALYSIS_STATE_ANALYZING && (
418+
<AnalyzingScreen onCancelClicked={onCancelClicked} />
419+
)}
420+
{analysisState === ANALYSIS_STATE_COMPLETE && (
421+
<FieldList
422+
schema={schema}
423+
analysisState={analysisState}
424+
actions={actions}
425+
/>
426+
)}
427+
</div>
383428
</WorkspaceContainer>
384429
</div>
385430
);

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ const bannerBodyStyles = css({
2121
paddingLeft: spacing[3],
2222
paddingRight: spacing[3],
2323
borderRadius: '12px',
24-
marginLeft: spacing[3],
25-
marginRight: spacing[3],
26-
'&:not(:last-child)': {
27-
marginBottom: spacing[4],
28-
},
2924
});
3025

3126
const bannerBodyLightModeStyles = css({

packages/compass-web/src/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ const CompassWeb = ({
220220
enableAtlasSearchIndexes: false,
221221
enableImportExport: false,
222222
enableGenAIFeatures: false,
223+
enableHackoladeBanner: false,
224+
enablePerformanceAdvisorBanner: true,
223225
cloudFeatureRolloutAccess: {
224226
GEN_AI_COMPASS: false,
225227
},

0 commit comments

Comments
 (0)