@@ -4,7 +4,11 @@ import {
4
4
JupyterFrontEndPlugin
5
5
} from '@jupyterlab/application' ;
6
6
import { IChangedArgs , ISettingRegistry } from '@jupyterlab/coreutils' ;
7
- import { FileBrowserModel , IFileBrowserFactory } from '@jupyterlab/filebrowser' ;
7
+ import {
8
+ FileBrowser ,
9
+ FileBrowserModel ,
10
+ IFileBrowserFactory
11
+ } from '@jupyterlab/filebrowser' ;
8
12
import { IMainMenu } from '@jupyterlab/mainmenu' ;
9
13
import { IRenderMimeRegistry } from '@jupyterlab/rendermime' ;
10
14
import { defaultIconRegistry } from '@jupyterlab/ui-components' ;
@@ -60,9 +64,8 @@ function activate(
60
64
restorer : ILayoutRestorer ,
61
65
factory : IFileBrowserFactory ,
62
66
renderMime : IRenderMimeRegistry ,
63
- settings : ISettingRegistry
67
+ settingRegistry : ISettingRegistry
64
68
) : IGitExtension {
65
- const { commands } = app ;
66
69
const key = plugin . id ;
67
70
68
71
registerGitIcons ( defaultIconRegistry ) ;
@@ -81,7 +84,7 @@ function activate(
81
84
} ) ;
82
85
83
86
/* Create the widgets */
84
- settings
87
+ settingRegistry
85
88
. load ( key )
86
89
. then ( settings => {
87
90
// Create the Git widget sidebar
@@ -97,6 +100,12 @@ function activate(
97
100
// Rank has been chosen somewhat arbitrarily to give priority to the running
98
101
// sessions widget in the sidebar.
99
102
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
+ ) ;
100
109
} )
101
110
. catch ( reason => {
102
111
console . error (
@@ -105,29 +114,42 @@ function activate(
105
114
} ) ;
106
115
107
116
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 ) ;
108
131
109
- /* Add commands and menu items */
110
- const category = 'Git' ;
111
- addCommands ( app , gitExtension , factory . defaultBrowser ) ;
112
132
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' ;
116
134
[ CommandIDs . gitUI , CommandIDs . gitTerminalCommand , CommandIDs . gitInit ] . forEach (
117
135
command => {
118
136
menu . addItem ( { command } ) ;
119
137
}
120
138
) ;
121
139
140
+ let tutorial = new Menu ( { commands } ) ;
141
+ tutorial . title . label = ' Tutorial ' ;
122
142
RESOURCES . map ( args => {
123
143
tutorial . addItem ( {
124
144
args,
125
145
command : CommandIDs . gitOpenUrl
126
146
} ) ;
127
147
} ) ;
128
-
129
148
menu . addItem ( { type : 'submenu' , submenu : tutorial } ) ;
130
- mainMenu . addMenu ( menu , { rank : 60 } ) ;
131
149
132
- return gitExtension ;
150
+ menu . addItem ( { type : 'separator' } ) ;
151
+
152
+ menu . addItem ( { command : CommandIDs . gitToggleSimpleStaging } ) ;
153
+
154
+ return menu ;
133
155
}
0 commit comments