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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
4644a2da
Commit
4644a2da
authored
Jun 04, 2019
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add web_url to tree entry in GraphQL API
parent
df549eb2
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
129 additions
and
5 deletions
+129
-5
app/assets/javascripts/repository/components/table/index.vue
app/assets/javascripts/repository/components/table/index.vue
+1
-0
app/assets/javascripts/repository/components/table/row.vue
app/assets/javascripts/repository/components/table/row.vue
+6
-1
app/assets/javascripts/repository/queries/getFiles.graphql
app/assets/javascripts/repository/queries/getFiles.graphql
+2
-0
app/graphql/types/tree/blob_type.rb
app/graphql/types/tree/blob_type.rb
+4
-0
app/graphql/types/tree/tree_entry_type.rb
app/graphql/types/tree/tree_entry_type.rb
+4
-0
app/graphql/types/tree/tree_type.rb
app/graphql/types/tree/tree_type.rb
+8
-2
app/presenters/blob_presenter.rb
app/presenters/blob_presenter.rb
+4
-0
app/presenters/tree_entry_presenter.rb
app/presenters/tree_entry_presenter.rb
+9
-0
lib/gitlab/graphql/representation/tree_entry.rb
lib/gitlab/graphql/representation/tree_entry.rb
+31
-0
spec/frontend/repository/components/table/row_spec.js
spec/frontend/repository/components/table/row_spec.js
+12
-0
spec/graphql/types/tree/blob_type_spec.rb
spec/graphql/types/tree/blob_type_spec.rb
+1
-1
spec/graphql/types/tree/tree_entry_type_spec.rb
spec/graphql/types/tree/tree_entry_type_spec.rb
+1
-1
spec/lib/gitlab/graphql/representation/tree_entry_spec.rb
spec/lib/gitlab/graphql/representation/tree_entry_spec.rb
+20
-0
spec/presenters/blob_presenter_spec.rb
spec/presenters/blob_presenter_spec.rb
+10
-0
spec/presenters/tree_entry_presenter_spec.rb
spec/presenters/tree_entry_presenter_spec.rb
+16
-0
No files found.
app/assets/javascripts/repository/components/table/index.vue
View file @
4644a2da
...
...
@@ -134,6 +134,7 @@ export default {
:current-path="path"
:path="entry.flatPath"
:type="entry.type"
:url="entry.webUrl"
/>
</
template
>
</tbody>
...
...
app/assets/javascripts/repository/components/table/row.vue
View file @
4644a2da
...
...
@@ -21,6 +21,11 @@ export default {
type
:
String
,
required
:
true
,
},
url
:
{
type
:
String
,
required
:
false
,
default
:
null
,
},
},
computed
:
{
routerLinkTo
()
{
...
...
@@ -59,7 +64,7 @@ export default {
<tr
v-once
:class=
"`file_$
{id}`" class="tree-item" @click="openRow">
<td
class=
"tree-item-file-name"
>
<i
:aria-label=
"type"
role=
"img"
:class=
"iconName"
class=
"fa fa-fw"
></i>
<component
:is=
"linkComponent"
:to=
"routerLinkTo"
class=
"str-truncated"
>
<component
:is=
"linkComponent"
:to=
"routerLinkTo"
:href=
"url"
class=
"str-truncated"
>
{{
fullPath
}}
</component>
<template
v-if=
"isSubmodule"
>
...
...
app/assets/javascripts/repository/queries/getFiles.graphql
View file @
4644a2da
...
...
@@ -23,6 +23,7 @@ query getFiles(
edges
{
node
{
...
TreeEntry
webUrl
}
}
pageInfo
{
...
...
@@ -43,6 +44,7 @@ query getFiles(
edges
{
node
{
...
TreeEntry
webUrl
}
}
pageInfo
{
...
...
app/graphql/types/tree/blob_type.rb
View file @
4644a2da
...
...
@@ -4,7 +4,11 @@ module Types
class
BlobType
<
BaseObject
implements
Types
::
Tree
::
EntryType
present_using
BlobPresenter
graphql_name
'Blob'
field
:web_url
,
GraphQL
::
STRING_TYPE
,
null:
true
end
end
end
app/graphql/types/tree/tree_entry_type.rb
View file @
4644a2da
...
...
@@ -4,8 +4,12 @@ module Types
class
TreeEntryType
<
BaseObject
implements
Types
::
Tree
::
EntryType
present_using
TreeEntryPresenter
graphql_name
'TreeEntry'
description
'Represents a directory'
field
:web_url
,
GraphQL
::
STRING_TYPE
,
null:
true
end
end
end
app/graphql/types/tree/tree_type.rb
View file @
4644a2da
...
...
@@ -4,9 +4,15 @@ module Types
class
TreeType
<
BaseObject
graphql_name
'Tree'
field
:trees
,
Types
::
Tree
::
TreeEntryType
.
connection_type
,
null:
false
field
:trees
,
Types
::
Tree
::
TreeEntryType
.
connection_type
,
null:
false
,
resolve:
->
(
obj
,
args
,
ctx
)
do
Gitlab
::
Graphql
::
Representation
::
TreeEntry
.
decorate
(
obj
.
trees
,
obj
.
repository
)
end
field
:submodules
,
Types
::
Tree
::
SubmoduleType
.
connection_type
,
null:
false
field
:blobs
,
Types
::
Tree
::
BlobType
.
connection_type
,
null:
false
field
:blobs
,
Types
::
Tree
::
BlobType
.
connection_type
,
null:
false
,
resolve:
->
(
obj
,
args
,
ctx
)
do
Gitlab
::
Graphql
::
Representation
::
TreeEntry
.
decorate
(
obj
.
blobs
,
obj
.
repository
)
end
end
end
end
app/presenters/blob_presenter.rb
View file @
4644a2da
...
...
@@ -13,4 +13,8 @@ class BlobPresenter < Gitlab::View::Presenter::Simple
plain:
plain
)
end
def
web_url
Gitlab
::
Routing
.
url_helpers
.
project_blob_url
(
blob
.
repository
.
project
,
File
.
join
(
blob
.
commit_id
,
blob
.
path
))
end
end
app/presenters/tree_entry_presenter.rb
0 → 100644
View file @
4644a2da
# frozen_string_literal: true
class
TreeEntryPresenter
<
Gitlab
::
View
::
Presenter
::
Delegated
presents
:tree
def
web_url
Gitlab
::
Routing
.
url_helpers
.
project_tree_url
(
tree
.
repository
.
project
,
File
.
join
(
tree
.
commit_id
,
tree
.
path
))
end
end
lib/gitlab/graphql/representation/tree_entry.rb
0 → 100644
View file @
4644a2da
# frozen_string_literal: true
module
Gitlab
module
Graphql
module
Representation
class
TreeEntry
<
SimpleDelegator
class
<<
self
def
decorate
(
entries
,
repository
)
return
if
entries
.
nil?
entries
.
map
do
|
entry
|
if
entry
.
is_a?
(
TreeEntry
)
entry
else
self
.
new
(
entry
,
repository
)
end
end
end
end
attr_accessor
:repository
def
initialize
(
raw_entry
,
repository
)
@repository
=
repository
super
(
raw_entry
)
end
end
end
end
end
spec/frontend/repository/components/table/row_spec.js
View file @
4644a2da
...
...
@@ -86,4 +86,16 @@ describe('Repository table row component', () => {
expect
(
vm
.
find
(
'
.commit-sha
'
).
text
()).
toContain
(
'
1
'
);
});
it
(
'
renders link with href
'
,
()
=>
{
factory
({
id
:
'
1
'
,
path
:
'
test
'
,
type
:
'
blob
'
,
url
:
'
https://test.com
'
,
currentPath
:
'
/
'
,
});
expect
(
vm
.
find
(
'
a
'
).
attributes
(
'
href
'
)).
toEqual
(
'
https://test.com
'
);
});
});
spec/graphql/types/tree/blob_type_spec.rb
View file @
4644a2da
...
...
@@ -5,5 +5,5 @@ require 'spec_helper'
describe
Types
::
Tree
::
BlobType
do
it
{
expect
(
described_class
.
graphql_name
).
to
eq
(
'Blob'
)
}
it
{
expect
(
described_class
).
to
have_graphql_fields
(
:id
,
:name
,
:type
,
:path
,
:flat_path
)
}
it
{
expect
(
described_class
).
to
have_graphql_fields
(
:id
,
:name
,
:type
,
:path
,
:flat_path
,
:web_url
)
}
end
spec/graphql/types/tree/tree_entry_type_spec.rb
View file @
4644a2da
...
...
@@ -5,5 +5,5 @@ require 'spec_helper'
describe
Types
::
Tree
::
TreeEntryType
do
it
{
expect
(
described_class
.
graphql_name
).
to
eq
(
'TreeEntry'
)
}
it
{
expect
(
described_class
).
to
have_graphql_fields
(
:id
,
:name
,
:type
,
:path
,
:flat_path
)
}
it
{
expect
(
described_class
).
to
have_graphql_fields
(
:id
,
:name
,
:type
,
:path
,
:flat_path
,
:web_url
)
}
end
spec/lib/gitlab/graphql/representation/tree_entry_spec.rb
0 → 100644
View file @
4644a2da
# frozen_string_literal: true
require
'spec_helper'
describe
Gitlab
::
Graphql
::
Representation
::
TreeEntry
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:repository
)
{
project
.
repository
}
describe
'.decorate'
do
it
'returns NilClass when given nil'
do
expect
(
described_class
.
decorate
(
nil
,
repository
)).
to
be_nil
end
it
'returns array of TreeEntry'
do
entries
=
described_class
.
decorate
(
repository
.
tree
.
blobs
,
repository
)
expect
(
entries
.
first
).
to
be_a
(
described_class
)
end
end
end
spec/presenters/blob_presenter_spec.rb
View file @
4644a2da
...
...
@@ -14,6 +14,16 @@ describe BlobPresenter, :seed_helper do
end
let
(
:blob
)
{
Blob
.
new
(
git_blob
)
}
describe
'.web_url'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:repository
)
{
project
.
repository
}
let
(
:blob
)
{
Gitlab
::
Graphql
::
Representation
::
TreeEntry
.
new
(
repository
.
tree
.
blobs
.
first
,
repository
)
}
subject
{
described_class
.
new
(
blob
)
}
it
{
expect
(
subject
.
web_url
).
to
eq
(
"http://localhost/
#{
project
.
full_path
}
/blob/
#{
blob
.
commit_id
}
/
#{
blob
.
path
}
"
)
}
end
describe
'#highlight'
do
subject
{
described_class
.
new
(
blob
)
}
...
...
spec/presenters/tree_entry_presenter_spec.rb
0 → 100644
View file @
4644a2da
# frozen_string_literal: true
require
'spec_helper'
describe
TreeEntryPresenter
do
include
Gitlab
::
Routing
.
url_helpers
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:repository
)
{
project
.
repository
}
let
(
:tree
)
{
Gitlab
::
Graphql
::
Representation
::
TreeEntry
.
new
(
repository
.
tree
.
trees
.
first
,
repository
)
}
let
(
:presenter
)
{
described_class
.
new
(
tree
)
}
describe
'.web_url'
do
it
{
expect
(
presenter
.
web_url
).
to
eq
(
"http://localhost/
#{
project
.
full_path
}
/tree/
#{
tree
.
commit_id
}
/
#{
tree
.
path
}
"
)
}
end
end
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