Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Enhancement: Prompts leaving user about pending uploads

Added an unload event listener that detects closes/ reloads/ navigates to another URL.
Added prompt that ask for confirmation to leave site on unload events if uploads pending.
Removed the event listener before destroy of component.

https://github.com/owncloud/web/issues/2590
https://github.com/owncloud/web/pull/4840
14 changes: 14 additions & 0 deletions packages/web-app-files/src/components/UploadProgress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ export default {
} else {
return 100
}
},

uploadPending() {
return this.totalUploadProgress < 100
}
},
watch: {
Expand All @@ -124,10 +128,20 @@ export default {
this.delayForScreenreader(() => this.$refs.progressbar.$el.focus())
})
})
window.addEventListener('beforeunload', this.handlerClose)
},
beforeDestroy() {
window.removeEventListener('beforeunload', this.handlerClose)
},
methods: {
$_toggleExpanded() {
this.expanded = !this.expanded
},
handlerClose(event) {
if (this.uploadPending) {
event.preventDefault()
event.returnValue = ''
}
}
}
}
Expand Down