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(compass-saved-aggregation-queries): refactor of "My Queries" to support multiple connections COMPASS-7915 #5794
base: main
Are you sure you want to change the base?
Conversation
9006f41
to
dca37ed
Compare
dca37ed
to
4d29557
Compare
I don't see the activeConnections being initialized when 'My Queries' is open - or is the store initialized when the plugin is included and not when 'My Queries' is open? |
In general I wonder if we could have a central place to fetch the active connections, instead of the plugins maintaining their own list. We have the |
Also regarding the way we deal with single connection -> perhaps all these three questions are leading to the same -> could we use the same approach as in useActiveConnections? Get all connections from repository and use ConnectionsManager to filter for the connected ones? If I'm not mistaken, this should work for the initial state (when 'My Queries' is open), single connection.. and perhaps there is a way to make this reusable. |
The active connections are getting initialised currently when we create the store, by listening to ConnectionsManager's events. Regarding having some central place - Yea I think what we're looking for will be provided by compass-connections once we convert that to plugin and expose a service interface to provide the internals like activeConnections. That is surely the end goal. |
4d29557
to
0af9f54
Compare
|
93a8698
to
5c600cb
Compare
… and Workspace and instead rely on getting the activeConnection from useActiveConnections
5c600cb
to
ea5519e
Compare
Please check the updated description in the PR for the most recent update on this. |
|
||
const dataService = | ||
connectionsManager.getDataServiceForConnection(connection); | ||
if (!dataService) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I asked in another PR and I feel like it's worth asking again: do we ever expect in the code not to get data service back and handle it by not throwing an error when using manager in actions? Should this logic be part of the method if we always throw if data service is not returned? Same for instance model
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea I am literally doing this if not throw
everywhere, will definitely make this part of the getDataService interface. Thank you 👍
if (!multiConnectionsEnabled) { | ||
// In single connections mode, we only expect one connections to be here | ||
// in the list of active connections. | ||
const [activeConnection] = activeConnections; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsure why we need the switch on the feature flag here, this should be the same logic for both multi and single connection mode (with other auto-resolving logic):
if (!multiConnectionsEnabled) { | |
// In single connections mode, we only expect one connections to be here | |
// in the list of active connections. | |
const [activeConnection] = activeConnections; | |
if (activeConnections.length === 1) { | |
// If there is only one connection, try to resolve collection name to open the saved item without prompting for input | |
const activeConnection = activeConnections[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea sorry for misdirection here - after our conversation I totally forgot to update / close this PR and left the work for the new modals and this branching in my other branch. I probably will close this one and will just raise one PR having both the changes.
if (error) { | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's kind of an unexpected pattern, if you really want to use the action to get those values, you can throw right in the get method, no need to return an error to re-throw it, but also see my other comment: every place where we get those, we throw if value is not available, I feel like we should just make the getter method account for that so that we don't need to check everywhere
Description
This PR makes "My Queries" plugin work now with ConnectionsManager and InstancesManager instead of DataService and MongoDBInstance. Additionally, now, we don't rely anymore on
singleConnectionConnectionInfo
that we introduced at some point to render "My Queries" plugin. Instead, we have taken a more optimistic route which is to useuseActiveConnections
hook to get a hold of current active connections and work with the very first connection that we find, to render "CompassSidebar", "CompassShell" and interaction in "My Queries" plugin for single connection mode.Checklist
Motivation and Context
Open Questions
Dependents
Types of changes