BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
f1e1113b
Commit
f1e1113b
authored
Aug 10, 2017
by
Eric Eastwood
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split out linkClicked and add tests
Fix
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/12198#note_37143174
parent
06c33095
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
12 deletions
+57
-12
repo_sidebar.vue
app/assets/javascripts/repo/components/repo_sidebar.vue
+9
-12
repo_sidebar_spec.js
spec/javascripts/repo/components/repo_sidebar_spec.js
+48
-0
No files found.
app/assets/javascripts/repo/components/repo_sidebar.vue
View file @
f1e1113b
...
...
@@ -33,17 +33,15 @@ 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
=
false
;
}
else
{
url
=
file
.
url
;
Service
.
url
=
url
;
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.
...
...
@@ -52,12 +50,11 @@ const RepoSidebar = {
Helper
.
scrollTabsRight
();
});
}
}
else
if
(
typeof
file
===
'string'
)
{
// go back
url
=
file
;
Service
.
url
=
url
;
},
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=
"
link
Clicked(prevURL)"
/>
@
linkclicked=
"
goToPreviousDirectory
Clicked(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=
"
link
Clicked(file)"
@
linkclicked=
"
file
Clicked(file)"
:is-tree=
"isTree"
:has-files=
"!!files.length"
:active-file=
"activeFile"
/>
...
...
spec/javascripts/repo/components/repo_sidebar_spec.js
View file @
f1e1113b
import
Vue
from
'vue'
;
import
Helper
from
'~/repo/helpers/repo_helper'
;
import
RepoService
from
'~/repo/services/repo_service'
;
import
RepoStore
from
'~/repo/stores/repo_store'
;
import
repoSidebar
from
'~/repo/components/repo_sidebar.vue'
;
...
...
@@ -58,4 +60,50 @@ describe('RepoSidebar', () => {
expect
(
vm
.
$el
.
querySelector
(
'tbody .prev-directory'
)).
toBeTruthy
();
});
describe
(
'methods'
,
()
=>
{
describe
(
'fileClicked'
,
()
=>
{
it
(
'should fetch data for new file'
,
()
=>
{
spyOn
(
Helper
,
'getContent'
);
const
file1
=
{
id
:
0
,
};
RepoStore
.
files
=
[
file1
];
RepoStore
.
isRoot
=
true
;
const
vm
=
createComponent
();
vm
.
fileClicked
(
file1
);
expect
(
Helper
.
getContent
).
toHaveBeenCalledWith
(
file1
,
jasmine
.
any
(
Function
));
});
it
(
'should hide files in directory if already open'
,
()
=>
{
spyOn
(
RepoStore
,
'removeChildFilesOfTree'
).
and
.
callThrough
();
const
file1
=
{
id
:
0
,
type
:
'tree'
,
url
:
''
,
opened
:
true
,
};
RepoStore
.
files
=
[
file1
];
RepoStore
.
isRoot
=
true
;
const
vm
=
createComponent
();
vm
.
fileClicked
(
file1
);
expect
(
RepoStore
.
removeChildFilesOfTree
).
toHaveBeenCalledWith
(
file1
);
});
});
describe
(
'goToPreviousDirectoryClicked'
,
()
=>
{
it
(
'should hide files in directory if already open'
,
()
=>
{
const
prevUrl
=
'foo/bar'
;
const
vm
=
createComponent
();
vm
.
goToPreviousDirectoryClicked
(
prevUrl
);
expect
(
RepoService
.
url
).
toEqual
(
prevUrl
);
});
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment