5
5
6
6
import {
7
7
InputDialog ,
8
+ Notification ,
9
+ showDialog ,
8
10
Dialog
9
- Notification
10
11
} from '@jupyterlab/apputils' ;
11
12
12
13
import {
@@ -18,13 +19,11 @@ import { PromiseDelegate, ReadonlyJSONValue } from '@lumino/coreutils';
18
19
// Icons
19
20
import {
20
21
fileUploadIcon ,
22
+ redoIcon
21
23
} from '@jupyterlab/ui-components' ;
22
24
import { requestAPI } from './handler' ;
23
25
import { showErrorMessage } from '@jupyterlab/apputils' ;
24
26
25
- /**
26
- * Uploads metadata and files to data repository
27
- */
28
27
29
28
30
29
function uploadDataset ( directory : string , repository : string ) {
@@ -151,6 +150,7 @@ export const uploadDatasetPlugin: JupyterFrontEndPlugin<void> = {
151
150
const fileBrowserModel = fileBrowser . model ;
152
151
153
152
153
+ // ** Upload a new dataset to a data repository **
154
154
const uploadDatasetCommand = "uploadDataset"
155
155
app . commands . addCommand ( uploadDatasetCommand , {
156
156
label : 'Upload Dataset' ,
@@ -193,35 +193,28 @@ export const uploadDatasetPlugin: JupyterFrontEndPlugin<void> = {
193
193
}
194
194
} ) ;
195
195
196
-
196
+ // ** Push changes made to a local dataset to a data repository **
197
197
const pushCommand = "pushDataset"
198
198
app . commands . addCommand ( pushCommand , {
199
199
label : 'Push' ,
200
200
isEnabled : ( ) => true ,
201
201
isVisible : ( ) => true , // activate only when current directory contains a manifest.yalm
202
- icon : fileUploadIcon ,
202
+ icon : redoIcon ,
203
203
execute : async ( ) => {
204
204
205
- // return relative path w.r.t. jupyterlab root path.
206
- // root-path = empty string.
207
-
208
- // Choose a better dialog for this
209
- let confirmAction = await InputDialog . getBoolean ( {
210
- title : 'Confirm the operation' ,
211
- label : `Yes, push changes to the data dataset` ,
212
- okLabel : 'Push' ,
213
- } ) ;
214
-
215
-
205
+ let confirmAction = await showDialog ( {
206
+ title : 'Push changes' , // Can be text or a react element
207
+ body : 'This will update the data repository using changes made here.' ,
208
+ host : document . body , // Parent element for rendering the dialog
209
+ buttons : [ Dialog . cancelButton ( ) , Dialog . okButton ( { label : 'Push' } ) ] ,
210
+ } )
216
211
217
212
if ( confirmAction . button . accept ) {
218
- console . log ( 'pushing changes to data repository' ) ;
219
- pushDataset ( fileBrowserModel . path )
220
- } else {
213
+ await pushDataset ( fileBrowserModel . path )
214
+ } else {
221
215
console . log ( 'rejected' ) ;
222
216
return
223
217
} ;
224
-
225
218
}
226
219
} ) ;
227
220
0 commit comments