From df3d9361e505db61de41b8e39516470d50c0e851 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Fri, 28 Jun 2019 13:36:18 +0100 Subject: Use GraphQL API to fetch last commit data for tree --- app/assets/javascripts/lib/graphql.js | 2 +- .../repository/components/last_commit.vue | 135 +++++++++++---------- app/assets/javascripts/repository/index.js | 30 ++--- .../queries/pathLastCommit.query.graphql | 6 +- app/views/projects/_files.html.haml | 4 +- 5 files changed, 92 insertions(+), 85 deletions(-) (limited to 'app') diff --git a/app/assets/javascripts/lib/graphql.js b/app/assets/javascripts/lib/graphql.js index 5857f9e22ae..c05db4a5c71 100644 --- a/app/assets/javascripts/lib/graphql.js +++ b/app/assets/javascripts/lib/graphql.js @@ -22,7 +22,7 @@ export default (resolvers = {}, config = {}) => { return new ApolloClient({ link: ApolloLink.split( - operation => operation.getContext().hasUpload, + operation => operation.getContext().hasUpload || operation.getContext().isSingleRequest, createUploadLink(httpOptions), new BatchHttpLink(httpOptions), ), diff --git a/app/assets/javascripts/repository/components/last_commit.vue b/app/assets/javascripts/repository/components/last_commit.vue index f25cee9bb57..26493556063 100644 --- a/app/assets/javascripts/repository/components/last_commit.vue +++ b/app/assets/javascripts/repository/components/last_commit.vue @@ -1,10 +1,9 @@ diff --git a/app/assets/javascripts/repository/index.js b/app/assets/javascripts/repository/index.js index 6280977b05b..ea051eaa414 100644 --- a/app/assets/javascripts/repository/index.js +++ b/app/assets/javascripts/repository/index.js @@ -50,23 +50,19 @@ export default function setupVueRepositoryList() { }, }); - const commitEl = document.getElementById('js-last-commit'); - - if (commitEl) { - // eslint-disable-next-line no-new - new Vue({ - el: commitEl, - router, - apolloProvider, - render(h) { - return h(LastCommit, { - props: { - currentPath: this.$route.params.pathMatch, - }, - }); - }, - }); - } + // eslint-disable-next-line no-new + new Vue({ + el: document.getElementById('js-last-commit'), + router, + apolloProvider, + render(h) { + return h(LastCommit, { + props: { + currentPath: this.$route.params.pathMatch, + }, + }); + }, + }); return new Vue({ el, diff --git a/app/assets/javascripts/repository/queries/pathLastCommit.query.graphql b/app/assets/javascripts/repository/queries/pathLastCommit.query.graphql index 90901f54d54..3bdfd979fa4 100644 --- a/app/assets/javascripts/repository/queries/pathLastCommit.query.graphql +++ b/app/assets/javascripts/repository/queries/pathLastCommit.query.graphql @@ -2,8 +2,8 @@ query pathLastCommit($projectPath: ID!, $path: String, $ref: String!) { project(fullPath: $projectPath) { repository { tree(path: $path, ref: $ref) { - commit { - id + lastCommit { + sha title message webUrl @@ -13,7 +13,7 @@ query pathLastCommit($projectPath: ID!, $path: String, $ref: String!) { avatarUrl webUrl } - pipeline { + latestPipeline { detailedStatus { detailsPath icon diff --git a/app/views/projects/_files.html.haml b/app/views/projects/_files.html.haml index 2b0c3985755..6763513f9ae 100644 --- a/app/views/projects/_files.html.haml +++ b/app/views/projects/_files.html.haml @@ -9,7 +9,9 @@ .nav-block = 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 - if is_project_overview -- cgit v1.2.1