Skip to content

Commit fa2e4ab

Browse files
committed
Revert "feat(compass-crud): add bloated docs insight to the document list COMPASS-6837 (#4566)"
This reverts commit bfb9cbb.
1 parent 80bebdf commit fa2e4ab

File tree

10 files changed

+44
-170
lines changed

10 files changed

+44
-170
lines changed

package-lock.json

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/compass-components/src/components/document-list/document-actions-group.tsx

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import React, { useEffect, useRef, useState } from 'react';
2-
import { css, cx } from '@leafygreen-ui/emotion';
2+
import { css } from '@leafygreen-ui/emotion';
33
import { spacing } from '@leafygreen-ui/tokens';
44
import { Button, Icon } from '../leafygreen';
55
import { Tooltip } from '../tooltip';
6-
import type { Signal } from '../signal-popover';
7-
import { SignalPopover } from '../signal-popover';
86

97
const actionsGroupContainer = css({
108
position: 'absolute',
119
display: 'flex',
12-
alignItems: 'center',
1310
gap: spacing[2],
1411
width: '100%',
1512
top: spacing[2] + spacing[1],
@@ -25,24 +22,6 @@ const actionsGroupItem = css({
2522

2623
const actionsGroupItemSeparator = css({
2724
flex: '1 0 auto',
28-
pointerEvents: 'none',
29-
});
30-
31-
const actionsGroupIdle = css({
32-
'& > button': {
33-
display: 'none',
34-
},
35-
});
36-
37-
const actionsGroupHovered = css({
38-
'& > button': {
39-
display: 'block',
40-
},
41-
});
42-
43-
// Insight icon is always visible, even when action buttons are not
44-
const actionsGroupSignalPopover = css({
45-
display: 'block !important',
4625
});
4726

4827
function useElementParentHoverState<T extends HTMLElement>(
@@ -80,7 +59,6 @@ const DocumentActionsGroup: React.FunctionComponent<
8059
onClone?: () => void;
8160
onRemove?: () => void;
8261
onlyShowOnHover?: boolean;
83-
insights?: Signal | Signal[];
8462
} & (
8563
| { onExpand?: never; expanded?: never }
8664
| { onExpand: () => void; expanded: boolean }
@@ -93,13 +71,10 @@ const DocumentActionsGroup: React.FunctionComponent<
9371
onExpand,
9472
expanded,
9573
onlyShowOnHover = true,
96-
insights,
9774
}) => {
98-
const [signalOpened, setSignalOpened] = useState(false);
9975
const conatinerRef = useRef<HTMLDivElement | null>(null);
10076
const isHovered = useElementParentHoverState(conatinerRef);
10177
const [showCopyButtonTooltip, setShowCopyButtonTooltip] = useState(false);
102-
const isActive = isHovered || signalOpened;
10378

10479
useEffect(() => {
10580
if (showCopyButtonTooltip === true) {
@@ -115,10 +90,10 @@ const DocumentActionsGroup: React.FunctionComponent<
11590
return (
11691
<div
11792
ref={conatinerRef}
118-
className={cx(
119-
actionsGroupContainer,
120-
onlyShowOnHover && (isActive ? actionsGroupHovered : actionsGroupIdle)
121-
)}
93+
className={actionsGroupContainer}
94+
style={{
95+
display: onlyShowOnHover ? (isHovered ? 'flex' : 'none') : 'flex',
96+
}}
12297
>
12398
{onExpand && (
12499
<Button
@@ -138,14 +113,6 @@ const DocumentActionsGroup: React.FunctionComponent<
138113
></Button>
139114
)}
140115
<span className={actionsGroupItemSeparator}></span>
141-
{insights && (
142-
<div className={cx(actionsGroupItem, actionsGroupSignalPopover)}>
143-
<SignalPopover
144-
signals={insights}
145-
onPopoverOpenChange={setSignalOpened}
146-
></SignalPopover>
147-
</div>
148-
)}
149116
{onEdit && (
150117
<Button
151118
size="xsmall"

packages/compass-components/src/components/signal-popover.tsx

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ export type Signal = {
5252
type SignalPopoverProps = {
5353
/** List of signals to render */
5454
signals: Signal | Signal[];
55+
5556
darkMode?: boolean;
56-
onPopoverOpenChange?: (open: boolean) => void;
5757
};
5858

5959
const signalCardContentStyles = css({
@@ -362,7 +362,6 @@ const closeButtonMultiSignalStyles = css({
362362
const SignalPopover: React.FunctionComponent<SignalPopoverProps> = ({
363363
signals: _signals,
364364
darkMode: _darkMode,
365-
onPopoverOpenChange: _onPopoverOpenChange,
366365
}) => {
367366
const [cueOpen, setCueOpen] = useState(false);
368367
const darkMode = useDarkMode(_darkMode);
@@ -393,19 +392,15 @@ const SignalPopover: React.FunctionComponent<SignalPopoverProps> = ({
393392
return observer.disconnect.bind(observer);
394393
}, []);
395394

396-
const onPopoverOpenChange = useCallback(
397-
(newStatus: boolean) => {
398-
setPopoverOpen(newStatus);
399-
_onPopoverOpenChange?.(newStatus);
400-
// Reset current signal index when popover is being opened. If we do this on
401-
// close instead, the popover content is weirdly changed while the closing
402-
// animation is happening
403-
if (newStatus === true) {
404-
setCurrentSignalIndex(0);
405-
}
406-
},
407-
[_onPopoverOpenChange]
408-
);
395+
const onPopoverOpenChange = useCallback((newStatus: boolean) => {
396+
setPopoverOpen(newStatus);
397+
// Reset current signal index when popover is being opened. If we do this on
398+
// close instead, the popover content is weirdly changed while the closing
399+
// animation is happening
400+
if (newStatus === true) {
401+
setCurrentSignalIndex(0);
402+
}
403+
}, []);
409404

410405
const badgeLabel = multiSignals ? (
411406
<>{signals.length}&nbsp;insights</>

packages/compass-crud/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@
104104
"react-dom": "^17.0.2",
105105
"reflux": "^0.4.1",
106106
"reflux-state-mixin": "github:mongodb-js/reflux-state-mixin",
107-
"semver": "^7.5.2",
108107
"sinon": "^8.1.1"
109108
},
110109
"dependencies": {

packages/compass-crud/src/components/editable-document.tsx

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import type { Document } from 'hadron-document';
44
import HadronDocument from 'hadron-document';
55
import { DocumentList } from '@mongodb-js/compass-components';
66
import type { CrudActions } from '../stores/crud-store';
7-
import { withPreferences } from 'compass-preferences-model';
87

98
/**
109
* The base class.
@@ -34,12 +33,12 @@ const TEST_ID = 'editable-document';
3433
export type EditableDocumentProps = {
3534
doc: Document;
3635
expandAll?: boolean;
36+
3737
removeDocument?: CrudActions['removeDocument'];
3838
replaceDocument?: CrudActions['replaceDocument'];
3939
updateDocument?: CrudActions['updateDocument'];
4040
openInsertDocumentDialog?: CrudActions['openInsertDocumentDialog'];
4141
copyToClipboard?: CrudActions['copyToClipboard'];
42-
showInsights?: boolean;
4342
};
4443

4544
type EditableDocumentState = {
@@ -222,18 +221,6 @@ class EditableDocument extends React.Component<
222221
onClone={this.handleClone.bind(this)}
223222
onExpand={this.handleExpandAll.bind(this)}
224223
expanded={!!this.state.expandAll}
225-
insights={
226-
this.props.showInsights && (this.props.doc?.size ?? 0) > 10_000_000
227-
? {
228-
id: 'bloated-document',
229-
title: 'Possibly bloated document',
230-
description:
231-
'Large documents can slow down queries by decreasing the number of documents that can be stored in RAM. Consider breaking up your data into more collections with smaller documents, and using references to consolidate the data you need.',
232-
learnMoreLink:
233-
'https://www.mongodb.com/docs/atlas/schema-suggestions/reduce-document-size/',
234-
}
235-
: undefined
236-
}
237224
/>
238225
);
239226
}
@@ -312,8 +299,7 @@ class EditableDocument extends React.Component<
312299
updateDocument: PropTypes.func.isRequired,
313300
openInsertDocumentDialog: PropTypes.func.isRequired,
314301
copyToClipboard: PropTypes.func.isRequired,
315-
showInsights: PropTypes.bool,
316302
};
317303
}
318304

319-
export default withPreferences(EditableDocument, ['showInsights'], React);
305+
export default EditableDocument;

packages/compass-crud/src/components/readonly-document.tsx

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
33
import { DocumentList } from '@mongodb-js/compass-components';
44
import type Document from 'hadron-document';
55
import type { TypeCastMap } from 'hadron-type-checker';
6-
import { withPreferences } from 'compass-preferences-model';
76
type BSONObject = TypeCastMap['Object'];
87

98
/**
@@ -26,7 +25,6 @@ export type ReadonlyDocumentProps = {
2625
openInsertDocumentDialog?: (doc: BSONObject, cloned: boolean) => void;
2726
doc: Document;
2827
expandAll: boolean;
29-
showInsights?: boolean;
3028
};
3129

3230
/**
@@ -68,18 +66,6 @@ class ReadonlyDocument extends React.Component<ReadonlyDocumentProps> {
6866
onClone={
6967
this.props.openInsertDocumentDialog ? this.handleClone : undefined
7068
}
71-
insights={
72-
this.props.showInsights && (this.props.doc?.size ?? 0) > 10_000_000
73-
? {
74-
id: 'bloated-document',
75-
title: 'Possibly bloated document',
76-
description:
77-
'Large documents can slow down queries by decreasing the number of documents that can be stored in RAM. Consider breaking up your data into more collections with smaller documents, and using references to consolidate the data you need.',
78-
learnMoreLink:
79-
'https://www.mongodb.com/docs/atlas/schema-suggestions/reduce-document-size/',
80-
}
81-
: undefined
82-
}
8369
/>
8470
);
8571
}
@@ -107,8 +93,7 @@ class ReadonlyDocument extends React.Component<ReadonlyDocumentProps> {
10793
doc: PropTypes.object.isRequired,
10894
expandAll: PropTypes.bool,
10995
openInsertDocumentDialog: PropTypes.func,
110-
showInsights: PropTypes.bool,
11196
};
11297
}
11398

114-
export default withPreferences(ReadonlyDocument, ['showInsights'], React);
99+
export default ReadonlyDocument;

0 commit comments

Comments
 (0)