Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(data-service, home): create a service provider / locator for data service COMPASS-7410 #5085

Merged
merged 4 commits into from
Nov 9, 2023

Conversation

gribnoysup
Copy link
Collaborator

@gribnoysup gribnoysup commented Nov 9, 2023

This patch introduces a service provider for data service, plugins using data service provider need to be in the connected application tree to function and can access it directly through activate plugin method.

As we already have a few plugins that were updated to the new interface that would benefit from using this service locator, I'm refactoring them to use new mechanism

  • import
  • export

To avoid blocking work, I'll follow up with the following plugins in a separate PR:

  • create view
  • create database
  • drop database
  • create collection
  • drop collection

@gribnoysup gribnoysup added the wip label Nov 9, 2023
@@ -20,28 +20,18 @@ const getComponent = (name: string) => {
};

describe('WorkspaceContent [Component]', function () {
let testAppRegistry: AppRegistry;
beforeEach(function () {
testAppRegistry = new AppRegistry();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@addaleax for now swithcing it back to global app registry in the useAppRegistryComponent and tests, the usage of those will be removed anyway pretty soon as the plugins we mock here are the next in line to be refactored.

Now that we have an app registry scope for a connected part application, we can't rely on global === local in this part of the app to ease testing

if (dataService === getState().dataService.dataService) {
dispatch(
globalAppRegistryEmit(
'export-finished',
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This event was used in tests but nowhere else and tests could just wait for the dispatched action instead, so I removed it

);
}

export type RootExportState = ReturnType<
ReturnType<typeof configureStore>['getState']
>;

export type ExportPluginServices = {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something for later, but I'm starting to think we should probably have some helper types to get those types easier from the returned plugin object maybe? Similar to React.ComponentProps or something like that

@gribnoysup gribnoysup force-pushed the compass-7410-data-service-provider branch from 7928456 to b5b3c7a Compare November 9, 2023 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants