File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
packages/compass-app-stores/src Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 11import {
22 dataServiceLocator ,
33 useConnectionInfo ,
4+ useConnectionIds ,
45} from '@mongodb-js/compass-connections/provider' ;
56import {
67 createServiceLocator ,
@@ -93,6 +94,32 @@ export const mongoDBInstanceLocator = createServiceLocator(
9394 'mongoDBInstanceLocator'
9495) ;
9596
97+ /**
98+ * Hook to check if there are any connected non-genuine MongoDB connections.
99+ * @return true if any connected connection is to a non-genuine MongoDB server.
100+ */
101+ export function useHasNonGenuineConnections ( ) : boolean {
102+ const instancesManager = mongoDBInstancesManagerLocator ( ) ;
103+
104+ const activeNonGenuineConnectionIds = useConnectionIds ( ( conn ) => {
105+ if ( conn . status !== 'connected' ) {
106+ return false ;
107+ }
108+
109+ try {
110+ const instance = instancesManager . getMongoDBInstanceForConnection (
111+ conn . info . id
112+ ) ;
113+ return instance . genuineMongoDB . isGenuine === false ;
114+ } catch {
115+ // Instance not found or not ready yet
116+ return false ;
117+ }
118+ } ) ;
119+
120+ return activeNonGenuineConnectionIds . length > 0 ;
121+ }
122+
96123const NamespaceModelContext = React . createContext < Database | Collection | null > (
97124 null
98125) ;
You can’t perform that action at this time.
0 commit comments