@@ -25,8 +25,6 @@ import { IDocumentManager, renameDialog } from '@jupyterlab/docmanager';
2525
2626import { DocumentWidget } from '@jupyterlab/docregistry' ;
2727
28- import { IFileBrowserCommands } from '@jupyterlab/filebrowser' ;
29-
3028import { IMainMenu } from '@jupyterlab/mainmenu' ;
3129
3230import { ISettingRegistry } from '@jupyterlab/settingregistry' ;
@@ -42,6 +40,8 @@ import {
4240 SidePanelPalette
4341} from '@jupyter-notebook/application' ;
4442
43+ import { CommandIDs as filebrowserCommandIDs } from '@jupyter-notebook/tree' ;
44+
4545import { jupyterIcon } from '@jupyter-notebook/ui-components' ;
4646
4747import { PromiseDelegate } from '@lumino/coreutils' ;
@@ -67,7 +67,7 @@ const STRIP_IPYNB = /\.ipynb$/;
6767/**
6868 * The command IDs used by the application plugin.
6969 */
70- namespace CommandIDs {
70+ export namespace CommandIDs {
7171 /**
7272 * Toggle Top Bar visibility
7373 */
@@ -254,12 +254,11 @@ const pages: JupyterFrontEndPlugin<void> = {
254254 id : '@jupyter-notebook/application-extension:pages' ,
255255 autoStart : true ,
256256 requires : [ ITranslator ] ,
257- optional : [ ICommandPalette , IFileBrowserCommands ] ,
257+ optional : [ ICommandPalette ] ,
258258 activate : (
259259 app : JupyterFrontEnd ,
260260 translator : ITranslator ,
261- palette : ICommandPalette | null ,
262- fileBrowserCommands : null
261+ palette : ICommandPalette | null
263262 ) : void => {
264263 const trans = translator . load ( 'notebook' ) ;
265264 const baseUrl = PageConfig . getBaseUrl ( ) ;
@@ -270,26 +269,22 @@ const pages: JupyterFrontEndPlugin<void> = {
270269 window . open ( `${ baseUrl } lab` ) ;
271270 }
272271 } ) ;
272+ const page = PageConfig . getOption ( 'notebookPage' ) ;
273273
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 {
278280 window . open ( `${ baseUrl } tree` ) ;
279281 }
280- } ) ;
281- }
282+ }
283+ } ) ;
282284
283285 if ( palette ) {
284286 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' } ) ;
293288 }
294289 }
295290} ;
0 commit comments