Skip to content

Commit 5229088

Browse files
committed
Added progress dialog on uploads
1 parent d93a93a commit 5229088

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

index.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,19 @@ const vfsActionFactory = (core, proc, win, dialog, state) => {
283283
return [];
284284
};
285285

286-
const writeRelative = f => vfs.writefile({
287-
path: pathJoin(state.currentPath.path, f.name)
288-
}, f, {pid: proc.pid});
286+
const writeRelative = f => {
287+
const d = dialog('progress', f);
288+
289+
return vfs.writefile({
290+
path: pathJoin(state.currentPath.path, f.name)
291+
}, f, {
292+
pid: proc.pid,
293+
onProgress: (ev, p) => d.setProgress(p)
294+
}).then((result) => {
295+
d.destroy();
296+
return result;
297+
});
298+
};
289299

290300
const uploadBrowserFiles = (files) => {
291301
Promise.all(files.map(writeRelative))
@@ -436,6 +446,11 @@ const dialogFactory = (core, proc, win) => {
436446
action(() => vfs.unlink(file, {pid: proc.pid}), true, __('MSG_DELETE_ERROR'));
437447
}));
438448

449+
const progressDialog = (file) => dialog('progress', {
450+
message: __('DIALOG_PROGRESS_MESSAGE', file.name),
451+
buttons: []
452+
}, () => {});
453+
439454
const errorDialog = (error, message) => dialog('alert', {
440455
type: 'error',
441456
error,
@@ -446,12 +461,13 @@ const dialogFactory = (core, proc, win) => {
446461
mkdir: mkdirDialog,
447462
rename: renameDialog,
448463
delete: deleteDialog,
464+
progress: progressDialog,
449465
error: errorDialog
450466
};
451467

452468
return (name, ...args) => {
453469
if (dialogs[name]) {
454-
dialogs[name](...args);
470+
return dialogs[name](...args);
455471
} else {
456472
throw new Error(`Invalid dialog: ${name}`);
457473
}

locales.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const en_EN = {
1010
DIALOG_MKDIR_PLACEHOLDER: 'New directory',
1111
DIALOG_RENAME_MESSAGE: 'Rename {0} ?',
1212
DIALOG_DELETE_MESSAGE: 'Delete {0} ?',
13+
DIALOG_PROGRESS_MESSAGE: 'Uploading {0}...',
1314
MSG_ERROR: 'An error occurred',
1415
MSG_UPLOAD_ERROR: 'Failed to upload file(s)',
1516
MSG_READDIR_ERROR: 'An error occurred while reading directory: {0}',

0 commit comments

Comments
 (0)