Commit 79b7cbd8 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'epic-boards-positions-fe' into 'master'

[frontend] Allow repositioning epics on epic boards

See merge request gitlab-org/gitlab!62845
parents 3d41663c 4b41a46e
import { sortBy } from 'lodash';
import { FiltersInfo as FiltersInfoCE } from '~/boards/boards_util';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { urlParamsToObject } from '~/lib/utils/common_utils';
......@@ -44,10 +43,9 @@ export function formatListEpics(listEpics) {
const listData = listEpics.nodes.reduce((map, list) => {
listItemsCount = list.epicsCount;
let sortedEpics = list.epics.edges.map((epicNode) => ({
const sortedEpics = list.epics.edges.map((epicNode) => ({
...epicNode.node,
}));
sortedEpics = sortBy(sortedEpics, 'relativePosition');
return {
...map,
......
......@@ -3,9 +3,18 @@ mutation EpicMoveList(
$boardId: BoardsEpicBoardID!
$fromListId: BoardsEpicListID!
$toListId: BoardsEpicListID!
$moveAfterId: EpicID
$moveBeforeId: EpicID
) {
epicMoveList(
input: { epicId: $epicId, boardId: $boardId, fromListId: $fromListId, toListId: $toListId }
input: {
epicId: $epicId
boardId: $boardId
fromListId: $fromListId
toListId: $toListId
moveAfterId: $moveAfterId
moveBeforeId: $moveBeforeId
}
) {
errors
}
......
......@@ -405,6 +405,8 @@ export default {
boardId: fullEpicBoardId(boardId),
fromListId,
toListId,
moveAfterId: moveAfterId ? fullEpicId(moveAfterId) : undefined,
moveBeforeId: moveBeforeId ? fullEpicId(moveBeforeId) : undefined,
},
})
.then(({ data }) => {
......
......@@ -87,14 +87,29 @@ RSpec.describe 'epic boards', :js do
expect(find('.board:nth-child(3) .board-card')).to have_content(epic3.title)
end
it 'moves epic between lists' do
expect(find('.board:nth-child(1)')).to have_content(epic3.title)
it 'moves to the bottom of another list' do
expect(find_board_list(1)).to have_content(epic3.title)
drag(list_from_index: 0, list_to_index: 1)
drag(list_from_index: 0, list_to_index: 1, to_index: 1)
wait_for_all_requests
expect(find_board_list(1)).not_to have_content(epic3.title)
expect(find_board_list(2)).to have_content(epic3.title)
page.within(find_board_list(2)) do
expect(all('.board-card')[1]).to have_content(epic3.title)
end
end
it 'moves to the top of another list' do
expect(find_board_list(1)).to have_content(epic3.title)
drag(list_from_index: 0, list_to_index: 1, to_index: 0)
wait_for_all_requests
expect(find_board_list(1)).not_to have_content(epic3.title)
page.within(find_board_list(2)) do
expect(all('.board-card')[0]).to have_content(epic3.title)
end
end
context 'lists' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment