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
ecb7c534
Commit
ecb7c534
authored
Aug 10, 2017
by
Eric Eastwood
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use promise syntax with Helper.getContent
Fix
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/12198#note_37143217
parent
f1e1113b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
10 deletions
+11
-10
repo_sidebar.vue
app/assets/javascripts/repo/components/repo_sidebar.vue
+7
-6
repo_helper.js
app/assets/javascripts/repo/helpers/repo_helper.js
+1
-2
repo_sidebar_spec.js
spec/javascripts/repo/components/repo_sidebar_spec.js
+3
-2
No files found.
app/assets/javascripts/repo/components/repo_sidebar.vue
View file @
ecb7c534
...
...
@@ -42,19 +42,20 @@ const RepoSidebar = {
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
,
()
=>
{
Helper
.
getContent
(
file
)
.
then
(()
=>
{
file
.
loading
=
false
;
Helper
.
scrollTabsRight
();
});
})
.
catch
(
Helper
.
loadingError
);
}
},
goToPreviousDirectoryClicked
(
prevURL
)
{
Service
.
url
=
prevURL
;
Helper
.
getContent
(
null
,
()
=>
Helper
.
scrollTabsRight
());
Helper
.
getContent
(
null
)
.
then
(()
=>
Helper
.
scrollTabsRight
())
.
catch
(
Helper
.
loadingError
);
},
},
};
...
...
app/assets/javascripts/repo/helpers/repo_helper.js
View file @
ecb7c534
...
...
@@ -135,14 +135,13 @@ const RepoHelper = {
return
isRoot
;
},
getContent
(
treeOrFile
,
cb
)
{
getContent
(
treeOrFile
)
{
let
file
=
treeOrFile
;
// const loadingData = RepoHelper.setLoading(true);
return
Service
.
getContent
()
.
then
((
response
)
=>
{
const
data
=
response
.
data
;
// RepoHelper.setLoading(false, loadingData);
if
(
cb
)
cb
();
Store
.
isTree
=
RepoHelper
.
isTree
(
data
);
if
(
!
Store
.
isTree
)
{
if
(
!
file
)
file
=
data
;
...
...
spec/javascripts/repo/components/repo_sidebar_spec.js
View file @
ecb7c534
...
...
@@ -64,9 +64,10 @@ describe('RepoSidebar', () => {
describe
(
'methods'
,
()
=>
{
describe
(
'fileClicked'
,
()
=>
{
it
(
'should fetch data for new file'
,
()
=>
{
spyOn
(
Helper
,
'getContent'
);
spyOn
(
Helper
,
'getContent'
)
.
and
.
callThrough
()
;
const
file1
=
{
id
:
0
,
url
:
''
,
};
RepoStore
.
files
=
[
file1
];
RepoStore
.
isRoot
=
true
;
...
...
@@ -74,7 +75,7 @@ describe('RepoSidebar', () => {
vm
.
fileClicked
(
file1
);
expect
(
Helper
.
getContent
).
toHaveBeenCalledWith
(
file1
,
jasmine
.
any
(
Function
)
);
expect
(
Helper
.
getContent
).
toHaveBeenCalledWith
(
file1
);
});
it
(
'should hide files in directory if already open'
,
()
=>
{
...
...
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