Skip to content

Commit 552e4b7

Browse files
committed
pushed up
1 parent ccb463e commit 552e4b7

File tree

3 files changed

+75
-25
lines changed

3 files changed

+75
-25
lines changed

packages/compass-vector-embedding-visualizer/src/index.ts

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,19 @@ import { dataServiceLocator } from '@mongodb-js/compass-connections/provider';
66
import { createStore } from 'redux';
77

88
import { VectorVisualizer } from './components/vector-visualizer';
9+
import { activateVectorPlugin } from './stores/store';
910

1011
function reducer(state = {}, _action: any) {
1112
return state;
1213
}
1314

14-
export const CompassVectorPluginProvider = registerHadronPlugin<
15-
{ dataService: any; collection: any },
16-
any,
17-
any
18-
>(
15+
export const CompassVectorPluginProvider = registerHadronPlugin(
1916
{
2017
name: 'CompassVectorEmbeddingVisualizer',
21-
component: function VectorVisualizerProvider({
22-
dataService,
23-
collection,
24-
children,
25-
}) {
26-
return React.createElement(
27-
VectorVisualizer,
28-
{ dataService, collection },
29-
children
30-
);
31-
},
32-
activate: () => {
33-
const store = createStore(reducer);
34-
return {
35-
store: () => store,
36-
deactivate: () => {},
37-
};
18+
component: function VectorVisualizerProvider({ children }) {
19+
return React.createElement(React.Fragment, null, children);
3820
},
21+
activate: activateVectorPlugin,
3922
},
4023
{
4124
dataService: dataServiceLocator,
@@ -44,11 +27,18 @@ export const CompassVectorPluginProvider = registerHadronPlugin<
4427
}
4528
);
4629

30+
const VectorVisualizerWrapper = (props: {
31+
dataService: any;
32+
collection: any;
33+
}) => {
34+
return React.createElement(VectorVisualizer, props);
35+
};
36+
4737
export const CompassVectorPlugin = {
48-
name: 'VectorVisualizer',
38+
name: 'Vector Visualizer' as const,
4939
type: 'CollectionTab' as const,
5040
provider: CompassVectorPluginProvider,
51-
content: VectorVisualizer,
41+
content: VectorVisualizerWrapper,
5242
header: () => React.createElement('div', null, 'Vector Embeddings'),
5343
};
5444

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import type { Store } from 'redux';
2+
import { createStore } from 'redux';
3+
import type { DataService } from 'mongodb-data-service';
4+
import type { ConnectionInfoRef } from '@mongodb-js/compass-connections/provider';
5+
import type {
6+
Collection,
7+
MongoDBInstance,
8+
} from '@mongodb-js/compass-app-stores/provider';
9+
import type AppRegistry from 'hadron-app-registry';
10+
import type { Logger } from '@mongodb-js/compass-logging';
11+
import type { TrackFunction } from '@mongodb-js/compass-telemetry';
12+
import type { AtlasService } from '@mongodb-js/atlas-service/provider';
13+
import type { PreferencesAccess } from 'compass-preferences-model';
14+
import type { ActivateHelpers } from 'hadron-app-registry';
15+
16+
export type VectorDataServiceProps =
17+
| 'find'
18+
// Required for collection model (fetching stats)
19+
| 'collectionStats'
20+
| 'collectionInfo'
21+
| 'listCollections';
22+
export type VectorDataService = Pick<DataService, VectorDataServiceProps>;
23+
24+
export type VectorPluginServices = {
25+
dataService: VectorDataService;
26+
connectionInfoRef: ConnectionInfoRef;
27+
instance: MongoDBInstance;
28+
localAppRegistry: Pick<AppRegistry, 'on' | 'emit' | 'removeListener'>;
29+
globalAppRegistry: Pick<AppRegistry, 'on' | 'emit' | 'removeListener'>;
30+
logger: Logger;
31+
collection: Collection;
32+
track: TrackFunction;
33+
atlasService: AtlasService;
34+
preferences: PreferencesAccess;
35+
};
36+
37+
export type VectorPluginOptions = {
38+
namespace: string;
39+
serverVersion: string;
40+
isReadonly: boolean;
41+
};
42+
43+
export type VectorPluginStore = Store;
44+
45+
function reducer(state = {}, _action: any) {
46+
return state;
47+
}
48+
49+
export function activateVectorPlugin(
50+
_options: VectorPluginOptions,
51+
_services: VectorPluginServices,
52+
{ cleanup }: ActivateHelpers
53+
) {
54+
const store = createStore((state = {}) => state);
55+
return {
56+
store,
57+
deactivate: () => cleanup(),
58+
};
59+
}

packages/compass-workspaces/src/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ export type CollectionSubtab =
44
| 'Schema'
55
| 'Indexes'
66
| 'Validation'
7-
| 'GlobalWrites';
7+
| 'GlobalWrites'
8+
| 'Vector Visualizer';
89

910
export type WelcomeWorkspace = {
1011
type: 'Welcome';

0 commit comments

Comments
 (0)