summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Zallmann <tzallmann@gitlab.com>2017-09-26 14:58:14 +0200
committerTim Zallmann <tzallmann@gitlab.com>2017-10-04 17:27:56 +0200
commit9196a356ae675ab97e7ed49e48c1e59105ad2a81 (patch)
treedaabd5521bf28be3b31a2514cfb2e875cd6190fd
parente58c8413d47080498f4327cbcb6e08edae44aa9e (diff)
downloadgitlab-ce-9196a356ae675ab97e7ed49e48c1e59105ad2a81.tar.gz
Polished Back Button for files that are not in the tree anymore
-rw-r--r--app/assets/javascripts/repo/components/repo_sidebar.vue11
1 files changed, 10 insertions, 1 deletions
diff --git a/app/assets/javascripts/repo/components/repo_sidebar.vue b/app/assets/javascripts/repo/components/repo_sidebar.vue
index 535206bafe3..702056a7e3a 100644
--- a/app/assets/javascripts/repo/components/repo_sidebar.vue
+++ b/app/assets/javascripts/repo/components/repo_sidebar.vue
@@ -26,7 +26,11 @@ export default {
methods: {
addPopEventListener() {
window.addEventListener('popstate', (event) => {
- const selectedFile = this.files.find(file => location.href.indexOf(file.url) > -1);
+ let selectedFile = this.files.find(file => {return location.pathname.indexOf(file.url) > -1});
+ if (!selectedFile) {
+ // Maybe it is not in the current tree but in the opened tabs
+ selectedFile = Store.openedFiles.find(file => {return location.pathname.indexOf(file.url) > -1});
+ }
if (selectedFile) {
if (selectedFile.url !== this.activeFile.url) {
this.fileClicked(selectedFile);
@@ -46,6 +50,11 @@ export default {
}
}
}
+ } else {
+ // Not opened at all lets open new tab
+ this.fileClicked({
+ url: location.href,
+ });
}
});
},