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
b37b804c
Commit
b37b804c
authored
May 19, 2021
by
jerasmus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Preload blobs in repo view
Preloaded the blobs using the hoverLoad directive. Changelog: performance
parent
15243640
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
1 deletion
+54
-1
app/assets/javascripts/repository/components/table/row.vue
app/assets/javascripts/repository/components/table/row.vue
+33
-0
app/assets/javascripts/repository/queries/blob_info.query.graphql
...ts/javascripts/repository/queries/blob_info.query.graphql
+0
-1
spec/frontend/repository/components/table/row_spec.js
spec/frontend/repository/components/table/row_spec.js
+21
-0
No files found.
app/assets/javascripts/repository/components/table/row.vue
View file @
b37b804c
...
...
@@ -7,13 +7,17 @@ import {
GlTooltipDirective
,
GlLoadingIcon
,
GlIcon
,
GlHoverLoadDirective
,
}
from
'
@gitlab/ui
'
;
import
{
escapeRegExp
}
from
'
lodash
'
;
import
filesQuery
from
'
shared_queries/repository/files.query.graphql
'
;
import
{
escapeFileUrl
}
from
'
~/lib/utils/url_utility
'
;
import
{
TREE_PAGE_SIZE
}
from
'
~/repository/constants
'
;
import
FileIcon
from
'
~/vue_shared/components/file_icon.vue
'
;
import
TimeagoTooltip
from
'
~/vue_shared/components/time_ago_tooltip.vue
'
;
import
glFeatureFlagMixin
from
'
~/vue_shared/mixins/gl_feature_flags_mixin
'
;
import
getRefMixin
from
'
../../mixins/get_ref
'
;
import
blobInfoQuery
from
'
../../queries/blob_info.query.graphql
'
;
import
commitQuery
from
'
../../queries/commit.query.graphql
'
;
export
default
{
...
...
@@ -28,6 +32,7 @@ export default {
},
directives
:
{
GlTooltip
:
GlTooltipDirective
,
GlHoverLoad
:
GlHoverLoadDirective
,
},
apollo
:
{
commit
:
{
...
...
@@ -139,6 +144,33 @@ export default {
return
this
.
commit
&&
this
.
commit
.
lockLabel
;
},
},
methods
:
{
handlePreload
()
{
return
this
.
isFolder
?
this
.
loadFolder
()
:
this
.
loadBlob
();
},
loadFolder
()
{
this
.
apolloQuery
(
filesQuery
,
{
projectPath
:
this
.
projectPath
,
ref
:
this
.
ref
,
path
:
this
.
path
,
nextPageCursor
:
''
,
pageSize
:
TREE_PAGE_SIZE
,
});
},
loadBlob
()
{
if
(
!
this
.
refactorBlobViewerEnabled
)
{
return
;
}
this
.
apolloQuery
(
blobInfoQuery
,
{
projectPath
:
this
.
projectPath
,
filePath
:
this
.
path
,
});
},
apolloQuery
(
query
,
variables
)
{
this
.
$apollo
.
query
({
query
,
variables
});
},
},
};
</
script
>
...
...
@@ -148,6 +180,7 @@ export default {
<component
:is=
"linkComponent"
ref=
"link"
v-gl-hover-load=
"handlePreload"
:to=
"routerLinkTo"
:href=
"url"
:class=
"
{
...
...
app/assets/javascripts/repository/queries/blob_info.query.graphql
View file @
b37b804c
query
getBlobInfo
(
$projectPath
:
ID
!,
$filePath
:
String
!)
{
project
(
fullPath
:
$projectPath
)
{
id
repository
{
blobs
(
paths
:
[
$filePath
])
{
nodes
{
...
...
spec/frontend/repository/components/table/row_spec.js
View file @
b37b804c
import
{
GlBadge
,
GlLink
,
GlIcon
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
,
RouterLinkStub
}
from
'
@vue/test-utils
'
;
import
{
createMockDirective
,
getBinding
}
from
'
helpers/vue_mock_directive
'
;
import
TableRow
from
'
~/repository/components/table/row.vue
'
;
import
FileIcon
from
'
~/vue_shared/components/file_icon.vue
'
;
import
{
FILE_SYMLINK_MODE
}
from
'
~/vue_shared/constants
'
;
...
...
@@ -19,6 +20,9 @@ function factory(propsData = {}) {
projectPath
:
'
gitlab-org/gitlab-ce
'
,
url
:
`https://test.com`
,
},
directives
:
{
GlHoverLoad
:
createMockDirective
(),
},
provide
:
{
glFeatures
:
{
refactorBlobViewer
:
true
},
},
...
...
@@ -34,6 +38,8 @@ function factory(propsData = {}) {
}
describe
(
'
Repository table row component
'
,
()
=>
{
const
findRouterLink
=
()
=>
vm
.
find
(
RouterLinkStub
);
afterEach
(()
=>
{
vm
.
destroy
();
});
...
...
@@ -81,6 +87,21 @@ describe('Repository table row component', () => {
});
});
it
(
'
renders a gl-hover-load directive
'
,
()
=>
{
factory
({
id
:
'
1
'
,
sha
:
'
123
'
,
path
:
'
test
'
,
type
:
'
blob
'
,
currentPath
:
'
/
'
,
});
const
hoverLoadDirective
=
getBinding
(
findRouterLink
().
element
,
'
gl-hover-load
'
);
expect
(
hoverLoadDirective
).
not
.
toBeUndefined
();
expect
(
hoverLoadDirective
.
value
).
toBeInstanceOf
(
Function
);
});
it
.
each
`
type | component | componentName
${
'
tree
'
}
|
${
RouterLinkStub
}
|
${
'
RouterLink
'
}
...
...
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