File tree Expand file tree Collapse file tree 2 files changed +31
-3
lines changed
packages/compass-workspaces/src/stores Expand file tree Collapse file tree 2 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -142,6 +142,21 @@ describe('tabs behavior', function () {
142142 expect ( state ) . to . have . property ( 'activeTabId' , state . tabs [ 1 ] . id ) ;
143143 } ) ;
144144
145+ it ( 'when the connection differs from the active tab, it should open a workspace in new tab' , function ( ) {
146+ const store = configureStore ( ) ;
147+ store . dispatch (
148+ openWorkspace ( { type : 'Databases' , connectionId : 'connectionA' } )
149+ ) ;
150+ store . dispatch (
151+ openWorkspace ( { type : 'Databases' , connectionId : 'connectionB' } )
152+ ) ;
153+ const state = store . getState ( ) ;
154+ expect ( state ) . to . have . property ( 'tabs' ) . have . lengthOf ( 2 ) ;
155+ expect ( state ) . to . have . nested . property ( 'tabs[0].type' , 'Databases' ) ;
156+ expect ( state ) . to . have . nested . property ( 'tabs[1].type' , 'Databases' ) ;
157+ expect ( state ) . to . have . property ( 'activeTabId' , state . tabs [ 1 ] . id ) ;
158+ } ) ;
159+
145160 it ( 'should select already opened tab when trying to open a new one with the same attributes' , function ( ) {
146161 const store = configureStore ( ) ;
147162 openTabs ( store ) ;
Original file line number Diff line number Diff line change @@ -318,10 +318,23 @@ const reducer: Reducer<WorkspacesState> = (
318318 : state ;
319319 }
320320
321- // ... otherwise check if we can replace the current tab based on its
322- // replace handlers and force new tab opening if we can't
323321 if ( currentActiveTab ) {
324- forceNewTab = canReplaceTab ( currentActiveTab ) === false ;
322+ // if both the new workspace and the existing one are connection scoped,
323+ // make sure we do not replace tabs between different connections
324+ if (
325+ action . workspace . type !== 'Welcome' &&
326+ action . workspace . type !== 'My Queries' &&
327+ currentActiveTab . type !== 'Welcome' &&
328+ currentActiveTab . type !== 'My Queries'
329+ ) {
330+ forceNewTab =
331+ action . workspace . connectionId !== currentActiveTab . connectionId ;
332+ }
333+
334+ // ... check if we can replace the current tab based on its
335+ // replace handlers and force new tab opening if we can't
336+ if ( ! forceNewTab )
337+ forceNewTab = canReplaceTab ( currentActiveTab ) === false ;
325338 }
326339 }
327340
You can’t perform that action at this time.
0 commit comments