Skip to content

Commit

Permalink
confirmation dialog on upload/download/remove files
Browse files Browse the repository at this point in the history
  • Loading branch information
ubidefeo committed Jan 12, 2024
1 parent e0650ce commit 6572ffc
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion ui/arduino2/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ async function store(state, emitter) {

for (let i in state.selectedFiles) {
const file = state.selectedFiles[i]
confirmAction = confirmDialog(`You are about to delete ${file.fileName} from your ${file.source}.\nAre you sure you want to proceed?`, 'Cancel', 'Yes')
if (!confirmAction) {
continue
}
if (file.source === 'board') {
await serial.removeFile(
serial.getFullPath(
Expand All @@ -388,7 +392,7 @@ async function store(state, emitter) {
}

emitter.emit('refresh-files')

state.selectedFiles = []
state.isRemoving = false
emitter.emit('render')
})
Expand Down Expand Up @@ -524,12 +528,21 @@ async function store(state, emitter) {
})

// DOWNLOAD AND UPLOAD FILES
function confirmDialog(message, cancelText, confirmText) {
confirmation = confirm(message, cancelText, confirmText);
return confirmation;
}

emitter.on('upload-files', async () => {
state.isTransferring = true
emitter.emit('render')

for (let i in state.selectedFiles) {
const file = state.selectedFiles[i]
confirmAction = confirmDialog(`Copying ${file.fileName} might overwrite an existing file at destination.\nAre you sure you want to proceed?`, 'Cancel', 'Yes')
if (!confirmAction) {
continue
}
await serial.uploadFile(
disk.getFullPath(
state.diskNavigationRoot,
Expand Down Expand Up @@ -559,6 +572,11 @@ async function store(state, emitter) {

for (let i in state.selectedFiles) {
const file = state.selectedFiles[i]
confirmAction = confirmDialog(`Copying ${file.fileName} might overwrite an existing file, are you sure you want to proceed?`, 'Cancel', 'Yes')
if (!confirmAction) {
continue
}

await serial.downloadFile(
serial.getFullPath(
'/',
Expand Down

0 comments on commit 6572ffc

Please sign in to comment.