Skip to content

Commit 9b13b10

Browse files
committed
implement better dialog for push command
1 parent 5c292db commit 9b13b10

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

jupyter_fairly/src/upload.ts

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import {
55

66
import {
77
InputDialog,
8+
Notification,
9+
showDialog,
810
Dialog
9-
Notification
1011
} from '@jupyterlab/apputils';
1112

1213
import {
@@ -18,13 +19,11 @@ import { PromiseDelegate, ReadonlyJSONValue } from '@lumino/coreutils';
1819
// Icons
1920
import {
2021
fileUploadIcon,
22+
redoIcon
2123
} from '@jupyterlab/ui-components';
2224
import { requestAPI } from './handler';
2325
import { showErrorMessage } from '@jupyterlab/apputils';
2426

25-
/**
26-
* Uploads metadata and files to data repository
27-
*/
2827

2928

3029
function uploadDataset(directory: string, repository: string) {
@@ -151,6 +150,7 @@ export const uploadDatasetPlugin: JupyterFrontEndPlugin<void> = {
151150
const fileBrowserModel = fileBrowser.model;
152151

153152

153+
// ** Upload a new dataset to a data repository **
154154
const uploadDatasetCommand = "uploadDataset"
155155
app.commands.addCommand(uploadDatasetCommand, {
156156
label: 'Upload Dataset',
@@ -193,35 +193,28 @@ export const uploadDatasetPlugin: JupyterFrontEndPlugin<void> = {
193193
}
194194
});
195195

196-
196+
// ** Push changes made to a local dataset to a data repository **
197197
const pushCommand = "pushDataset"
198198
app.commands.addCommand(pushCommand, {
199199
label: 'Push',
200200
isEnabled: () => true,
201201
isVisible: () => true, // activate only when current directory contains a manifest.yalm
202-
icon: fileUploadIcon,
202+
icon: redoIcon,
203203
execute: async() => {
204204

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+
})
216211

217212
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 {
221215
console.log('rejected');
222216
return
223217
};
224-
225218
}
226219
});
227220

0 commit comments

Comments
 (0)