Skip to content

Commit 130beea

Browse files
committed
tmp: implement store and most of the business logic
1 parent 20a1bf4 commit 130beea

File tree

20 files changed

+1554
-23
lines changed

20 files changed

+1554
-23
lines changed

packages/compass-connection-import-export/src/components/select-table.tsx renamed to packages/compass-components/src/components/select-table.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import React, { useCallback } from 'react';
12
import {
23
Cell,
34
Checkbox,
@@ -7,8 +8,7 @@ import {
78
Table,
89
TableBody,
910
TableHead,
10-
} from '@mongodb-js/compass-components';
11-
import React, { useCallback } from 'react';
11+
} from './leafygreen';
1212

1313
type SelectItem = {
1414
id: string;

packages/compass-components/src/components/workspace-container.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ const darkThemeStyles = css({
9999
});
100100

101101
type WorkspaceContainerProps = {
102-
toolbar?: React.ReactNode;
102+
toolbar?: React.ReactNode | (() => void);
103103
toolbarRef?: React.Ref<HTMLDivElement>;
104104
scrollableContainerRef?: React.Ref<HTMLDivElement>;
105105
initialTopInView?: boolean;
@@ -148,7 +148,7 @@ function WorkspaceContainer({
148148
>
149149
{toolbar && (
150150
<div ref={toolbarRef} className={toolbarStyles}>
151-
{toolbar}
151+
{typeof toolbar === 'function' ? toolbar() : toolbar}
152152
</div>
153153
)}
154154
<div className={scrollBoxStyles} ref={scrollContainer}>

packages/compass-components/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,4 @@ export {
209209
type VirtualListProps,
210210
type ItemRenderer as VirtualListItemRenderer,
211211
} from './components/virtual-list';
212+
export { SelectTable } from './components/select-table';

packages/compass-connection-import-export/src/components/export-modal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import {
66
FormFieldContainer,
77
FormModal,
88
openToast,
9+
SelectTable,
910
} from '@mongodb-js/compass-components';
1011
import { FileInput } from './file-input';
1112
import { Passphrase } from './passphrase';
12-
import { SelectTable } from './select-table';
1313
import type { ImportExportResult } from '../hooks/common';
1414
import { useOpenModalThroughIpc } from '../hooks/common';
1515
import { useExportConnections } from '../hooks/use-export-connections';

packages/compass-connection-import-export/src/components/import-modal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import {
77
FormModal,
88
spacing,
99
openToast,
10+
SelectTable,
1011
} from '@mongodb-js/compass-components';
1112
import { FileInput } from './file-input';
1213
import { Passphrase } from './passphrase';
13-
import { SelectTable } from './select-table';
1414
import type { ImportExportResult } from '../hooks/common';
1515
import { useOpenModalThroughIpc } from '../hooks/common';
1616
import { useImportConnections } from '../hooks/use-import-connections';

packages/compass-connection-import-export/tsconfig.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
"compilerOptions": {
44
"outDir": "dist"
55
},
6-
"include": ["src/**/*"],
6+
"include": [
7+
"src/**/*",
8+
"../compass-components/src/components/select-table.spec.tsx",
9+
"../compass-components/src/components/select-table.tsx"
10+
],
711
"exclude": ["./src/**/*.spec.*"]
812
}

packages/compass-connections/src/stores/connections-store-redux.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,13 @@ const connectWithOptions = (
14791479
return inflightConnection;
14801480
}
14811481
inflightConnection = (async () => {
1482+
if (
1483+
getCurrentConnectionStatus(getState(), connectionInfo.id) ===
1484+
'connected'
1485+
) {
1486+
return;
1487+
}
1488+
14821489
const isAutoconnectAttempt = isAutoconnectInfo(
14831490
getState(),
14841491
connectionInfo.id

packages/compass-connections/src/stores/store-context.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,14 +271,15 @@ export function useConnectionIds(
271271
export function useConnectionsList(
272272
filter?: (connection: ConnectionState) => boolean
273273
) {
274-
return useSelector<ConnectionState[]>(
274+
return useSelector<(ConnectionState & { title: string })[]>(
275275
(state) => {
276276
return state.connections.ids
277277
.filter((id) => {
278278
return filter?.(state.connections.byId[id]) ?? true;
279279
})
280280
.map((id) => {
281-
return state.connections.byId[id];
281+
const connection = state.connections.byId[id];
282+
return { ...connection, title: getConnectionTitle(connection.info) };
282283
});
283284
},
284285
(a, b) => {
Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,31 @@
11
import React from 'react';
22
import { connect } from 'react-redux';
3+
import DiagramEditor from './diagram-editor';
4+
import SavedDiagramsList from './saved-diagrams-list';
5+
import NewDiagramFormModal from './new-diagram-form';
6+
import type { DataModelingState } from '../store/reducer';
37

4-
type DataModelingPluginInitialProps = Record<string, never>;
8+
type DataModelingPluginInitialProps = {
9+
showList: boolean;
10+
};
511

6-
const DataModeling: React.FunctionComponent<
7-
DataModelingPluginInitialProps
8-
> = () => {
9-
return <>Hello from Data Modeling plugin</>;
12+
const DataModeling: React.FunctionComponent<DataModelingPluginInitialProps> = ({
13+
showList,
14+
}) => {
15+
return (
16+
<>
17+
{showList ? (
18+
<SavedDiagramsList></SavedDiagramsList>
19+
) : (
20+
<DiagramEditor></DiagramEditor>
21+
)}
22+
<NewDiagramFormModal></NewDiagramFormModal>
23+
</>
24+
);
1025
};
1126

12-
export default connect()(DataModeling);
27+
export default connect((state: DataModelingState) => {
28+
return {
29+
showList: state.step === 'NO_DIAGRAM_SELECTED',
30+
};
31+
})(DataModeling);

0 commit comments

Comments
 (0)