Skip to content

Commit 85dfbf5

Browse files
authored
chore(preferences-model): hide all insights behind a feature flag (#4562)
1 parent eb12afb commit 85dfbf5

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
lines changed

packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-header/pipeline-actions.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
} from '../../../modules/pipeline-builder/builder-helpers';
2121
import { isOutputStage } from '../../../utils/stage';
2222
import { openCreateIndexModal } from '../../../modules/insights';
23+
import { usePreference } from 'compass-preferences-model';
2324

2425
const containerStyles = css({
2526
display: 'flex',
@@ -72,9 +73,10 @@ export const PipelineActions: React.FunctionComponent<PipelineActionsProps> = ({
7273
showCollectionScanInsight,
7374
onCollectionScanInsightActionButtonClick,
7475
}) => {
76+
const showInsights = usePreference('showInsights', React);
7577
return (
7678
<div className={containerStyles}>
77-
{showCollectionScanInsight && (
79+
{showInsights && showCollectionScanInsight && (
7880
<div>
7981
<SignalPopover
8082
signals={{

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export type FeatureFlags = {
1818
enableOidc: boolean; // Not capitalized "OIDC" for spawn arg casing.
1919
enableStageWizard: boolean;
2020
newExplainPlan: boolean;
21+
showInsights: boolean;
2122
};
2223

2324
export const featureFlags: Required<{
@@ -66,4 +67,12 @@ export const featureFlags: Required<{
6667
long: 'Explain plan is now accessible right from the query bar. To view a query’s execution plan, click “Explain” as you would on an aggregation pipeline.',
6768
},
6869
},
70+
71+
showInsights: {
72+
stage: 'development',
73+
description: {
74+
short: 'Show performance insights',
75+
long: 'Surface visual signals in the Compass interface to highlight potential performance issues and anti-patterns.',
76+
},
77+
},
6978
};

packages/compass-query-bar/src/components/option-editor.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
} from '@mongodb-js/compass-editor';
1919
import { connect } from 'react-redux';
2020
import type { QueryBarState } from '../stores/query-bar-reducer';
21+
import { usePreference } from 'compass-preferences-model';
2122

2223
const editorStyles = css({
2324
position: 'relative',
@@ -82,6 +83,8 @@ const OptionEditor: React.FunctionComponent<OptionEditorProps> = ({
8283
['data-testid']: dataTestId,
8384
insights,
8485
}) => {
86+
const showInsights = usePreference('showInsights', React);
87+
8588
const editorContainerRef = useRef<HTMLDivElement>(null);
8689

8790
const focusRingProps = useFocusRing({
@@ -139,7 +142,7 @@ const OptionEditor: React.FunctionComponent<OptionEditorProps> = ({
139142
commands={commands}
140143
data-testid={dataTestId}
141144
/>
142-
{insights && (
145+
{showInsights && insights && (
143146
<div className={queryBarEditorOptionInsightsStyles}>
144147
<SignalPopover signals={insights}></SignalPopover>
145148
</div>

packages/compass-sidebar/src/components/navigation-items.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
useDefaultAction,
1313
SignalPopover,
1414
} from '@mongodb-js/compass-components';
15-
import { withPreferences } from 'compass-preferences-model';
15+
import { usePreference, withPreferences } from 'compass-preferences-model';
1616

1717
import type { ItemAction } from '@mongodb-js/compass-components';
1818

@@ -128,10 +128,10 @@ export function NavigationItem<Actions extends string>({
128128
isActive: boolean;
129129
showTooManyCollectionsInsight?: boolean;
130130
}) {
131+
const showInsights = usePreference('showInsights', React);
131132
const onClick = useCallback(() => {
132133
onAction('open-instance-workspace', tabName);
133134
}, [onAction, tabName]);
134-
135135
const [hoverProps] = useHoverState();
136136
const focusRingProps = useFocusRing();
137137
const defaultActionProps = useDefaultAction(onClick);
@@ -155,7 +155,7 @@ export function NavigationItem<Actions extends string>({
155155
<Icon glyph={glyph} size="small"></Icon>
156156
{isExpanded && <span className={navigationItemLabel}>{label}</span>}
157157
</div>
158-
{isExpanded && showTooManyCollectionsInsight && (
158+
{showInsights && isExpanded && showTooManyCollectionsInsight && (
159159
<div className={signalContainerStyles}>
160160
<SignalPopover
161161
signals={{

packages/databases-collections-list/src/namespace-param.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
SignalPopover,
1212
} from '@mongodb-js/compass-components';
1313
import type { ViewType } from './use-view-type';
14+
import { usePreference } from 'compass-preferences-model';
1415

1516
const namespaceParam = css({
1617
display: 'flex',
@@ -96,6 +97,8 @@ export const NamespaceParam: React.FunctionComponent<{
9697
viewType: ViewType;
9798
insights?: React.ComponentProps<typeof SignalPopover>['signals'];
9899
}> = ({ label, value, status, hint, viewType, insights }) => {
100+
const showInsights = usePreference('showInsights', React);
101+
99102
const renderedValue = useMemo(() => {
100103
const isReady = status !== 'initial' && status !== 'fetching';
101104
return (
@@ -160,7 +163,9 @@ export const NamespaceParam: React.FunctionComponent<{
160163
)}
161164
>
162165
{renderedValue}
163-
{insights && <SignalPopover signals={insights}></SignalPopover>}
166+
{showInsights && insights && (
167+
<SignalPopover signals={insights}></SignalPopover>
168+
)}
164169
</span>
165170
</div>
166171
);

0 commit comments

Comments
 (0)