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
2759adcb
Commit
2759adcb
authored
Jan 18, 2021
by
Florie Guibert
Committed by
Kushal Pandya
Jan 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Swimlanes - Creating an issue should add board scope to it
Create issue in board list adds board scope to it
parent
1622ac99
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
112 additions
and
5 deletions
+112
-5
app/assets/javascripts/boards/boards_util.js
app/assets/javascripts/boards/boards_util.js
+21
-1
app/assets/javascripts/boards/index.js
app/assets/javascripts/boards/index.js
+3
-1
app/assets/javascripts/boards/stores/actions.js
app/assets/javascripts/boards/stores/actions.js
+5
-1
ee/app/helpers/ee/boards_helper.rb
ee/app/helpers/ee/boards_helper.rb
+1
-0
ee/changelogs/unreleased/287713-swimlanes-creating-an-issue-should-add-board-scope-to-it.yml
...mlanes-creating-an-issue-should-add-board-scope-to-it.yml
+5
-0
spec/frontend/boards/stores/actions_spec.js
spec/frontend/boards/stores/actions_spec.js
+77
-2
No files found.
app/assets/javascripts/boards/boards_util.js
View file @
2759adcb
...
...
@@ -88,13 +88,33 @@ export function fullIterationId(id) {
return
`gid://gitlab/Iteration/
${
id
}
`
;
}
export
function
fullUserId
(
id
)
{
return
`gid://gitlab/User/
${
id
}
`
;
}
export
function
fullMilestoneId
(
id
)
{
return
`gid://gitlab/Milestone/
${
id
}
`
;
}
export
function
fullLabelId
(
label
)
{
if
(
label
.
project_id
!==
null
)
{
if
(
label
.
project_id
&&
label
.
project_id
!==
null
)
{
return
`gid://gitlab/ProjectLabel/
${
label
.
id
}
`
;
}
return
`gid://gitlab/GroupLabel/
${
label
.
id
}
`
;
}
export
function
formatIssueInput
(
issueInput
,
boardConfig
)
{
const
{
labelIds
=
[],
assigneeIds
=
[]
}
=
issueInput
;
const
{
labels
,
assigneeId
,
milestoneId
}
=
boardConfig
;
return
{
milestoneId
:
milestoneId
?
fullMilestoneId
(
milestoneId
)
:
null
,
...
issueInput
,
labelIds
:
[...
labelIds
,
...(
labels
?.
map
((
l
)
=>
fullLabelId
(
l
))
||
[])],
assigneeIds
:
[...
assigneeIds
,
...(
assigneeId
?
[
fullUserId
(
assigneeId
)]
:
[])],
};
}
export
function
moveIssueListHelper
(
issue
,
fromList
,
toList
)
{
const
updatedIssue
=
issue
;
if
(
...
...
app/assets/javascripts/boards/index.js
View file @
2759adcb
...
...
@@ -127,8 +127,10 @@ export default () => {
milestoneTitle
:
$boardApp
.
dataset
.
boardMilestoneTitle
||
''
,
iterationId
:
parseInt
(
$boardApp
.
dataset
.
boardIterationId
,
10
),
iterationTitle
:
$boardApp
.
dataset
.
boardIterationTitle
||
''
,
assigneeId
:
$boardApp
.
dataset
.
boardAssigneeId
,
assigneeUsername
:
$boardApp
.
dataset
.
boardAssigneeUsername
,
labels
:
$boardApp
.
dataset
.
labels
?
JSON
.
parse
(
$boardApp
.
dataset
.
labels
||
[])
:
[],
labels
:
$boardApp
.
dataset
.
labels
?
JSON
.
parse
(
$boardApp
.
dataset
.
labels
)
:
[],
labelIds
:
$boardApp
.
dataset
.
labelIds
?
JSON
.
parse
(
$boardApp
.
dataset
.
labelIds
)
:
[],
weight
:
$boardApp
.
dataset
.
boardWeight
?
parseInt
(
$boardApp
.
dataset
.
boardWeight
,
10
)
:
null
,
...
...
app/assets/javascripts/boards/stores/actions.js
View file @
2759adcb
...
...
@@ -12,6 +12,7 @@ import {
fullBoardId
,
formatListsPageInfo
,
formatIssue
,
formatIssueInput
,
updateListPosition
,
}
from
'
../boards_util
'
;
import
createFlash
from
'
~/flash
'
;
...
...
@@ -362,7 +363,10 @@ export default {
},
createNewIssue
:
({
commit
,
state
},
issueInput
)
=>
{
const
input
=
issueInput
;
const
{
boardConfig
}
=
state
;
const
input
=
formatIssueInput
(
issueInput
,
boardConfig
);
const
{
boardType
,
fullPath
}
=
state
;
if
(
boardType
===
BoardType
.
project
)
{
input
.
projectPath
=
fullPath
;
...
...
ee/app/helpers/ee/boards_helper.rb
View file @
2759adcb
...
...
@@ -21,6 +21,7 @@ module EE
board_iteration_title:
board
.
iteration
&
.
title
,
board_iteration_id:
board
.
iteration_id
,
board_assignee_username:
board
.
assignee
&
.
username
,
board_assignee_id:
board
.
assignee
&
.
id
,
label_ids:
board
.
label_ids
,
labels:
board
.
labels
.
to_json
(
only:
[
:id
,
:title
,
:color
,
:text_color
]
),
board_weight:
board
.
weight
,
...
...
ee/changelogs/unreleased/287713-swimlanes-creating-an-issue-should-add-board-scope-to-it.yml
0 → 100644
View file @
2759adcb
---
title
:
Swimlanes - Creating an issue adds board scope to it
merge_request
:
51675
author
:
type
:
fixed
spec/frontend/boards/stores/actions_spec.js
View file @
2759adcb
...
...
@@ -16,8 +16,14 @@ import * as types from '~/boards/stores/mutation_types';
import
{
inactiveId
}
from
'
~/boards/constants
'
;
import
issueMoveListMutation
from
'
~/boards/graphql/issue_move_list.mutation.graphql
'
;
import
destroyBoardListMutation
from
'
~/boards/graphql/board_list_destroy.mutation.graphql
'
;
import
issueCreateMutation
from
'
~/boards/graphql/issue_create.mutation.graphql
'
;
import
updateAssignees
from
'
~/vue_shared/components/sidebar/queries/updateAssignees.mutation.graphql
'
;
import
{
fullBoardId
,
formatListIssues
,
formatBoardLists
}
from
'
~/boards/boards_util
'
;
import
{
fullBoardId
,
formatListIssues
,
formatBoardLists
,
formatIssueInput
,
}
from
'
~/boards/boards_util
'
;
import
createFlash
from
'
~/flash
'
;
jest
.
mock
(
'
~/flash
'
);
...
...
@@ -728,6 +734,27 @@ describe('createNewIssue', () => {
const
state
=
{
boardType
:
'
group
'
,
fullPath
:
'
gitlab-org/gitlab
'
,
boardConfig
:
{
labelIds
:
[],
assigneeId
:
null
,
milestoneId
:
-
1
,
},
};
const
stateWithBoardConfig
=
{
boardConfig
:
{
labels
:
[
{
id
:
5
,
title
:
'
Test
'
,
color
:
'
#ff0000
'
,
description
:
'
testing;
'
,
textColor
:
'
white
'
,
},
],
assigneeId
:
2
,
milestoneId
:
3
,
},
};
it
(
'
should return issue from API on success
'
,
async
()
=>
{
...
...
@@ -744,11 +771,59 @@ describe('createNewIssue', () => {
expect
(
result
).
toEqual
(
mockIssue
);
});
it
(
'
should add board scope to the issue being created
'
,
async
()
=>
{
jest
.
spyOn
(
gqlClient
,
'
mutate
'
).
mockResolvedValue
({
data
:
{
createIssue
:
{
issue
:
mockIssue
,
errors
:
[],
},
},
});
await
actions
.
createNewIssue
({
state
:
stateWithBoardConfig
},
mockIssue
);
expect
(
gqlClient
.
mutate
).
toHaveBeenCalledWith
({
mutation
:
issueCreateMutation
,
variables
:
{
input
:
formatIssueInput
(
mockIssue
,
stateWithBoardConfig
.
boardConfig
),
},
});
});
it
(
'
should add board scope by merging attributes to the issue being created
'
,
async
()
=>
{
const
issue
=
{
...
mockIssue
,
assigneeIds
:
[
'
gid://gitlab/User/1
'
],
labelIds
:
[
'
gid://gitlab/GroupLabel/4
'
],
};
jest
.
spyOn
(
gqlClient
,
'
mutate
'
).
mockResolvedValue
({
data
:
{
createIssue
:
{
issue
,
errors
:
[],
},
},
});
const
payload
=
formatIssueInput
(
issue
,
stateWithBoardConfig
.
boardConfig
);
await
actions
.
createNewIssue
({
state
:
stateWithBoardConfig
},
issue
);
expect
(
gqlClient
.
mutate
).
toHaveBeenCalledWith
({
mutation
:
issueCreateMutation
,
variables
:
{
input
:
formatIssueInput
(
issue
,
stateWithBoardConfig
.
boardConfig
),
},
});
expect
(
payload
.
labelIds
).
toEqual
([
'
gid://gitlab/GroupLabel/4
'
,
'
gid://gitlab/GroupLabel/5
'
]);
expect
(
payload
.
assigneeIds
).
toEqual
([
'
gid://gitlab/User/1
'
,
'
gid://gitlab/User/2
'
]);
});
it
(
'
should commit CREATE_ISSUE_FAILURE mutation when API returns an error
'
,
(
done
)
=>
{
jest
.
spyOn
(
gqlClient
,
'
mutate
'
).
mockResolvedValue
({
data
:
{
createIssue
:
{
issue
:
{}
,
issue
:
mockIssue
,
errors
:
[{
foo
:
'
bar
'
}],
},
},
...
...
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