@@ -4,7 +4,11 @@ import {
44 JupyterFrontEndPlugin
55} from '@jupyterlab/application' ;
66import { IChangedArgs , ISettingRegistry } from '@jupyterlab/coreutils' ;
7- import { FileBrowserModel , IFileBrowserFactory } from '@jupyterlab/filebrowser' ;
7+ import {
8+ FileBrowser ,
9+ FileBrowserModel ,
10+ IFileBrowserFactory
11+ } from '@jupyterlab/filebrowser' ;
812import { IMainMenu } from '@jupyterlab/mainmenu' ;
913import { IRenderMimeRegistry } from '@jupyterlab/rendermime' ;
1014import { defaultIconRegistry } from '@jupyterlab/ui-components' ;
@@ -60,9 +64,8 @@ function activate(
6064 restorer : ILayoutRestorer ,
6165 factory : IFileBrowserFactory ,
6266 renderMime : IRenderMimeRegistry ,
63- settings : ISettingRegistry
67+ settingRegistry : ISettingRegistry
6468) : IGitExtension {
65- const { commands } = app ;
6669 const key = plugin . id ;
6770
6871 registerGitIcons ( defaultIconRegistry ) ;
@@ -81,7 +84,7 @@ function activate(
8184 } ) ;
8285
8386 /* Create the widgets */
84- settings
87+ settingRegistry
8588 . load ( key )
8689 . then ( settings => {
8790 // Create the Git widget sidebar
@@ -97,6 +100,12 @@ function activate(
97100 // Rank has been chosen somewhat arbitrarily to give priority to the running
98101 // sessions widget in the sidebar.
99102 app . shell . add ( gitPlugin , 'left' , { rank : 200 } ) ;
103+
104+ // add a menu for the plugin
105+ mainMenu . addMenu (
106+ createGitMenu ( app , gitExtension , factory . defaultBrowser , settings ) ,
107+ { rank : 60 }
108+ ) ;
100109 } )
101110 . catch ( reason => {
102111 console . error (
@@ -105,29 +114,42 @@ function activate(
105114 } ) ;
106115
107116 addCloneButton ( gitExtension , factory . defaultBrowser ) ;
117+ return gitExtension ;
118+ }
119+
120+ /**
121+ * Add commands and menu items
122+ */
123+ function createGitMenu (
124+ app : JupyterFrontEnd ,
125+ gitExtension : IGitExtension ,
126+ fileBrowser : FileBrowser ,
127+ settings : ISettingRegistry . ISettings
128+ ) : Menu {
129+ const { commands } = app ;
130+ addCommands ( app , gitExtension , fileBrowser , settings ) ;
108131
109- /* Add commands and menu items */
110- const category = 'Git' ;
111- addCommands ( app , gitExtension , factory . defaultBrowser ) ;
112132 let menu = new Menu ( { commands } ) ;
113- let tutorial = new Menu ( { commands } ) ;
114- tutorial . title . label = ' Tutorial ' ;
115- menu . title . label = category ;
133+ menu . title . label = 'Git' ;
116134 [ CommandIDs . gitUI , CommandIDs . gitTerminalCommand , CommandIDs . gitInit ] . forEach (
117135 command => {
118136 menu . addItem ( { command } ) ;
119137 }
120138 ) ;
121139
140+ let tutorial = new Menu ( { commands } ) ;
141+ tutorial . title . label = ' Tutorial ' ;
122142 RESOURCES . map ( args => {
123143 tutorial . addItem ( {
124144 args,
125145 command : CommandIDs . gitOpenUrl
126146 } ) ;
127147 } ) ;
128-
129148 menu . addItem ( { type : 'submenu' , submenu : tutorial } ) ;
130- mainMenu . addMenu ( menu , { rank : 60 } ) ;
131149
132- return gitExtension ;
150+ menu . addItem ( { type : 'separator' } ) ;
151+
152+ menu . addItem ( { command : CommandIDs . gitToggleSimpleStaging } ) ;
153+
154+ return menu ;
133155}
0 commit comments