diff options
Diffstat (limited to 'app/assets/javascripts/ide/components/ide.vue')
-rw-r--r-- | app/assets/javascripts/ide/components/ide.vue | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/app/assets/javascripts/ide/components/ide.vue b/app/assets/javascripts/ide/components/ide.vue index d589f56dd7c..838debf1ceb 100644 --- a/app/assets/javascripts/ide/components/ide.vue +++ b/app/assets/javascripts/ide/components/ide.vue @@ -47,6 +47,7 @@ export default { data() { return { loadDeferred: false, + skipBeforeUnload: false, }; }, computed: { @@ -78,9 +79,14 @@ export default { mounted() { window.onbeforeunload = (e) => this.onBeforeUnload(e); + eventHub.$on('skip-beforeunload', this.handleSkipBeforeUnload); + if (this.themeName) document.querySelector('.navbar-gitlab').classList.add(`theme-${this.themeName}`); }, + destroyed() { + eventHub.$off('skip-beforeunload', this.handleSkipBeforeUnload); + }, beforeCreate() { performanceMarkAndMeasure({ mark: WEBIDE_MARK_APP_START, @@ -94,6 +100,11 @@ export default { methods: { ...mapActions(['toggleFileFinder']), onBeforeUnload(e = {}) { + if (this.skipBeforeUnload) { + this.skipBeforeUnload = false; + return undefined; + } + const returnValue = __('Are you sure you want to lose unsaved changes?'); if (!this.someUncommittedChanges) return undefined; @@ -103,6 +114,9 @@ export default { }); return returnValue; }, + handleSkipBeforeUnload() { + this.skipBeforeUnload = true; + }, openFile(file) { this.$router.push(this.getUrlForPath(file.path)); }, |