summaryrefslogtreecommitdiff
path: root/app/assets/javascripts
diff options
context:
space:
mode:
authorEric Eastwood <contact@ericeastwood.com>2017-08-10 13:50:59 -0500
committerEric Eastwood <contact@ericeastwood.com>2017-08-14 11:03:36 -0500
commitf1e1113bf4d107c0ecf3f989f6110b00a83cef2d (patch)
treeadd40de38bdd1b810e1dc4e4cdb0fdb6f2a1781b /app/assets/javascripts
parent06c330954e030e30e9e8284110907c53b206e447 (diff)
downloadgitlab-ce-f1e1113bf4d107c0ecf3f989f6110b00a83cef2d.tar.gz
Split out linkClicked and add tests
Fix https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/12198#note_37143174
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/repo/components/repo_sidebar.vue45
1 files changed, 21 insertions, 24 deletions
diff --git a/app/assets/javascripts/repo/components/repo_sidebar.vue b/app/assets/javascripts/repo/components/repo_sidebar.vue
index d6d832efc49..ccc84c4ed7c 100644
--- a/app/assets/javascripts/repo/components/repo_sidebar.vue
+++ b/app/assets/javascripts/repo/components/repo_sidebar.vue
@@ -33,32 +33,29 @@ const RepoSidebar = {
});
},
- linkClicked(clickedFile) {
- let url = '';
+ fileClicked(clickedFile) {
let file = clickedFile;
- if (typeof file === 'object') {
- file.loading = true;
- if (file.type === 'tree' && file.opened) {
- file = Store.removeChildFilesOfTree(file);
+
+ file.loading = true;
+ if (file.type === 'tree' && file.opened) {
+ file = Store.removeChildFilesOfTree(file);
+ file.loading = false;
+ } else {
+ Service.url = file.url;
+ // I need to refactor this to do the `then` here.
+ // Not a callback. For now this is good enough.
+ // it works.
+ Helper.getContent(file, () => {
file.loading = false;
- } else {
- url = file.url;
- Service.url = url;
- // I need to refactor this to do the `then` here.
- // Not a callback. For now this is good enough.
- // it works.
- Helper.getContent(file, () => {
- file.loading = false;
- Helper.scrollTabsRight();
- });
- }
- } else if (typeof file === 'string') {
- // go back
- url = file;
- Service.url = url;
- Helper.getContent(null, () => Helper.scrollTabsRight());
+ Helper.scrollTabsRight();
+ });
}
},
+
+ goToPreviousDirectoryClicked(prevURL) {
+ Service.url = prevURL;
+ Helper.getContent(null, () => Helper.scrollTabsRight());
+ },
},
};
@@ -82,7 +79,7 @@ export default RepoSidebar;
<repo-previous-directory
v-if="isRoot"
:prev-url="prevURL"
- @linkclicked="linkClicked(prevURL)"/>
+ @linkclicked="goToPreviousDirectoryClicked(prevURL)"/>
<repo-loading-file
v-for="n in 5"
:key="n"
@@ -94,7 +91,7 @@ export default RepoSidebar;
:key="file.id"
:file="file"
:is-mini="isMini"
- @linkclicked="linkClicked(file)"
+ @linkclicked="fileClicked(file)"
:is-tree="isTree"
:has-files="!!files.length"
:active-file="activeFile"/>