@@ -47,6 +47,7 @@ import { Menu, MenuBar } from '@lumino/widgets';
4747import { NotebookTreeWidget , INotebookTree } from '@jupyter-notebook/tree' ;
4848
4949import { FilesActionButtons } from './fileactions' ;
50+ import { INotebookShell } from '@jupyter-notebook/application' ;
5051
5152/**
5253 * The file browser factory.
@@ -265,6 +266,7 @@ const notebookTreeWidget: JupyterFrontEndPlugin<INotebookTree> = {
265266 ISettingRegistry ,
266267 IToolbarWidgetRegistry ,
267268 IFileBrowserFactory ,
269+ INotebookShell ,
268270 ] ,
269271 optional : [
270272 IRunningSessionManagers ,
@@ -280,13 +282,16 @@ const notebookTreeWidget: JupyterFrontEndPlugin<INotebookTree> = {
280282 settingRegistry : ISettingRegistry ,
281283 toolbarRegistry : IToolbarWidgetRegistry ,
282284 factory : IFileBrowserFactory ,
285+ notebookShell : INotebookShell ,
283286 manager : IRunningSessionManagers | null ,
284287 settingEditorTracker : ISettingEditorTracker | null ,
285288 jsonSettingEditorTracker : IJSONSettingEditorTracker | null
286289 ) : INotebookTree => {
287290 const nbTreeWidget = new NotebookTreeWidget ( ) ;
291+ nbTreeWidget . tabsMovable = false ;
288292
289293 const trans = translator . load ( 'notebook' ) ;
294+ const { tracker } = factory ;
290295
291296 browser . title . label = trans . __ ( 'Files' ) ;
292297 browser . node . setAttribute ( 'role' , 'region' ) ;
@@ -295,7 +300,6 @@ const notebookTreeWidget: JupyterFrontEndPlugin<INotebookTree> = {
295300
296301 nbTreeWidget . addWidget ( browser ) ;
297302 nbTreeWidget . tabBar . addTab ( browser . title ) ;
298- nbTreeWidget . tabsMovable = false ;
299303
300304 toolbarRegistry . addFactory (
301305 FILE_BROWSER_FACTORY ,
@@ -376,17 +380,30 @@ const notebookTreeWidget: JupyterFrontEndPlugin<INotebookTree> = {
376380 ( editorTracker ) => {
377381 if ( editorTracker ) {
378382 editorTracker . widgetAdded . connect ( ( _ , editor ) => {
379- nbTreeWidget . addWidget ( editor ) ;
383+ nbTreeWidget . adWidget ( editor ) ;
380384 nbTreeWidget . tabBar . addTab ( editor . title ) ;
381385 nbTreeWidget . currentWidget = editor ;
382386 } ) ;
383387 }
384388 }
385389 ) ;
386390
387- // workaround for https://github.com/jupyter/notebook/issues/7210
388- const { tracker } = factory ;
391+ // add drives to the notebook tree widget
392+ tracker . forEach ( ( widget ) => {
393+ // move the additional drives to the notebook tree widget
394+ if ( widget . model . driveName ) {
395+ const parent = widget . parent ;
396+ widget . parent = null ;
397+ nbTreeWidget . addWidget ( widget ) ;
398+ widget . title . label = widget . model . driveName ;
399+ nbTreeWidget . tabBar . addTab ( widget . title ) ;
400+ parent ?. dispose ( ) ;
401+ }
402+ } ) ;
389403
404+ // TODO: remove
405+ // Workaround to force the focus on the default file browser
406+ // See https://github.com/jupyterlab/jupyterlab/issues/15629 for more info
390407 const setCurrentToDefaultBrower = ( ) => {
391408 tracker [ '_pool' ] . current = browser ;
392409 } ;
0 commit comments