diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-01 18:10:05 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-01 18:10:05 +0300 |
commit | d57e27ef353787dac501d6970c546c9d86dd1f88 (patch) | |
tree | 89044194e81f95aaa15ace8a5d6a5b429179965f /app/assets/javascripts/repository | |
parent | a27b8a5c104f492e4b0abac4c84385a615c4f6ba (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/repository')
-rw-r--r-- | app/assets/javascripts/repository/index.js | 56 | ||||
-rw-r--r-- | app/assets/javascripts/repository/queries/path_last_commit.query.graphql | 9 |
2 files changed, 51 insertions, 14 deletions
diff --git a/app/assets/javascripts/repository/index.js b/app/assets/javascripts/repository/index.js index 65da8f70b40..1d6749654f5 100644 --- a/app/assets/javascripts/repository/index.js +++ b/app/assets/javascripts/repository/index.js @@ -12,12 +12,17 @@ import { setTitle } from './utils/title'; import { updateFormAction } from './utils/dom'; import { convertObjectPropsToCamelCase, parseBoolean } from '../lib/utils/common_utils'; import { __ } from '../locale'; +import PathLastCommitQuery from './queries/path_last_commit.query.graphql'; export default function setupVueRepositoryList() { const el = document.getElementById('js-tree-list'); const { dataset } = el; const { projectPath, projectShortPath, ref, escapedRef, fullName } = dataset; const router = createRouter(projectPath, escapedRef); + const pathRegex = /-\/tree\/[^/]+\/(.+$)/; + const matches = window.location.href.match(pathRegex); + + const currentRoutePath = matches ? matches[1] : ''; apolloProvider.clients.defaultClient.cache.writeData({ data: { @@ -29,6 +34,43 @@ export default function setupVueRepositoryList() { }, }); + const initLastCommitApp = () => + new Vue({ + el: document.getElementById('js-last-commit'), + router, + apolloProvider, + render(h) { + return h(LastCommit, { + props: { + currentPath: this.$route.params.path, + }, + }); + }, + }); + + if (window.gl.startup_graphql_calls) { + const query = window.gl.startup_graphql_calls.find( + call => call.operationName === 'pathLastCommit', + ); + query.fetchCall + .then(res => res.json()) + .then(res => { + apolloProvider.clients.defaultClient.writeQuery({ + query: PathLastCommitQuery, + data: res.data, + variables: { + projectPath, + ref, + path: currentRoutePath, + }, + }); + }) + .catch(() => {}) + .finally(() => initLastCommitApp()); + } else { + initLastCommitApp(); + } + router.afterEach(({ params: { path } }) => { setTitle(path, ref, fullName); }); @@ -77,20 +119,6 @@ export default function setupVueRepositoryList() { }); } - // 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.path, - }, - }); - }, - }); - const treeHistoryLinkEl = document.getElementById('js-tree-history-link'); const { historyLink } = treeHistoryLinkEl.dataset; diff --git a/app/assets/javascripts/repository/queries/path_last_commit.query.graphql b/app/assets/javascripts/repository/queries/path_last_commit.query.graphql index 51f3f790a5d..d845f7c6224 100644 --- a/app/assets/javascripts/repository/queries/path_last_commit.query.graphql +++ b/app/assets/javascripts/repository/queries/path_last_commit.query.graphql @@ -1,8 +1,12 @@ query pathLastCommit($projectPath: ID!, $path: String, $ref: String!) { project(fullPath: $projectPath) { + __typename repository { + __typename tree(path: $path, ref: $ref) { + __typename lastCommit { + __typename sha title titleHtml @@ -13,15 +17,20 @@ query pathLastCommit($projectPath: ID!, $path: String, $ref: String!) { authorName authorGravatar author { + __typename name avatarUrl webPath } signatureHtml pipelines(ref: $ref, first: 1) { + __typename edges { + __typename node { + __typename detailedStatus { + __typename detailsPath icon tooltip |