summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2019-06-05 15:44:53 +0000
committerNick Thomas <nick@gitlab.com>2019-06-05 15:44:53 +0000
commit327c7d5a07fa08276a52b6a2bfdf79eee812a2cd (patch)
tree0da14d9a65451f5c1937fb8679cab3ab9f4c7954 /app
parent86ff32da666c8d284ecff5987d42fa4dfed2ee9b (diff)
parent4644a2daf5ec5e86e2b2989f04e99e4f081f6fef (diff)
downloadgitlab-ce-327c7d5a07fa08276a52b6a2bfdf79eee812a2cd.tar.gz
Merge branch 'graphql-file-entry-url' into 'master'
Add web_url to tree entry in GraphQL API See merge request gitlab-org/gitlab-ce!28646
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/repository/components/table/index.vue1
-rw-r--r--app/assets/javascripts/repository/components/table/row.vue7
-rw-r--r--app/assets/javascripts/repository/queries/getFiles.graphql2
-rw-r--r--app/graphql/types/tree/blob_type.rb4
-rw-r--r--app/graphql/types/tree/tree_entry_type.rb4
-rw-r--r--app/graphql/types/tree/tree_type.rb10
-rw-r--r--app/presenters/blob_presenter.rb4
-rw-r--r--app/presenters/tree_entry_presenter.rb9
8 files changed, 38 insertions, 3 deletions
diff --git a/app/assets/javascripts/repository/components/table/index.vue b/app/assets/javascripts/repository/components/table/index.vue
index cccde1bb278..d2198bcccfe 100644
--- a/app/assets/javascripts/repository/components/table/index.vue
+++ b/app/assets/javascripts/repository/components/table/index.vue
@@ -134,6 +134,7 @@ export default {
:current-path="path"
:path="entry.flatPath"
:type="entry.type"
+ :url="entry.webUrl"
/>
</template>
</tbody>
diff --git a/app/assets/javascripts/repository/components/table/row.vue b/app/assets/javascripts/repository/components/table/row.vue
index 9a264bef87e..764882a7936 100644
--- a/app/assets/javascripts/repository/components/table/row.vue
+++ b/app/assets/javascripts/repository/components/table/row.vue
@@ -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">
diff --git a/app/assets/javascripts/repository/queries/getFiles.graphql b/app/assets/javascripts/repository/queries/getFiles.graphql
index a9b61d28560..7d92bc46455 100644
--- a/app/assets/javascripts/repository/queries/getFiles.graphql
+++ b/app/assets/javascripts/repository/queries/getFiles.graphql
@@ -23,6 +23,7 @@ query getFiles(
edges {
node {
...TreeEntry
+ webUrl
}
}
pageInfo {
@@ -43,6 +44,7 @@ query getFiles(
edges {
node {
...TreeEntry
+ webUrl
}
}
pageInfo {
diff --git a/app/graphql/types/tree/blob_type.rb b/app/graphql/types/tree/blob_type.rb
index 230624201b0..f2b7d5df2b2 100644
--- a/app/graphql/types/tree/blob_type.rb
+++ b/app/graphql/types/tree/blob_type.rb
@@ -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
diff --git a/app/graphql/types/tree/tree_entry_type.rb b/app/graphql/types/tree/tree_entry_type.rb
index d5cfb898aea..23ec2ef0ec2 100644
--- a/app/graphql/types/tree/tree_entry_type.rb
+++ b/app/graphql/types/tree/tree_entry_type.rb
@@ -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
diff --git a/app/graphql/types/tree/tree_type.rb b/app/graphql/types/tree/tree_type.rb
index 1eb6c43972e..1ee93ed9542 100644
--- a/app/graphql/types/tree/tree_type.rb
+++ b/app/graphql/types/tree/tree_type.rb
@@ -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
diff --git a/app/presenters/blob_presenter.rb b/app/presenters/blob_presenter.rb
index 6323c1b3389..c5675ef3ea3 100644
--- a/app/presenters/blob_presenter.rb
+++ b/app/presenters/blob_presenter.rb
@@ -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
diff --git a/app/presenters/tree_entry_presenter.rb b/app/presenters/tree_entry_presenter.rb
new file mode 100644
index 00000000000..7bb10cd1455
--- /dev/null
+++ b/app/presenters/tree_entry_presenter.rb
@@ -0,0 +1,9 @@
+# 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