Skip to content

Commit 9ec223b

Browse files
authored
chore(sidebar): remove old sidebar code COMPASS-6091 (#3478)
* remove old sidebar code * remove unused deps
1 parent 56d9d68 commit 9ec223b

File tree

72 files changed

+37
-4196
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+37
-4196
lines changed

package-lock.json

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

packages/compass-connections/src/components/connection-list/connection-list.tsx

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,10 @@ import type { ConnectionInfo } from 'mongodb-data-service';
1818
import Connection from './connection';
1919
import ConnectionsTitle from './connections-title';
2020

21-
const legacyNewConnectionButtonContainerStyles = css({
22-
display: 'flex',
23-
flexDirection: 'column',
24-
background: uiColors.gray.dark2,
25-
position: 'relative',
26-
});
27-
2821
const newConnectionButtonContainerStyles = css({
2922
padding: spacing[3],
3023
});
3124

32-
const legacyNewConnectionButtonStyles = css({
33-
border: 'none',
34-
fontWeight: 'bold',
35-
borderRadius: 0,
36-
svg: {
37-
color: uiColors.white,
38-
},
39-
':hover': {
40-
border: 'none',
41-
boxShadow: 'none',
42-
},
43-
});
44-
4525
const newConnectionButtonStyles = css({
4626
width: '100%',
4727
justifyContent: 'center',
@@ -166,32 +146,21 @@ function ConnectionList({
166146

167147
const { theme } = useTheme();
168148

169-
const useNewSidebar = process?.env?.COMPASS_SHOW_NEW_SIDEBAR !== 'false';
170-
171149
const isExpanded = true; // TODO: https://jira.mongodb.org/browse/COMPASS-5967
172150

173151
return (
174152
<Fragment>
175-
{useNewSidebar && <ConnectionsTitle isExpanded={isExpanded} />}
176-
<div
177-
className={
178-
useNewSidebar
179-
? newConnectionButtonContainerStyles
180-
: legacyNewConnectionButtonContainerStyles
181-
}
182-
>
153+
<ConnectionsTitle isExpanded={isExpanded} />
154+
<div className={newConnectionButtonContainerStyles}>
183155
<Button
184156
className={cx(
185-
useNewSidebar
186-
? newConnectionButtonStyles
187-
: legacyNewConnectionButtonStyles,
188-
useNewSidebar &&
189-
(theme === Theme.Dark
190-
? newConnectionButtonStylesDark
191-
: newConnectionButtonStylesLight)
157+
newConnectionButtonStyles,
158+
theme === Theme.Dark
159+
? newConnectionButtonStylesDark
160+
: newConnectionButtonStylesLight
192161
)}
193162
onClick={createNewConnection}
194-
size={useNewSidebar ? 'default' : 'large'}
163+
size="default"
195164
data-testid="new-connection-button"
196165
rightGlyph={<Icon glyph="Plus" />}
197166
>

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

Lines changed: 18 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
import React, { useState } from 'react';
1+
import React from 'react';
22
import {
33
ResizableSidebar,
4-
useTheme,
5-
Theme,
6-
ThemeProvider,
74
ErrorBoundary,
85
WorkspaceContainer,
96
spacing,
107
css,
118
} from '@mongodb-js/compass-components';
12-
import type { ThemeState } from '@mongodb-js/compass-components';
139
import ConnectionForm from '@mongodb-js/connection-form';
1410
import type {
1511
ConnectionInfo,
@@ -87,51 +83,30 @@ function Connections({
8783
isConnected,
8884
} = state;
8985

90-
const existingTheme = useTheme();
91-
92-
// Use the same theme as Home if the feature flag is activated, otherwise
93-
// always use Dark. We'll remove this code along with the provider once we
94-
// remove the feature flag, hopefully soon.
95-
const useNewSidebar = process?.env?.COMPASS_SHOW_NEW_SIDEBAR !== 'false';
96-
const expectedTheme = useNewSidebar ? existingTheme.theme : Theme.Dark;
97-
98-
const [theme, setTheme] = useState<ThemeState>({
99-
theme: expectedTheme,
100-
enabled: true,
101-
});
102-
103-
// If the inherited theme (from Home) changes because the user changed the
104-
// theme via the menu, we have to update it here too.
105-
if (theme.theme !== expectedTheme) {
106-
setTheme({ theme: expectedTheme, enabled: true });
107-
}
108-
10986
return (
11087
<div
11188
data-testid={
11289
isConnected ? 'connections-connected' : 'connections-disconnected'
11390
}
11491
className={connectStyles}
11592
>
116-
<ThemeProvider theme={theme}>
117-
<ResizableSidebar>
118-
<ConnectionList
119-
activeConnectionId={activeConnectionId}
120-
favoriteConnections={favoriteConnections}
121-
recentConnections={recentConnections}
122-
createNewConnection={createNewConnection}
123-
setActiveConnectionId={setActiveConnectionById}
124-
onDoubleClick={(connectionInfo) => {
125-
void connect(connectionInfo);
126-
}}
127-
removeAllRecentsConnections={() => {
128-
void removeAllRecentsConnections();
129-
}}
130-
removeConnection={removeConnection}
131-
duplicateConnection={duplicateConnection}
132-
/>
133-
</ResizableSidebar>
134-
</ThemeProvider>
93+
<ResizableSidebar>
94+
<ConnectionList
95+
activeConnectionId={activeConnectionId}
96+
favoriteConnections={favoriteConnections}
97+
recentConnections={recentConnections}
98+
createNewConnection={createNewConnection}
99+
setActiveConnectionId={setActiveConnectionById}
100+
onDoubleClick={(connectionInfo) => {
101+
void connect(connectionInfo);
102+
}}
103+
removeAllRecentsConnections={() => {
104+
void removeAllRecentsConnections();
105+
}}
106+
removeConnection={removeConnection}
107+
duplicateConnection={duplicateConnection}
108+
/>
109+
</ResizableSidebar>
135110
<WorkspaceContainer>
136111
<div className={formContainerStyles}>
137112
<ErrorBoundary

packages/compass-databases-navigation/src/database-item.tsx

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,10 @@ const ExpandButton: React.FunctionComponent<{
6666
const databaseItem = css({
6767
height: DATABASE_ROW_HEIGHT,
6868
paddingRight: spacing[1],
69-
});
70-
71-
const databaseItemOldSpacing = css({
72-
paddingLeft: spacing[1],
73-
});
74-
75-
const databaseItemNewSpacing = css({
7669
paddingLeft: spacing[2],
7770
});
7871

79-
const databaseItemLabelOldSpacing = css({
80-
marginLeft: spacing[1],
81-
});
82-
83-
const databaseItemLabelNewSpacing = css({
72+
const databaseItemLabel = css({
8473
marginLeft: spacing[2],
8574
});
8675

@@ -150,8 +139,6 @@ export const DatabaseItem: React.FunctionComponent<
150139
];
151140
}, []);
152141

153-
const useNewSidebar = process?.env?.COMPASS_SHOW_NEW_SIDEBAR !== 'false';
154-
155142
return (
156143
<ItemContainer
157144
id={id}
@@ -163,26 +150,16 @@ export const DatabaseItem: React.FunctionComponent<
163150
isActive={isActive}
164151
isTabbable={isTabbable}
165152
onDefaultAction={onDefaultAction}
166-
className={cx(
167-
databaseItem,
168-
useNewSidebar ? databaseItemNewSpacing : databaseItemOldSpacing
169-
)}
153+
className={databaseItem}
170154
style={style}
171155
{...hoverProps}
172156
>
173157
<ExpandButton
174158
onClick={onExpandButtonClick}
175159
isExpanded={isExpanded}
176160
></ExpandButton>
177-
{useNewSidebar && <Icon glyph="Database" size="small"></Icon>}
178-
<ItemLabel
179-
className={
180-
useNewSidebar
181-
? databaseItemLabelNewSpacing
182-
: databaseItemLabelOldSpacing
183-
}
184-
title={name}
185-
>
161+
<Icon glyph="Database" size="small"></Icon>
162+
<ItemLabel className={databaseItemLabel} title={name}>
186163
{name}
187164
</ItemLabel>
188165
{!isReadOnly && (

packages/compass-databases-navigation/src/placeholder-item.tsx

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,20 @@ const placeholderItem = css({
1212
});
1313

1414
const padding = {
15-
old: {
16-
database: css({
17-
// Because we are aligning this with non-leafygreen items on the screen we
18-
// have to use custom sizes
19-
paddingLeft: spacing[1] + spacing[2],
20-
}),
21-
collection: css({
22-
paddingLeft: spacing[5],
23-
}),
24-
},
25-
new: {
26-
database: css({
27-
paddingLeft: spacing[4] + spacing[2],
28-
}),
29-
collection: css({
30-
paddingLeft: spacing[4] + spacing[4] + spacing[1],
31-
}),
32-
},
15+
database: css({
16+
paddingLeft: spacing[4] + spacing[2],
17+
}),
18+
collection: css({
19+
paddingLeft: spacing[4] + spacing[4] + spacing[1],
20+
}),
3321
} as const;
3422

3523
export const PlaceholderItem: React.FunctionComponent<{
3624
type?: 'database' | 'collection';
3725
style?: CSSProperties;
3826
}> = ({ type = 'collection', style }) => {
39-
const useNewSidebar = process?.env?.COMPASS_SHOW_NEW_SIDEBAR !== 'false';
40-
const variant = useNewSidebar ? 'new' : 'old';
4127
return (
42-
<div className={cx(placeholderItem, padding[variant][type])} style={style}>
28+
<div className={cx(placeholderItem, padding[type])} style={style}>
4329
<Placeholder />
4430
</div>
4531
);

packages/compass-sidebar/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,8 @@
8888
"@types/react-dom": "^17.0.10",
8989
"@types/sinon-chai": "^3.2.5",
9090
"chai": "^4.3.6",
91-
"classnames": "^2.2.6",
9291
"debug": "^4.2.0",
9392
"depcheck": "^1.4.1",
94-
"enzyme": "^3.11.0",
9593
"eslint": "^7.25.0",
9694
"hadron-app": "^5.0.0",
9795
"hadron-app-registry": "^9.0.0",
@@ -103,7 +101,6 @@
103101
"prettier": "^2.7.1",
104102
"prop-types": "^15.7.2",
105103
"react-dom": "^16.14.0",
106-
"react-fontawesome": "^1.6.1",
107104
"react-redux": "^5.0.6",
108105
"redux": "^4.1.2",
109106
"redux-thunk": "^2.3.0",

0 commit comments

Comments
 (0)