= ({
}) => {
const isPreferencesReadOnly = usePreference('readOnly', React);
+ useTrackOnChange(
+ 'COMPASS-DATABASES-UI',
+ (track) => {
+ track('Screen', { name: 'databases' });
+ },
+ []
+ );
+
if (databasesLoadingStatus === 'error') {
return (
@@ -137,7 +146,7 @@ const mapDispatchToProps = {
const ConnectedDatabases = connect(
mapStateToProps,
mapDispatchToProps
-)(Databases);
+)(Databases) as React.FunctionComponent>;
export default ConnectedDatabases;
export { Databases };
diff --git a/packages/databases-collections/src/index.ts b/packages/databases-collections/src/index.ts
index 494e6442f0a..230dcd25770 100644
--- a/packages/databases-collections/src/index.ts
+++ b/packages/databases-collections/src/index.ts
@@ -18,18 +18,24 @@ import { DatabasesPlugin } from './databases-plugin';
import MappedRenameCollectionModal from './components/rename-collection-modal/rename-collection-modal';
import { activateRenameCollectionPlugin } from './stores/rename-collection';
-// View collections list plugin.
-const COLLECTIONS_PLUGIN_ROLE = {
- name: 'Collections',
+export const CollectionsWorkspaceTab = {
+ name: 'Collections' as const,
component: CollectionsPlugin,
- order: 1,
};
-export const InstanceTab = {
- name: 'Databases',
+export type CollectionsWorkspace = {
+ type: typeof CollectionsWorkspaceTab['name'];
+} & React.ComponentProps;
+
+export const DatabasesWorkspaceTab = {
+ name: 'Databases' as const,
component: DatabasesPlugin,
};
+export type DatabasesWorkspace = {
+ type: typeof DatabasesWorkspaceTab['name'];
+} & React.ComponentProps;
+
export const CreateNamespacePlugin = registerHadronPlugin(
{
name: 'CreateNamespace',
@@ -75,7 +81,6 @@ export const RenameCollectionPlugin = registerHadronPlugin(
* Activate all the components in the package.
**/
function activate(appRegistry: AppRegistry) {
- appRegistry.registerRole('Database.Tab', COLLECTIONS_PLUGIN_ROLE);
appRegistry.registerStore(
'CollectionsPlugin.CollectionsStore',
CollectionsStore
@@ -86,7 +91,6 @@ function activate(appRegistry: AppRegistry) {
* Deactivate all the components in the package.
**/
function deactivate(appRegistry: AppRegistry) {
- appRegistry.deregisterRole('Database.Tab', COLLECTIONS_PLUGIN_ROLE);
appRegistry.deregisterStore('CollectionsPlugin.CollectionsStore');
}
diff --git a/packages/databases-collections/src/stores/collections-store.js b/packages/databases-collections/src/stores/collections-store.js
index 455eeb78752..29ca5e7b9b9 100644
--- a/packages/databases-collections/src/stores/collections-store.js
+++ b/packages/databases-collections/src/stores/collections-store.js
@@ -1,7 +1,6 @@
import throttle from 'lodash/throttle';
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
-import toNS from 'mongodb-ns';
import { appRegistryActivated } from '../modules/app-registry';
import { changeDatabaseName } from '../modules/database-name';
import { dataServiceConnected } from '../modules/data-service';
@@ -127,22 +126,6 @@ store.onActivated = (appRegistry) => {
store.dispatch(dataServiceConnected(error, dataService));
});
- appRegistry.on('collection-dropped', (namespace) => {
- const { database } = toNS(namespace);
-
- const currentDatabase = store.getState().databaseName;
- if (database === currentDatabase) {
- appRegistry.emit('active-collection-dropped', namespace);
- }
- });
-
- appRegistry.on('database-dropped', (name) => {
- const currentDatabase = store.getState().databaseName;
- if (name === currentDatabase) {
- appRegistry.emit('active-database-dropped', name);
- }
- });
-
/**
* Set the app registry to use later.
*/
diff --git a/packages/databases-collections/src/stores/create-namespace.spec.tsx b/packages/databases-collections/src/stores/create-namespace.spec.tsx
index ac8baa8a46e..1ecfd5630eb 100644
--- a/packages/databases-collections/src/stores/create-namespace.spec.tsx
+++ b/packages/databases-collections/src/stores/create-namespace.spec.tsx
@@ -22,6 +22,7 @@ describe('CreateNamespacePlugin', function () {
const instance = {
on: sandbox.stub(),
off: sandbox.stub(),
+ removeListener: sandbox.stub(),
build: { version: '999.999.999' },
topologyDescription: { type: 'Unknown' },
};
diff --git a/packages/databases-collections/src/stores/databases-store.ts b/packages/databases-collections/src/stores/databases-store.ts
index 6330ada60ba..d2160d68b52 100644
--- a/packages/databases-collections/src/stores/databases-store.ts
+++ b/packages/databases-collections/src/stores/databases-store.ts
@@ -14,7 +14,7 @@ type DatabasesTabServices = {
};
export function activatePlugin(
- _: unknown,
+ _initialProps: Record,
{ globalAppRegistry, instance }: DatabasesTabServices
) {
const store = createStore(
diff --git a/packages/hadron-app-registry/src/index.ts b/packages/hadron-app-registry/src/index.ts
index 3508aee55d6..59ffdd2ce17 100644
--- a/packages/hadron-app-registry/src/index.ts
+++ b/packages/hadron-app-registry/src/index.ts
@@ -6,12 +6,11 @@ export {
AppRegistryProvider,
useGlobalAppRegistry,
useLocalAppRegistry,
- useAppRegistryComponent,
- useAppRegistryRole,
} from './react-context';
export type {
HadronPluginComponent,
HadronPluginConfig,
+ ActivateHelpers,
} from './register-plugin';
export { registerHadronPlugin } from './register-plugin';
export default AppRegistry;
diff --git a/packages/hadron-app-registry/src/react-context.tsx b/packages/hadron-app-registry/src/react-context.tsx
index 2f8c3b410aa..ad406a8372e 100644
--- a/packages/hadron-app-registry/src/react-context.tsx
+++ b/packages/hadron-app-registry/src/react-context.tsx
@@ -6,8 +6,6 @@ import React, {
useState,
} from 'react';
import { globalAppRegistry, AppRegistry } from './app-registry';
-import createDebug from 'debug';
-const debug = createDebug('hadron-app-registry:react');
/**
* @internal exported for the mock plugin helper implementation
@@ -105,42 +103,3 @@ export function useLocalAppRegistry(): AppRegistry {
}
return appRegistry;
}
-
-/** @deprecated prefer using plugins or direct references instead */
-export function useAppRegistryComponent(
- componentName: string
-): React.JSXElementConstructor | null {
- const appRegistry = useGlobalAppRegistry();
-
- const [component] = useState(() => {
- const newComponent = appRegistry.getComponent(componentName);
- if (!newComponent) {
- debug(
- `home plugin loading component, but ${String(componentName)} is NULL`
- );
- }
- return newComponent;
- });
-
- return component ? component : null;
-}
-
-/** @deprecated prefer using plugins or direct references instead */
-export function useAppRegistryRole(roleName: string):
- | {
- component: React.JSXElementConstructor;
- name: string;
- }[]
- | null {
- const appRegistry = useGlobalAppRegistry();
-
- const [role] = useState(() => {
- const newRole = appRegistry.getRole(roleName);
- if (!newRole) {
- debug(`home plugin loading role, but ${String(roleName)} is NULL`);
- }
- return newRole;
- });
-
- return role ? role : null;
-}
diff --git a/packages/hadron-app-registry/src/register-plugin.tsx b/packages/hadron-app-registry/src/register-plugin.tsx
index 4a3c958c83b..9d715d6d951 100644
--- a/packages/hadron-app-registry/src/register-plugin.tsx
+++ b/packages/hadron-app-registry/src/register-plugin.tsx
@@ -10,6 +10,39 @@ import {
useLocalAppRegistry,
} from './react-context';
+class ActivateHelpersImpl {
+ private cleanupFns = new Set<() => void>();
+
+ on = (
+ emitter: {
+ on(evt: string, fn: (...args: any) => any): any;
+ removeListener(evt: string, fn: (...args: any) => any): any;
+ },
+ evt: string,
+ fn: (...args: any) => any
+ ) => {
+ emitter.on(evt, fn);
+ this.addCleanup(() => {
+ emitter.removeListener(evt, fn);
+ });
+ };
+
+ addCleanup = (fn: () => void) => {
+ this.cleanupFns.add(fn);
+ };
+
+ cleanup = () => {
+ for (const fn of this.cleanupFns.values()) {
+ fn();
+ }
+ };
+}
+
+export type ActivateHelpers = Pick<
+ ActivateHelpersImpl,
+ 'on' | 'addCleanup' | 'cleanup'
+>;
+
function LegacyRefluxProvider({
store,
actions,
@@ -64,7 +97,8 @@ export type HadronPluginConfig unknown>> = {
*/
activate: (
initialProps: T,
- services: Registries & Services
+ services: Registries & Services,
+ helpers: ActivateHelpers
) => {
/**
* Redux or reflux store that will be automatically passed to a
@@ -194,11 +228,15 @@ export function registerHadronPlugin<
() =>
localAppRegistry.getPlugin(registryName) ??
(() => {
- const plugin = config.activate(props, {
- globalAppRegistry,
- localAppRegistry,
- ...serviceImpls,
- });
+ const plugin = config.activate(
+ props,
+ {
+ globalAppRegistry,
+ localAppRegistry,
+ ...serviceImpls,
+ },
+ new ActivateHelpersImpl()
+ );
localAppRegistry.registerPlugin(registryName, plugin);
return plugin;
})()
diff --git a/packages/hadron-build/package.json b/packages/hadron-build/package.json
index 99b2b6326ac..30c9acacfc8 100644
--- a/packages/hadron-build/package.json
+++ b/packages/hadron-build/package.json
@@ -33,10 +33,10 @@
"debug": "^4.2.0",
"del": "^2.0.2",
"download": "^8.0.0",
- "electron": "^25.9.6",
+ "electron": "^25.9.7",
"electron-packager": "^15.5.1",
"electron-packager-plugin-non-proprietary-codecs-ffmpeg": "^1.0.2",
- "@electron/rebuild": "^3.3.1",
+ "@electron/rebuild": "^3.4.0",
"flatnest": "^1.0.0",
"fs-extra": "^8.1.0",
"getos": "^3.1.4",
diff --git a/packages/hadron-ipc/package.json b/packages/hadron-ipc/package.json
index 948edb594c2..781537a953c 100644
--- a/packages/hadron-ipc/package.json
+++ b/packages/hadron-ipc/package.json
@@ -69,7 +69,7 @@
},
"dependencies": {
"debug": "^4.3.4",
- "electron": "^25.9.6",
+ "electron": "^25.9.7",
"is-electron-renderer": "^2.0.1"
}
}
diff --git a/scripts/generate-readme-packages-overview.js b/scripts/generate-readme-packages-overview.js
index dbe1db37410..1742e9b6498 100644
--- a/scripts/generate-readme-packages-overview.js
+++ b/scripts/generate-readme-packages-overview.js
@@ -17,13 +17,11 @@ const pluginNames = [
'@mongodb-js/compass-export-to-language',
'@mongodb-js/compass-collection',
'@mongodb-js/compass-crud',
- '@mongodb-js/compass-database',
'@mongodb-js/compass-databases-collections',
'@mongodb-js/compass-field-store',
'@mongodb-js/compass-find-in-page',
'@mongodb-js/compass-home',
'@mongodb-js/compass-import-export',
- '@mongodb-js/compass-instance',
'@mongodb-js/compass-query-bar',
'@mongodb-js/compass-schema',
'@mongodb-js/compass-schema-validation',
diff --git a/scripts/package.json b/scripts/package.json
index 264ba9c51ca..bcf090ee2c7 100644
--- a/scripts/package.json
+++ b/scripts/package.json
@@ -42,7 +42,7 @@
"@mongodb-js/monorepo-tools": "^1.1.1",
"@mongodb-js/webpack-config-compass": "^1.2.5",
"commander": "^11.0.0",
- "electron": "^25.9.6",
+ "electron": "^25.9.7",
"glob": "^10.2.5",
"jsdom": "^21.1.0",
"keytar": "^7.9.0",