Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
c25e83b5
Commit
c25e83b5
authored
Sep 25, 2017
by
Fatih Acet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RepoEditor: Prevent extra network call for already opened files.
parent
8266c78c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
7 deletions
+32
-7
app/assets/javascripts/repo/components/repo_sidebar.vue
app/assets/javascripts/repo/components/repo_sidebar.vue
+14
-7
app/assets/javascripts/repo/helpers/repo_helper.js
app/assets/javascripts/repo/helpers/repo_helper.js
+4
-0
spec/javascripts/repo/components/repo_sidebar_spec.js
spec/javascripts/repo/components/repo_sidebar_spec.js
+14
-0
No files found.
app/assets/javascripts/repo/components/repo_sidebar.vue
View file @
c25e83b5
...
@@ -37,9 +37,15 @@ export default {
...
@@ -37,9 +37,15 @@ export default {
let
file
=
clickedFile
;
let
file
=
clickedFile
;
if
(
file
.
loading
)
return
;
if
(
file
.
loading
)
return
;
file
.
loading
=
true
;
file
.
loading
=
true
;
if
(
file
.
type
===
'
tree
'
&&
file
.
opened
)
{
if
(
file
.
type
===
'
tree
'
&&
file
.
opened
)
{
file
=
Store
.
removeChildFilesOfTree
(
file
);
file
=
Store
.
removeChildFilesOfTree
(
file
);
file
.
loading
=
false
;
file
.
loading
=
false
;
}
else
{
const
openFile
=
Helper
.
getFileFromPath
(
file
.
url
);
if
(
openFile
)
{
file
.
loading
=
false
;
Store
.
setActiveFiles
(
openFile
);
}
else
{
}
else
{
Service
.
url
=
file
.
url
;
Service
.
url
=
file
.
url
;
Helper
.
getContent
(
file
)
Helper
.
getContent
(
file
)
...
@@ -49,6 +55,7 @@ export default {
...
@@ -49,6 +55,7 @@ export default {
})
})
.
catch
(
Helper
.
loadingError
);
.
catch
(
Helper
.
loadingError
);
}
}
}
},
},
goToPreviousDirectoryClicked
(
prevURL
)
{
goToPreviousDirectoryClicked
(
prevURL
)
{
...
...
app/assets/javascripts/repo/helpers/repo_helper.js
View file @
c25e83b5
...
@@ -263,6 +263,10 @@ const RepoHelper = {
...
@@ -263,6 +263,10 @@ const RepoHelper = {
return
Store
.
openedFiles
.
find
(
openedFile
=>
Store
.
activeFile
.
url
===
openedFile
.
url
);
return
Store
.
openedFiles
.
find
(
openedFile
=>
Store
.
activeFile
.
url
===
openedFile
.
url
);
},
},
getFileFromPath
(
path
)
{
return
Store
.
openedFiles
.
find
(
file
=>
file
.
url
===
path
);
},
loadingError
()
{
loadingError
()
{
Flash
(
'
Unable to load this content at this time.
'
);
Flash
(
'
Unable to load this content at this time.
'
);
},
},
...
...
spec/javascripts/repo/components/repo_sidebar_spec.js
View file @
c25e83b5
...
@@ -79,6 +79,20 @@ describe('RepoSidebar', () => {
...
@@ -79,6 +79,20 @@ describe('RepoSidebar', () => {
expect
(
Helper
.
getContent
).
toHaveBeenCalledWith
(
file1
);
expect
(
Helper
.
getContent
).
toHaveBeenCalledWith
(
file1
);
});
});
it
(
'
should not fetch data for already opened files
'
,
()
=>
{
const
file
=
{
id
:
42
,
url
:
'
foo
'
,
};
spyOn
(
Helper
,
'
getFileFromPath
'
).
and
.
returnValue
(
file
);
spyOn
(
RepoStore
,
'
setActiveFiles
'
);
const
vm
=
createComponent
();
vm
.
fileClicked
(
file
);
expect
(
RepoStore
.
setActiveFiles
).
toHaveBeenCalledWith
(
file
);
});
it
(
'
should hide files in directory if already open
'
,
()
=>
{
it
(
'
should hide files in directory if already open
'
,
()
=>
{
spyOn
(
RepoStore
,
'
removeChildFilesOfTree
'
).
and
.
callThrough
();
spyOn
(
RepoStore
,
'
removeChildFilesOfTree
'
).
and
.
callThrough
();
const
file1
=
{
const
file1
=
{
...
...
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