diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-15 12:08:41 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-15 12:08:41 +0300 |
commit | 9c72b346ac3b24cca9233a6ebf298659b408513f (patch) | |
tree | a9ffdbce875ab94e09ff0e3ac737fbfecb86a0af /app/assets/javascripts/releases | |
parent | 2819fd258a456f0193a2e1ca9e7a54cee45b98cf (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/releases')
5 files changed, 111 insertions, 73 deletions
diff --git a/app/assets/javascripts/releases/queries/all_releases.query.graphql b/app/assets/javascripts/releases/queries/all_releases.query.graphql index e74b7769abe..c35306f163d 100644 --- a/app/assets/javascripts/releases/queries/all_releases.query.graphql +++ b/app/assets/javascripts/releases/queries/all_releases.query.graphql @@ -1,67 +1,10 @@ +#import "./release.fragment.graphql" + query allReleases($fullPath: ID!, $first: Int, $last: Int, $before: String, $after: String) { project(fullPath: $fullPath) { releases(first: $first, last: $last, before: $before, after: $after) { nodes { - name - tagName - tagPath - descriptionHtml - releasedAt - upcomingRelease - assets { - count - sources { - nodes { - format - url - } - } - links { - nodes { - id - name - url - directAssetUrl - linkType - external - } - } - } - evidences { - nodes { - filepath - collectedAt - sha - } - } - links { - editUrl - issuesUrl - mergeRequestsUrl - selfUrl - } - commit { - sha - webUrl - title - } - author { - webUrl - avatarUrl - username - } - milestones { - nodes { - id - title - description - webPath - stats { - totalIssuesCount - closedIssuesCount - } - } - } + ...Release } pageInfo { startCursor diff --git a/app/assets/javascripts/releases/queries/one_release.query.graphql b/app/assets/javascripts/releases/queries/one_release.query.graphql new file mode 100644 index 00000000000..b893aea94b0 --- /dev/null +++ b/app/assets/javascripts/releases/queries/one_release.query.graphql @@ -0,0 +1,9 @@ +#import "./release.fragment.graphql" + +query oneRelease($fullPath: ID!, $tagName: String!) { + project(fullPath: $fullPath) { + release(tagName: $tagName) { + ...Release + } + } +} diff --git a/app/assets/javascripts/releases/queries/release.fragment.graphql b/app/assets/javascripts/releases/queries/release.fragment.graphql new file mode 100644 index 00000000000..445ed616348 --- /dev/null +++ b/app/assets/javascripts/releases/queries/release.fragment.graphql @@ -0,0 +1,62 @@ +fragment Release on Release { + name + tagName + tagPath + descriptionHtml + releasedAt + upcomingRelease + assets { + count + sources { + nodes { + format + url + } + } + links { + nodes { + id + name + url + directAssetUrl + linkType + external + } + } + } + evidences { + nodes { + filepath + collectedAt + sha + } + } + links { + editUrl + issuesUrl + mergeRequestsUrl + selfUrl + } + commit { + sha + webUrl + title + } + author { + webUrl + avatarUrl + username + } + milestones { + nodes { + id + title + description + webPath + stats { + totalIssuesCount + closedIssuesCount + } + } + } +} diff --git a/app/assets/javascripts/releases/stores/modules/list/actions.js b/app/assets/javascripts/releases/stores/modules/list/actions.js index a7bb6a3a1d0..02e67415e63 100644 --- a/app/assets/javascripts/releases/stores/modules/list/actions.js +++ b/app/assets/javascripts/releases/stores/modules/list/actions.js @@ -8,7 +8,7 @@ import { convertObjectPropsToCamelCase, } from '~/lib/utils/common_utils'; import allReleasesQuery from '~/releases/queries/all_releases.query.graphql'; -import { gqClient, convertGraphQLResponse } from '../../../util'; +import { gqClient, convertAllReleasesGraphQLResponse } from '../../../util'; import { PAGE_SIZE } from '../../../constants'; /** @@ -64,7 +64,7 @@ export const fetchReleasesGraphQl = ( }, }) .then(response => { - const { data, paginationInfo: graphQlPageInfo } = convertGraphQLResponse(response); + const { data, paginationInfo: graphQlPageInfo } = convertAllReleasesGraphQLResponse(response); commit(types.RECEIVE_RELEASES_SUCCESS, { data, diff --git a/app/assets/javascripts/releases/util.js b/app/assets/javascripts/releases/util.js index e890b4b008d..445c429fd96 100644 --- a/app/assets/javascripts/releases/util.js +++ b/app/assets/javascripts/releases/util.js @@ -107,7 +107,24 @@ const convertMilestones = graphQLRelease => ({ }); /** - * Converts the response from the GraphQL endpoint into the + * Converts a single release object fetched from GraphQL + * into a release object that matches the shape of the REST API + * (the same shape that is returned by `apiJsonToRelease` above.) + * + * @param graphQLRelease The release object returned from a GraphQL query + */ +export const convertGraphQLRelease = graphQLRelease => ({ + ...convertScalarProperties(graphQLRelease), + ...convertAssets(graphQLRelease), + ...convertEvidences(graphQLRelease), + ...convertLinks(graphQLRelease), + ...convertCommit(graphQLRelease), + ...convertAuthor(graphQLRelease), + ...convertMilestones(graphQLRelease), +}); + +/** + * Converts the response from all_releases.query.graphql into the * same shape as is returned from the Releases REST API. * * This allows the release components to use the response @@ -115,16 +132,8 @@ const convertMilestones = graphQLRelease => ({ * * @param response The response received from the GraphQL endpoint */ -export const convertGraphQLResponse = response => { - const releases = response.data.project.releases.nodes.map(r => ({ - ...convertScalarProperties(r), - ...convertAssets(r), - ...convertEvidences(r), - ...convertLinks(r), - ...convertCommit(r), - ...convertAuthor(r), - ...convertMilestones(r), - })); +export const convertAllReleasesGraphQLResponse = response => { + const releases = response.data.project.releases.nodes.map(convertGraphQLRelease); const paginationInfo = { ...response.data.project.releases.pageInfo, @@ -132,3 +141,18 @@ export const convertGraphQLResponse = response => { return { data: releases, paginationInfo }; }; + +/** + * Converts the response from one_release.query.graphql into the + * same shape as is returned from the Releases REST API. + * + * This allows the release components to use the response + * from either endpoint interchangeably. + * + * @param response The response received from the GraphQL endpoint + */ +export const convertOneReleaseGraphQLResponse = response => { + const release = convertGraphQLRelease(response.data.project.release); + + return { data: release }; +}; |