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
df3d9361
Commit
df3d9361
authored
Jun 28, 2019
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use GraphQL API to fetch last commit data for tree
parent
ecb05e59
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
120 additions
and
100 deletions
+120
-100
app/assets/javascripts/lib/graphql.js
app/assets/javascripts/lib/graphql.js
+1
-1
app/assets/javascripts/repository/components/last_commit.vue
app/assets/javascripts/repository/components/last_commit.vue
+72
-63
app/assets/javascripts/repository/index.js
app/assets/javascripts/repository/index.js
+13
-17
app/assets/javascripts/repository/queries/pathLastCommit.query.graphql
...vascripts/repository/queries/pathLastCommit.query.graphql
+3
-3
app/views/projects/_files.html.haml
app/views/projects/_files.html.haml
+3
-1
spec/features/projects/files/user_reads_pipeline_status_spec.rb
...eatures/projects/files/user_reads_pipeline_status_spec.rb
+2
-0
spec/features/projects/show/user_sees_last_commit_ci_status_spec.rb
...res/projects/show/user_sees_last_commit_ci_status_spec.rb
+4
-0
spec/frontend/repository/components/__snapshots__/last_commit_spec.js.snap
...ository/components/__snapshots__/last_commit_spec.js.snap
+8
-8
spec/frontend/repository/components/last_commit_spec.js
spec/frontend/repository/components/last_commit_spec.js
+14
-7
No files found.
app/assets/javascripts/lib/graphql.js
View file @
df3d9361
...
@@ -22,7 +22,7 @@ export default (resolvers = {}, config = {}) => {
...
@@ -22,7 +22,7 @@ export default (resolvers = {}, config = {}) => {
return
new
ApolloClient
({
return
new
ApolloClient
({
link
:
ApolloLink
.
split
(
link
:
ApolloLink
.
split
(
operation
=>
operation
.
getContext
().
hasUpload
,
operation
=>
operation
.
getContext
().
hasUpload
||
operation
.
getContext
().
isSingleRequest
,
createUploadLink
(
httpOptions
),
createUploadLink
(
httpOptions
),
new
BatchHttpLink
(
httpOptions
),
new
BatchHttpLink
(
httpOptions
),
),
),
...
...
app/assets/javascripts/repository/components/last_commit.vue
View file @
df3d9361
<
script
>
<
script
>
import
{
GlTooltipDirective
,
GlLink
,
GlButton
}
from
'
@gitlab/ui
'
;
import
{
GlTooltipDirective
,
GlLink
,
GlButton
,
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
sprintf
,
s__
}
from
'
~/locale
'
;
import
{
sprintf
,
s__
}
from
'
~/locale
'
;
import
Icon
from
'
../../vue_shared/components/icon.vue
'
;
import
Icon
from
'
../../vue_shared/components/icon.vue
'
;
import
UserAvatarLink
from
'
../../vue_shared/components/user_avatar/user_avatar_link.vue
'
;
import
UserAvatarLink
from
'
../../vue_shared/components/user_avatar/user_avatar_link.vue
'
;
import
TimeagoTooltip
from
'
../../vue_shared/components/time_ago_tooltip.vue
'
;
import
TimeagoTooltip
from
'
../../vue_shared/components/time_ago_tooltip.vue
'
;
import
CommitPipelineStatus
from
'
../../projects/tree/components/commit_pipeline_status_component.vue
'
;
import
CiIcon
from
'
../../vue_shared/components/ci_icon.vue
'
;
import
CiIcon
from
'
../../vue_shared/components/ci_icon.vue
'
;
import
ClipboardButton
from
'
../../vue_shared/components/clipboard_button.vue
'
;
import
ClipboardButton
from
'
../../vue_shared/components/clipboard_button.vue
'
;
import
getRefMixin
from
'
../mixins/get_ref
'
;
import
getRefMixin
from
'
../mixins/get_ref
'
;
...
@@ -16,11 +15,11 @@ export default {
...
@@ -16,11 +15,11 @@ export default {
Icon
,
Icon
,
UserAvatarLink
,
UserAvatarLink
,
TimeagoTooltip
,
TimeagoTooltip
,
CommitPipelineStatus
,
ClipboardButton
,
ClipboardButton
,
CiIcon
,
CiIcon
,
GlLink
,
GlLink
,
GlButton
,
GlButton
,
GlLoadingIcon
,
},
},
directives
:
{
directives
:
{
GlTooltip
:
GlTooltipDirective
,
GlTooltip
:
GlTooltipDirective
,
...
@@ -39,7 +38,10 @@ export default {
...
@@ -39,7 +38,10 @@ export default {
path
:
this
.
currentPath
.
replace
(
/^
\/
/
,
''
),
path
:
this
.
currentPath
.
replace
(
/^
\/
/
,
''
),
};
};
},
},
update
:
data
=>
data
.
project
.
repository
.
tree
.
commit
,
update
:
data
=>
data
.
project
.
repository
.
tree
.
lastCommit
,
context
:
{
isSingleRequest
:
true
,
},
},
},
},
},
props
:
{
props
:
{
...
@@ -59,14 +61,14 @@ export default {
...
@@ -59,14 +61,14 @@ export default {
computed
:
{
computed
:
{
statusTitle
()
{
statusTitle
()
{
return
sprintf
(
s__
(
'
Commits|Commit: %{commitText}
'
),
{
return
sprintf
(
s__
(
'
Commits|Commit: %{commitText}
'
),
{
commitText
:
this
.
commit
.
p
ipeline
.
detailedStatus
.
text
,
commitText
:
this
.
commit
.
latestP
ipeline
.
detailedStatus
.
text
,
});
});
},
},
isLoading
()
{
isLoading
()
{
return
this
.
$apollo
.
queries
.
commit
.
loading
;
return
this
.
$apollo
.
queries
.
commit
.
loading
;
},
},
showCommitId
()
{
showCommitId
()
{
return
this
.
commit
.
id
.
substr
(
0
,
8
);
return
this
.
commit
.
sha
.
substr
(
0
,
8
);
},
},
},
},
methods
:
{
methods
:
{
...
@@ -78,68 +80,75 @@ export default {
...
@@ -78,68 +80,75 @@ export default {
</
script
>
</
script
>
<
template
>
<
template
>
<div
v-if=
"!isLoading"
class=
"info-well d-none d-sm-flex project-last-commit commit p-3"
>
<div
class=
"info-well d-none d-sm-flex project-last-commit commit p-3"
>
<user-avatar-link
<gl-loading-icon
v-if=
"isLoading"
size=
"md"
class=
"mx-auto"
/>
v-if=
"commit.author"
<template
v-else
>
:link-href=
"commit.author.webUrl"
<user-avatar-link
:img-src=
"commit.author.avatarUrl"
v-if=
"commit.author"
:img-size=
"40"
:link-href=
"commit.author.webUrl"
class=
"avatar-cell"
:img-src=
"commit.author.avatarUrl"
/>
:img-size=
"40"
<div
class=
"commit-detail flex-list"
>
class=
"avatar-cell"
<div
class=
"commit-content qa-commit-content"
>
/>
<gl-link
:href=
"commit.webUrl"
class=
"commit-row-message item-title"
>
<div
class=
"commit-detail flex-list"
>
{{
commit
.
title
}}
<div
class=
"commit-content qa-commit-content"
>
</gl-link>
<gl-link
:href=
"commit.webUrl"
class=
"commit-row-message item-title"
>
<gl-button
{{
commit
.
title
}}
v-if=
"commit.description"
</gl-link>
:class=
"
{ open: showDescription }"
<gl-button
:aria-label="__('Show commit description')"
v-if=
"commit.description"
class="text-expander"
:class=
"
{ open: showDescription }"
@click="toggleShowDescription"
:aria-label="__('Show commit description')"
>
class="text-expander"
<icon
name=
"ellipsis_h"
/>
@click="toggleShowDescription"
</gl-button>
>
<div
class=
"committer"
>
<icon
name=
"ellipsis_h"
/>
</gl-button>
<div
class=
"committer"
>
<gl-link
v-if=
"commit.author"
:href=
"commit.author.webUrl"
class=
"commit-author-link js-user-link"
>
{{
commit
.
author
.
name
}}
</gl-link>
authored
<timeago-tooltip
:time=
"commit.authoredDate"
tooltip-placement=
"bottom"
/>
</div>
<pre
v-if=
"commit.description"
v-show=
"showDescription"
class=
"commit-row-description append-bottom-8"
>
{{
commit
.
description
}}
</pre>
</div>
<div
class=
"commit-actions flex-row"
>
<gl-link
<gl-link
v-if=
"commit.author"
v-if=
"commit.latestPipeline"
:href=
"commit.author.webUrl"
v-gl-tooltip
class=
"commit-author-link js-user-link"
:href=
"commit.latestPipeline.detailedStatus.detailsPath"
:title=
"statusTitle"
class=
"js-commit-pipeline"
>
>
{{
commit
.
author
.
name
}}
<ci-icon
:status=
"commit.latestPipeline.detailedStatus"
:size=
"24"
:aria-label=
"statusTitle"
/>
</gl-link>
</gl-link>
authored
<div
class=
"commit-sha-group d-flex"
>
<timeago-tooltip
:time=
"commit.authoredDate"
tooltip-placement=
"bottom"
/>
<div
class=
"label label-monospace monospace"
>
</div>
{{
showCommitId
}}
<pre
</div>
v-if=
"commit.description"
<clipboard-button
v-show=
"showDescription"
:text=
"commit.sha"
class=
"commit-row-description append-bottom-8"
:title=
"__('Copy commit SHA to clipboard')"
>
tooltip-placement=
"bottom"
{{
commit
.
description
}}
/>
</pre>
</div>
<div
class=
"commit-actions flex-row"
>
<gl-link
v-if=
"commit.pipeline"
v-gl-tooltip
:href=
"commit.pipeline.detailedStatus.detailsPath"
:title=
"statusTitle"
class=
"js-commit-pipeline"
>
<ci-icon
:status=
"commit.pipeline.detailedStatus"
:size=
"24"
:aria-label=
"statusTitle"
/>
</gl-link>
<div
class=
"commit-sha-group d-flex"
>
<div
class=
"label label-monospace monospace"
>
{{
showCommitId
}}
</div>
</div>
<clipboard-button
:text=
"commit.id"
:title=
"__('Copy commit SHA to clipboard')"
tooltip-placement=
"bottom"
/>
</div>
</div>
</div>
</div>
</
div
>
</
template
>
</div>
</div>
</template>
</template>
app/assets/javascripts/repository/index.js
View file @
df3d9361
...
@@ -50,23 +50,19 @@ export default function setupVueRepositoryList() {
...
@@ -50,23 +50,19 @@ export default function setupVueRepositoryList() {
},
},
});
});
const
commitEl
=
document
.
getElementById
(
'
js-last-commit
'
);
// eslint-disable-next-line no-new
new
Vue
({
if
(
commitEl
)
{
el
:
document
.
getElementById
(
'
js-last-commit
'
),
// eslint-disable-next-line no-new
router
,
new
Vue
({
apolloProvider
,
el
:
commitEl
,
render
(
h
)
{
router
,
return
h
(
LastCommit
,
{
apolloProvider
,
props
:
{
render
(
h
)
{
currentPath
:
this
.
$route
.
params
.
pathMatch
,
return
h
(
LastCommit
,
{
},
props
:
{
});
currentPath
:
this
.
$route
.
params
.
pathMatch
,
},
},
});
});
},
});
}
return
new
Vue
({
return
new
Vue
({
el
,
el
,
...
...
app/assets/javascripts/repository/queries/pathLastCommit.query.graphql
View file @
df3d9361
...
@@ -2,8 +2,8 @@ query pathLastCommit($projectPath: ID!, $path: String, $ref: String!) {
...
@@ -2,8 +2,8 @@ query pathLastCommit($projectPath: ID!, $path: String, $ref: String!) {
project
(
fullPath
:
$projectPath
)
{
project
(
fullPath
:
$projectPath
)
{
repository
{
repository
{
tree
(
path
:
$path
,
ref
:
$ref
)
{
tree
(
path
:
$path
,
ref
:
$ref
)
{
c
ommit
{
lastC
ommit
{
id
sha
title
title
message
message
webUrl
webUrl
...
@@ -13,7 +13,7 @@ query pathLastCommit($projectPath: ID!, $path: String, $ref: String!) {
...
@@ -13,7 +13,7 @@ query pathLastCommit($projectPath: ID!, $path: String, $ref: String!) {
avatarUrl
avatarUrl
webUrl
webUrl
}
}
p
ipeline
{
latestP
ipeline
{
detailedStatus
{
detailedStatus
{
detailsPath
detailsPath
icon
icon
...
...
app/views/projects/_files.html.haml
View file @
df3d9361
...
@@ -9,7 +9,9 @@
...
@@ -9,7 +9,9 @@
.nav-block
.nav-block
=
render
'projects/tree/tree_header'
,
tree:
@tree
=
render
'projects/tree/tree_header'
,
tree:
@tree
-
if
commit
-
if
vue_file_list_enabled?
#js-last-commit
-
elsif
commit
=
render
'shared/commit_well'
,
commit:
commit
,
ref:
ref
,
project:
project
=
render
'shared/commit_well'
,
commit:
commit
,
ref:
ref
,
project:
project
-
if
is_project_overview
-
if
is_project_overview
...
...
spec/features/projects/files/user_reads_pipeline_status_spec.rb
View file @
df3d9361
...
@@ -7,6 +7,8 @@ describe 'user reads pipeline status', :js do
...
@@ -7,6 +7,8 @@ describe 'user reads pipeline status', :js do
let
(
:x110_pipeline
)
{
create_pipeline
(
'x1.1.0'
,
'failed'
)
}
let
(
:x110_pipeline
)
{
create_pipeline
(
'x1.1.0'
,
'failed'
)
}
before
do
before
do
stub_feature_flags
(
vue_file_list:
false
)
project
.
add_maintainer
(
user
)
project
.
add_maintainer
(
user
)
project
.
repository
.
add_tag
(
user
,
'x1.1.0'
,
'v1.1.0'
)
project
.
repository
.
add_tag
(
user
,
'x1.1.0'
,
'v1.1.0'
)
...
...
spec/features/projects/show/user_sees_last_commit_ci_status_spec.rb
View file @
df3d9361
...
@@ -3,6 +3,10 @@ require 'spec_helper'
...
@@ -3,6 +3,10 @@ require 'spec_helper'
describe
'Projects > Show > User sees last commit CI status'
do
describe
'Projects > Show > User sees last commit CI status'
do
set
(
:project
)
{
create
(
:project
,
:repository
,
:public
)
}
set
(
:project
)
{
create
(
:project
,
:repository
,
:public
)
}
before
do
stub_feature_flags
(
vue_file_list:
false
)
end
it
'shows the project README'
,
:js
do
it
'shows the project README'
,
:js
do
project
.
enable_ci
project
.
enable_ci
pipeline
=
create
(
:ci_pipeline
,
project:
project
,
sha:
project
.
commit
.
sha
,
ref:
'master'
)
pipeline
=
create
(
:ci_pipeline
,
project:
project
,
sha:
project
.
commit
.
sha
,
ref:
'master'
)
...
...
spec/frontend/repository/components/__snapshots__/last_commit_spec.js.snap
View file @
df3d9361
...
@@ -27,8 +27,8 @@ exports[`Repository last commit component renders commit widget 1`] = `
...
@@ -27,8 +27,8 @@ exports[`Repository last commit component renders commit widget 1`] = `
href="https://test.com/commit/123"
href="https://test.com/commit/123"
>
>
Commit title
Commit title
</gllink-stub>
</gllink-stub>
<!---->
<!---->
...
@@ -41,12 +41,12 @@ exports[`Repository last commit component renders commit widget 1`] = `
...
@@ -41,12 +41,12 @@ exports[`Repository last commit component renders commit widget 1`] = `
href="https://test.com/test"
href="https://test.com/test"
>
>
Test
Test
</gllink-stub>
</gllink-stub>
authored
authored
<timeagotooltip-stub
<timeagotooltip-stub
cssclass=""
cssclass=""
time="2019-01-01"
time="2019-01-01"
...
@@ -81,8 +81,8 @@ exports[`Repository last commit component renders commit widget 1`] = `
...
@@ -81,8 +81,8 @@ exports[`Repository last commit component renders commit widget 1`] = `
class="label label-monospace monospace"
class="label label-monospace monospace"
>
>
12345678
12345678
</div>
</div>
<clipboardbutton-stub
<clipboardbutton-stub
...
...
spec/frontend/repository/components/last_commit_spec.js
View file @
df3d9361
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
LastCommit
from
'
~/repository/components/last_commit.vue
'
;
import
LastCommit
from
'
~/repository/components/last_commit.vue
'
;
import
UserAvatarLink
from
'
~/vue_shared/components/user_avatar/user_avatar_link.vue
'
;
import
UserAvatarLink
from
'
~/vue_shared/components/user_avatar/user_avatar_link.vue
'
;
...
@@ -6,7 +7,7 @@ let vm;
...
@@ -6,7 +7,7 @@ let vm;
function
createCommitData
(
data
=
{})
{
function
createCommitData
(
data
=
{})
{
return
{
return
{
id
:
'
123456789
'
,
sha
:
'
123456789
'
,
title
:
'
Commit title
'
,
title
:
'
Commit title
'
,
message
:
'
Commit message
'
,
message
:
'
Commit message
'
,
webUrl
:
'
https://test.com/commit/123
'
,
webUrl
:
'
https://test.com/commit/123
'
,
...
@@ -16,7 +17,7 @@ function createCommitData(data = {}) {
...
@@ -16,7 +17,7 @@ function createCommitData(data = {}) {
avatarUrl
:
'
https://test.com
'
,
avatarUrl
:
'
https://test.com
'
,
webUrl
:
'
https://test.com/test
'
,
webUrl
:
'
https://test.com/test
'
,
},
},
p
ipeline
:
{
latestP
ipeline
:
{
detailedStatus
:
{
detailedStatus
:
{
detailsPath
:
'
https://test.com/pipeline
'
,
detailsPath
:
'
https://test.com/pipeline
'
,
icon
:
'
failed
'
,
icon
:
'
failed
'
,
...
@@ -52,12 +53,12 @@ describe('Repository last commit component', () => {
...
@@ -52,12 +53,12 @@ describe('Repository last commit component', () => {
it
.
each
`
it
.
each
`
loading | label
loading | label
${
true
}
|
${
'
hide
s
'
}
${
true
}
|
${
'
show
s
'
}
${
false
}
|
${
'
show
s
'
}
${
false
}
|
${
'
hide
s
'
}
`
(
'
$label when $loading is true
'
,
({
loading
})
=>
{
`
(
'
$label when
loading icon
$loading is true
'
,
({
loading
})
=>
{
factory
(
createCommitData
(),
loading
);
factory
(
createCommitData
(),
loading
);
expect
(
vm
.
isEmpty
()).
toBe
(
loading
);
expect
(
vm
.
find
(
GlLoadingIcon
).
exists
()).
toBe
(
loading
);
});
});
it
(
'
renders commit widget
'
,
()
=>
{
it
(
'
renders commit widget
'
,
()
=>
{
...
@@ -73,11 +74,17 @@ describe('Repository last commit component', () => {
...
@@ -73,11 +74,17 @@ describe('Repository last commit component', () => {
});
});
it
(
'
hides pipeline components when pipeline does not exist
'
,
()
=>
{
it
(
'
hides pipeline components when pipeline does not exist
'
,
()
=>
{
factory
(
createCommitData
({
p
ipeline
:
null
}));
factory
(
createCommitData
({
latestP
ipeline
:
null
}));
expect
(
vm
.
find
(
'
.js-commit-pipeline
'
).
exists
()).
toBe
(
false
);
expect
(
vm
.
find
(
'
.js-commit-pipeline
'
).
exists
()).
toBe
(
false
);
});
});
it
(
'
renders pipeline components
'
,
()
=>
{
factory
();
expect
(
vm
.
find
(
'
.js-commit-pipeline
'
).
exists
()).
toBe
(
true
);
});
it
(
'
hides author component when author does not exist
'
,
()
=>
{
it
(
'
hides author component when author does not exist
'
,
()
=>
{
factory
(
createCommitData
({
author
:
null
}));
factory
(
createCommitData
({
author
:
null
}));
...
...
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