diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-09 06:42:22 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-09 06:42:22 +0300 |
commit | 7dd9256e5eac896fb422566376086a0befc79151 (patch) | |
tree | be65227875ddb0cff4961ae2d97380bbf64dd851 /app/assets/javascripts/graphql_shared | |
parent | 2295d352f6073101497f9bf4e4981c7ae72706a3 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/graphql_shared')
-rw-r--r-- | app/assets/javascripts/graphql_shared/fragments/iteration.fragment.graphql | 4 | ||||
-rw-r--r-- | app/assets/javascripts/graphql_shared/utils.js | 10 |
2 files changed, 12 insertions, 2 deletions
diff --git a/app/assets/javascripts/graphql_shared/fragments/iteration.fragment.graphql b/app/assets/javascripts/graphql_shared/fragments/iteration.fragment.graphql new file mode 100644 index 00000000000..78a368089a8 --- /dev/null +++ b/app/assets/javascripts/graphql_shared/fragments/iteration.fragment.graphql @@ -0,0 +1,4 @@ +fragment Iteration on Iteration { + id + title +} diff --git a/app/assets/javascripts/graphql_shared/utils.js b/app/assets/javascripts/graphql_shared/utils.js index 828ddd95ffc..e459ebf629f 100644 --- a/app/assets/javascripts/graphql_shared/utils.js +++ b/app/assets/javascripts/graphql_shared/utils.js @@ -15,6 +15,8 @@ export const isGid = (id) => { return false; }; +const parseGid = (gid) => parseInt(`${gid}`.replace(/gid:\/\/gitlab\/.*\//g, ''), 10); + /** * Ids generated by GraphQL endpoints are usually in the format * gid://gitlab/Environments/123. This method extracts Id number @@ -23,8 +25,12 @@ export const isGid = (id) => { * @param {String} gid GraphQL global ID * @returns {Number} */ -export const getIdFromGraphQLId = (gid = '') => - parseInt(`${gid}`.replace(/gid:\/\/gitlab\/.*\//g, ''), 10) || null; +export const getIdFromGraphQLId = (gid = '') => parseGid(gid) || null; + +export const getZeroBasedIdFromGraphQLId = (gid = '') => { + const parsedGid = parseGid(gid); + return Number.isInteger(parsedGid) ? parsedGid : null; +}; export const MutationOperationMode = { Append: 'APPEND', |