@@ -15,6 +15,8 @@ import workspacesReducer, {
1515 getLocalAppRegistryForTab ,
1616 cleanupLocalAppRegistries ,
1717 connectionDisconnected ,
18+ updateDatabaseInfo ,
19+ updateCollectionInfo ,
1820} from './stores/workspaces' ;
1921import Workspaces from './components' ;
2022import { applyMiddleware , createStore } from 'redux' ;
@@ -89,12 +91,38 @@ export function activateWorkspacePlugin(
8991
9092 addCleanup ( cleanupLocalAppRegistries ) ;
9193
92- const setupInstanceListeners = ( instance : MongoDBInstance ) => {
94+ const setupInstanceListeners = (
95+ connectionId : string ,
96+ instance : MongoDBInstance
97+ ) => {
9398 on ( instance , 'change:collections._id' , ( collection : Collection ) => {
9499 const { _id : from } = collection . previousAttributes ( ) ;
95100 store . dispatch ( collectionRenamed ( from , collection . ns ) ) ;
96101 } ) ;
97102
103+ on ( instance , 'change:databases.is_non_existent' , ( database : Database ) => {
104+ const namespaceId = `${ connectionId } .${ database . _id } ` ;
105+ const databaseInfo = {
106+ isNonExistent : database . is_non_existent ,
107+ } ;
108+ store . dispatch ( updateDatabaseInfo ( namespaceId , databaseInfo ) ) ;
109+ } ) ;
110+
111+ on (
112+ instance ,
113+ 'change:collections.is_non_existent' ,
114+ ( collection : Collection ) => {
115+ const namespaceId = `${ connectionId } .${ collection . _id } ` ;
116+ const collectionInfo = {
117+ isTimeSeries : collection . isTimeSeries ,
118+ isReadonly : collection . readonly ?? collection . isView ,
119+ sourceName : collection . sourceName ,
120+ isNonExistent : collection . is_non_existent ,
121+ } ;
122+ store . dispatch ( updateCollectionInfo ( namespaceId , collectionInfo ) ) ;
123+ }
124+ ) ;
125+
98126 on ( instance , 'remove:collections' , ( collection : Collection ) => {
99127 store . dispatch ( collectionRemoved ( collection . ns ) ) ;
100128 } ) ;
@@ -104,9 +132,8 @@ export function activateWorkspacePlugin(
104132 } ) ;
105133 } ;
106134
107- const existingInstances = instancesManager . listMongoDBInstances ( ) ;
108- for ( const instance of existingInstances . values ( ) ) {
109- setupInstanceListeners ( instance ) ;
135+ for ( const [ connId , instance ] of instancesManager . listMongoDBInstances ( ) ) {
136+ setupInstanceListeners ( connId , instance ) ;
110137 }
111138
112139 on (
@@ -116,7 +143,7 @@ export function activateWorkspacePlugin(
116143 connectionInfoId : ConnectionInfo [ 'id' ] ,
117144 instance : MongoDBInstance
118145 ) {
119- setupInstanceListeners ( instance ) ;
146+ setupInstanceListeners ( connectionInfoId , instance ) ;
120147 }
121148 ) ;
122149
0 commit comments