Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
86506bbc
Commit
86506bbc
authored
Nov 09, 2021
by
Florie Guibert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge getIdFromGraphQLId utils
parent
afd257ba
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
57 deletions
+5
-57
app/assets/javascripts/boards/components/board_form.vue
app/assets/javascripts/boards/components/board_form.vue
+3
-3
app/assets/javascripts/graphql_shared/utils.js
app/assets/javascripts/graphql_shared/utils.js
+1
-3
spec/frontend/graphql_shared/utils_spec.js
spec/frontend/graphql_shared/utils_spec.js
+1
-51
No files found.
app/assets/javascripts/boards/components/board_form.vue
View file @
86506bbc
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
import
{
GlModal
,
GlAlert
}
from
'
@gitlab/ui
'
;
import
{
GlModal
,
GlAlert
}
from
'
@gitlab/ui
'
;
import
{
mapGetters
,
mapActions
,
mapState
}
from
'
vuex
'
;
import
{
mapGetters
,
mapActions
,
mapState
}
from
'
vuex
'
;
import
{
TYPE_USER
,
TYPE_ITERATION
,
TYPE_MILESTONE
}
from
'
~/graphql_shared/constants
'
;
import
{
TYPE_USER
,
TYPE_ITERATION
,
TYPE_MILESTONE
}
from
'
~/graphql_shared/constants
'
;
import
{
convertToGraphQLId
,
get
ZeroBased
IdFromGraphQLId
}
from
'
~/graphql_shared/utils
'
;
import
{
convertToGraphQLId
,
getIdFromGraphQLId
}
from
'
~/graphql_shared/utils
'
;
import
{
getParameterByName
,
visitUrl
}
from
'
~/lib/utils/url_utility
'
;
import
{
getParameterByName
,
visitUrl
}
from
'
~/lib/utils/url_utility
'
;
import
{
__
,
s__
}
from
'
~/locale
'
;
import
{
__
,
s__
}
from
'
~/locale
'
;
import
{
fullLabelId
}
from
'
../boards_util
'
;
import
{
fullLabelId
}
from
'
../boards_util
'
;
...
@@ -169,11 +169,11 @@ export default {
...
@@ -169,11 +169,11 @@ export default {
:
null
,
:
null
,
// Temporarily converting to milestone ID due to https://gitlab.com/gitlab-org/gitlab/-/issues/344779
// Temporarily converting to milestone ID due to https://gitlab.com/gitlab-org/gitlab/-/issues/344779
milestoneId
:
this
.
board
.
milestone
?.
id
milestoneId
:
this
.
board
.
milestone
?.
id
?
convertToGraphQLId
(
TYPE_MILESTONE
,
get
ZeroBased
IdFromGraphQLId
(
this
.
board
.
milestone
.
id
))
?
convertToGraphQLId
(
TYPE_MILESTONE
,
getIdFromGraphQLId
(
this
.
board
.
milestone
.
id
))
:
null
,
:
null
,
// Temporarily converting to iteration ID due to https://gitlab.com/gitlab-org/gitlab/-/issues/344779
// Temporarily converting to iteration ID due to https://gitlab.com/gitlab-org/gitlab/-/issues/344779
iterationId
:
this
.
board
.
iteration
?.
id
iterationId
:
this
.
board
.
iteration
?.
id
?
convertToGraphQLId
(
TYPE_ITERATION
,
get
ZeroBased
IdFromGraphQLId
(
this
.
board
.
iteration
.
id
))
?
convertToGraphQLId
(
TYPE_ITERATION
,
getIdFromGraphQLId
(
this
.
board
.
iteration
.
id
))
:
null
,
:
null
,
};
};
},
},
...
...
app/assets/javascripts/graphql_shared/utils.js
View file @
86506bbc
...
@@ -25,9 +25,7 @@ const parseGid = (gid) => parseInt(`${gid}`.replace(/gid:\/\/gitlab\/.*\//g, '')
...
@@ -25,9 +25,7 @@ const parseGid = (gid) => parseInt(`${gid}`.replace(/gid:\/\/gitlab\/.*\//g, '')
* @param {String} gid GraphQL global ID
* @param {String} gid GraphQL global ID
* @returns {Number}
* @returns {Number}
*/
*/
export
const
getIdFromGraphQLId
=
(
gid
=
''
)
=>
parseGid
(
gid
)
||
null
;
export
const
getIdFromGraphQLId
=
(
gid
=
''
)
=>
{
export
const
getZeroBasedIdFromGraphQLId
=
(
gid
=
''
)
=>
{
const
parsedGid
=
parseGid
(
gid
);
const
parsedGid
=
parseGid
(
gid
);
return
Number
.
isInteger
(
parsedGid
)
?
parsedGid
:
null
;
return
Number
.
isInteger
(
parsedGid
)
?
parsedGid
:
null
;
};
};
...
...
spec/frontend/graphql_shared/utils_spec.js
View file @
86506bbc
import
{
import
{
isGid
,
isGid
,
getIdFromGraphQLId
,
getIdFromGraphQLId
,
getZeroBasedIdFromGraphQLId
,
convertToGraphQLId
,
convertToGraphQLId
,
convertToGraphQLIds
,
convertToGraphQLIds
,
convertFromGraphQLIds
,
convertFromGraphQLIds
,
...
@@ -54,7 +53,7 @@ describe('getIdFromGraphQLId', () => {
...
@@ -54,7 +53,7 @@ describe('getIdFromGraphQLId', () => {
},
},
{
{
input
:
'
gid://gitlab/Environments/0
'
,
input
:
'
gid://gitlab/Environments/0
'
,
output
:
null
,
output
:
0
,
},
},
{
{
input
:
'
gid://gitlab/Environments/123
'
,
input
:
'
gid://gitlab/Environments/123
'
,
...
@@ -71,55 +70,6 @@ describe('getIdFromGraphQLId', () => {
...
@@ -71,55 +70,6 @@ describe('getIdFromGraphQLId', () => {
});
});
});
});
describe
(
'
getZeroBasedIdFromGraphQLId
'
,
()
=>
{
[
{
input
:
''
,
output
:
null
,
},
{
input
:
null
,
output
:
null
,
},
{
input
:
2
,
output
:
2
,
},
{
input
:
'
gid://
'
,
output
:
null
,
},
{
input
:
'
gid://gitlab/
'
,
output
:
null
,
},
{
input
:
'
gid://gitlab/Environments
'
,
output
:
null
,
},
{
input
:
'
gid://gitlab/Environments/
'
,
output
:
null
,
},
{
input
:
'
gid://gitlab/Environments/0
'
,
output
:
0
,
},
{
input
:
'
gid://gitlab/Environments/123
'
,
output
:
123
,
},
{
input
:
'
gid://gitlab/DesignManagement::Version/2
'
,
output
:
2
,
},
].
forEach
(({
input
,
output
})
=>
{
it
(
`getZeroBasedIdFromGraphQLId returns
${
output
}
when passed
${
input
}
`
,
()
=>
{
expect
(
getZeroBasedIdFromGraphQLId
(
input
)).
toBe
(
output
);
});
});
});
describe
(
'
convertToGraphQLId
'
,
()
=>
{
describe
(
'
convertToGraphQLId
'
,
()
=>
{
it
(
'
combines $type and $id into $result
'
,
()
=>
{
it
(
'
combines $type and $id into $result
'
,
()
=>
{
expect
(
convertToGraphQLId
(
mockType
,
mockId
)).
toBe
(
mockGid
);
expect
(
convertToGraphQLId
(
mockType
,
mockId
)).
toBe
(
mockGid
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment