Skip to content

Commit f42359b

Browse files
committed
chore(import-export): refactor import store to use service injection
1 parent ddac92f commit f42359b

File tree

18 files changed

+79
-343
lines changed

18 files changed

+79
-343
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ function Home({
355355
// AppRegistry scope for a connected application
356356
<AppRegistryProvider>
357357
<DataServiceProvider value={connectedDataService.current}>
358+
<ImportPlugin></ImportPlugin>
358359
<ExportPlugin></ExportPlugin>
359360
<Workspace namespace={namespace} />
360361
</DataServiceProvider>
@@ -386,7 +387,6 @@ function Home({
386387
<DropDatabasePlugin></DropDatabasePlugin>
387388
<CreateCollectionPlugin></CreateCollectionPlugin>
388389
<DropCollectionPlugin></DropCollectionPlugin>
389-
<ImportPlugin></ImportPlugin>
390390
<AtlasSignIn></AtlasSignIn>
391391
</SignalHooksProvider>
392392
);

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,16 @@ function ImportModal({
168168
if (isOpen && !fileName && errors.length === 0) {
169169
// Show the file input when we don't have a file to import yet.
170170
return (
171-
<ImportFileInput
172-
autoOpen
173-
onCancel={handleClose}
174-
fileName={fileName}
175-
selectImportFileName={selectImportFileName}
176-
/>
171+
// Don't actually show it on the screen, just render it to trigger
172+
// autoOpen
173+
<div style={{ display: 'none' }}>
174+
<ImportFileInput
175+
autoOpen
176+
onCancel={handleClose}
177+
fileName={fileName}
178+
selectImportFileName={selectImportFileName}
179+
/>
180+
</div>
177181
);
178182
}
179183

@@ -266,7 +270,7 @@ function ImportModal({
266270
* Map the state of the store to component properties.
267271
*/
268272
const mapStateToProps = (state: RootImportState) => ({
269-
ns: state.ns,
273+
ns: state.import.namespace,
270274
isOpen: state.import.isOpen,
271275
errors: state.import.errors,
272276
fileType: state.import.fileType,

packages/compass-import-export/src/import/import-csv.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { ByteCounter } from '../utils/byte-counter';
2828
const debug = createDebug('import-csv');
2929

3030
type ImportCSVOptions = {
31-
dataService: DataService;
31+
dataService: Pick<DataService, 'bulkWrite' | 'insertOne'>;
3232
ns: string;
3333
input: Readable;
3434
output?: Writable;

packages/compass-import-export/src/import/import-json.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const debug = createDebug('import-json');
2626
type JSONVariant = 'json' | 'jsonl';
2727

2828
type ImportJSONOptions = {
29-
dataService: DataService;
29+
dataService: Pick<DataService, 'bulkWrite' | 'insertOne'>;
3030
ns: string;
3131
input: Readable;
3232
output?: Writable;

packages/compass-import-export/src/index.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,18 @@ import { activatePlugin as activateExportPlugin } from './stores/export-store';
88
/**
99
* The import plugin.
1010
*/
11-
export const ImportPlugin = registerHadronPlugin({
12-
name: 'Import',
13-
component: ImportPluginComponent,
14-
activate: activateImportPlugin,
15-
});
11+
export const ImportPlugin = registerHadronPlugin(
12+
{
13+
name: 'Import',
14+
component: ImportPluginComponent,
15+
activate: activateImportPlugin,
16+
},
17+
{
18+
dataService: dataServiceLocator as typeof dataServiceLocator<
19+
'isConnected' | 'bulkWrite' | 'insertOne'
20+
>,
21+
}
22+
);
1623

1724
/**
1825
* The export plugin.

packages/compass-import-export/src/modules/compass/data-service.spec.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

packages/compass-import-export/src/modules/compass/data-service.ts

Lines changed: 0 additions & 51 deletions
This file was deleted.

packages/compass-import-export/src/modules/compass/global-app-registry.spec.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

packages/compass-import-export/src/modules/compass/global-app-registry.ts

Lines changed: 0 additions & 57 deletions
This file was deleted.

packages/compass-import-export/src/modules/compass/index.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)