@@ -25,8 +25,6 @@ import { IDocumentManager, renameDialog } from '@jupyterlab/docmanager';
25
25
26
26
import { DocumentWidget } from '@jupyterlab/docregistry' ;
27
27
28
- import { IFileBrowserCommands } from '@jupyterlab/filebrowser' ;
29
-
30
28
import { IMainMenu } from '@jupyterlab/mainmenu' ;
31
29
32
30
import { ISettingRegistry } from '@jupyterlab/settingregistry' ;
@@ -42,6 +40,8 @@ import {
42
40
SidePanelPalette
43
41
} from '@jupyter-notebook/application' ;
44
42
43
+ import { CommandIDs as filebrowserCommandIDs } from '@jupyter-notebook/tree' ;
44
+
45
45
import { jupyterIcon } from '@jupyter-notebook/ui-components' ;
46
46
47
47
import { PromiseDelegate } from '@lumino/coreutils' ;
@@ -254,12 +254,11 @@ const pages: JupyterFrontEndPlugin<void> = {
254
254
id : '@jupyter-notebook/application-extension:pages' ,
255
255
autoStart : true ,
256
256
requires : [ ITranslator ] ,
257
- optional : [ ICommandPalette , IFileBrowserCommands ] ,
257
+ optional : [ ICommandPalette ] ,
258
258
activate : (
259
259
app : JupyterFrontEnd ,
260
260
translator : ITranslator ,
261
- palette : ICommandPalette | null ,
262
- fileBrowserCommands : null
261
+ palette : ICommandPalette | null
263
262
) : void => {
264
263
const trans = translator . load ( 'notebook' ) ;
265
264
const baseUrl = PageConfig . getBaseUrl ( ) ;
@@ -270,26 +269,22 @@ const pages: JupyterFrontEndPlugin<void> = {
270
269
window . open ( `${ baseUrl } lab` ) ;
271
270
}
272
271
} ) ;
272
+ const page = PageConfig . getOption ( 'notebookPage' ) ;
273
273
274
- if ( ! app . commands . isVisible ( 'filebrowser:toggle-main' ) ) {
275
- app . commands . addCommand ( CommandIDs . openTree , {
276
- label : trans . __ ( 'File Browser' ) ,
277
- execute : ( ) => {
274
+ app . commands . addCommand ( CommandIDs . openTree , {
275
+ label : trans . __ ( 'File Browser' ) ,
276
+ execute : ( ) => {
277
+ if ( page === 'tree' ) {
278
+ app . commands . execute ( filebrowserCommandIDs . activate ) ;
279
+ } else {
278
280
window . open ( `${ baseUrl } tree` ) ;
279
281
}
280
- } ) ;
281
- }
282
+ }
283
+ } ) ;
282
284
283
285
if ( palette ) {
284
286
palette . addItem ( { command : CommandIDs . openLab , category : 'View' } ) ;
285
- if ( ! app . commands . isVisible ( 'filebrowser:toggle-main' ) ) {
286
- palette . addItem ( { command : CommandIDs . openTree , category : 'View' } ) ;
287
- } else {
288
- palette . addItem ( {
289
- command : 'filebrowser:toggle-main' ,
290
- category : 'View'
291
- } ) ;
292
- }
287
+ palette . addItem ( { command : CommandIDs . openTree , category : 'View' } ) ;
293
288
}
294
289
}
295
290
} ;
0 commit comments