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
d3d903e3
Commit
d3d903e3
authored
May 05, 2020
by
Florie Guibert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Epic tree move child with drag and drop
- Review feedback
parent
dc37bb2c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
49 deletions
+36
-49
ee/app/assets/javascripts/related_items_tree/components/tree_root.vue
...s/javascripts/related_items_tree/components/tree_root.vue
+1
-1
ee/app/assets/javascripts/related_items_tree/store/actions.js
...pp/assets/javascripts/related_items_tree/store/actions.js
+2
-2
ee/spec/frontend/related_items_tree/store/actions_spec.js
ee/spec/frontend/related_items_tree/store/actions_spec.js
+20
-28
ee/spec/frontend/related_items_tree/store/mutations_spec.js
ee/spec/frontend/related_items_tree/store/mutations_spec.js
+13
-18
No files found.
ee/app/assets/javascripts/related_items_tree/components/tree_root.vue
View file @
d3d903e3
...
@@ -51,7 +51,7 @@ export default {
...
@@ -51,7 +51,7 @@ export default {
},
},
onMove
(
e
)
{
onMove
(
e
)
{
const
item
=
e
.
relatedContext
.
element
;
const
item
=
e
.
relatedContext
.
element
;
if
(
item
&&
item
.
type
&&
item
.
type
===
ChildType
.
Epic
)
if
(
item
?
.
type
===
ChildType
.
Epic
)
this
.
toggleItem
({
this
.
toggleItem
({
parentItem
:
item
,
parentItem
:
item
,
isDragging
:
true
,
isDragging
:
true
,
...
...
ee/app/assets/javascripts/related_items_tree/store/actions.js
View file @
d3d903e3
...
@@ -470,9 +470,9 @@ export const moveItem = (
...
@@ -470,9 +470,9 @@ export const moveItem = (
let
isFirstChild
=
false
;
let
isFirstChild
=
false
;
const
newParentChildren
=
state
.
children
[
newParentItem
.
parentReference
];
const
newParentChildren
=
state
.
children
[
newParentItem
.
parentReference
];
if
(
newParentChildren
!==
undefined
&&
newParentChildren
.
length
>
0
)
{
if
(
newParentChildren
?
.
length
>
0
)
{
adjacentItem
=
newParentChildren
[
newIndex
];
adjacentItem
=
newParentChildren
[
newIndex
];
if
(
adjacentItem
===
undefined
)
{
if
(
!
adjacentItem
)
{
adjacentItem
=
newParentChildren
[
newParentChildren
.
length
-
1
];
adjacentItem
=
newParentChildren
[
newParentChildren
.
length
-
1
];
relativePosition
=
relativePositions
.
Before
;
relativePosition
=
relativePositions
.
Before
;
}
}
...
...
ee/spec/frontend/related_items_tree/store/actions_spec.js
View file @
d3d903e3
...
@@ -1379,15 +1379,17 @@ describe('RelatedItemTree', () => {
...
@@ -1379,15 +1379,17 @@ describe('RelatedItemTree', () => {
}),
}),
);
);
const
payload
=
{
oldParentItem
:
mockParentItem
,
newParentItem
:
mockParentItem2
,
targetItem
:
mockItems
[
1
],
newIndex
:
1
,
oldIndex
:
0
,
};
testAction
(
testAction
(
actions
.
moveItem
,
actions
.
moveItem
,
{
payload
,
oldParentItem
:
mockParentItem
,
newParentItem
:
mockParentItem2
,
targetItem
:
mockItems
[
1
],
newIndex
:
1
,
oldIndex
:
0
,
},
state
,
state
,
[
[
{
{
...
@@ -1405,13 +1407,7 @@ describe('RelatedItemTree', () => {
...
@@ -1405,13 +1407,7 @@ describe('RelatedItemTree', () => {
[
[
{
{
type
:
'
receiveMoveItemFailure
'
,
type
:
'
receiveMoveItemFailure
'
,
payload
:
{
payload
,
oldParentItem
:
mockParentItem
,
newParentItem
:
mockParentItem2
,
targetItem
:
mockItems
[
1
],
newIndex
:
1
,
oldIndex
:
0
,
},
},
},
],
],
);
);
...
@@ -1420,15 +1416,17 @@ describe('RelatedItemTree', () => {
...
@@ -1420,15 +1416,17 @@ describe('RelatedItemTree', () => {
it
(
'
should perform MOVE_ITEM mutation before request and dispatch `receiveReorderItemFailure` on request failure
'
,
()
=>
{
it
(
'
should perform MOVE_ITEM mutation before request and dispatch `receiveReorderItemFailure` on request failure
'
,
()
=>
{
jest
.
spyOn
(
epicUtils
.
gqClient
,
'
mutate
'
).
mockReturnValue
(
Promise
.
reject
());
jest
.
spyOn
(
epicUtils
.
gqClient
,
'
mutate
'
).
mockReturnValue
(
Promise
.
reject
());
const
payload
=
{
oldParentItem
:
mockParentItem
,
newParentItem
:
mockParentItem2
,
targetItem
:
mockItems
[
1
],
newIndex
:
1
,
oldIndex
:
0
,
};
testAction
(
testAction
(
actions
.
moveItem
,
actions
.
moveItem
,
{
payload
,
oldParentItem
:
mockParentItem
,
newParentItem
:
mockParentItem2
,
targetItem
:
mockItems
[
1
],
newIndex
:
1
,
oldIndex
:
0
,
},
state
,
state
,
[
[
{
{
...
@@ -1446,13 +1444,7 @@ describe('RelatedItemTree', () => {
...
@@ -1446,13 +1444,7 @@ describe('RelatedItemTree', () => {
[
[
{
{
type
:
'
receiveMoveItemFailure
'
,
type
:
'
receiveMoveItemFailure
'
,
payload
:
{
payload
,
oldParentItem
:
mockParentItem
,
newParentItem
:
mockParentItem2
,
targetItem
:
mockItems
[
1
],
newIndex
:
1
,
oldIndex
:
0
,
},
},
},
],
],
);
);
...
...
ee/spec/frontend/related_items_tree/store/mutations_spec.js
View file @
d3d903e3
...
@@ -565,6 +565,16 @@ describe('RelatedItemsTree', () => {
...
@@ -565,6 +565,16 @@ describe('RelatedItemsTree', () => {
});
});
describe
(
types
.
MOVE_ITEM
,
()
=>
{
describe
(
types
.
MOVE_ITEM
,
()
=>
{
const
defaultPayload
=
{
oldParentItem
:
{
reference
:
'
&1
'
,
},
targetItem
:
'
bar
'
,
oldIndex
:
1
,
newIndex
:
0
,
isFirstChild
:
false
,
};
it
(
'
should move an item from one parent to another with children based on provided indexes
'
,
()
=>
{
it
(
'
should move an item from one parent to another with children based on provided indexes
'
,
()
=>
{
const
newParentItem
=
{
const
newParentItem
=
{
parentReference
:
'
&2
'
,
parentReference
:
'
&2
'
,
...
@@ -574,14 +584,8 @@ describe('RelatedItemsTree', () => {
...
@@ -574,14 +584,8 @@ describe('RelatedItemsTree', () => {
state
.
children
[
newParentItem
.
parentReference
]
=
[
'
baz
'
];
state
.
children
[
newParentItem
.
parentReference
]
=
[
'
baz
'
];
mutations
[
types
.
MOVE_ITEM
](
state
,
{
mutations
[
types
.
MOVE_ITEM
](
state
,
{
oldParentItem
:
{
...
defaultPayload
,
reference
:
'
&1
'
,
},
newParentItem
,
newParentItem
,
targetItem
:
'
bar
'
,
oldIndex
:
1
,
newIndex
:
0
,
isFirstChild
:
false
,
});
});
expect
(
state
.
children
[
state
.
parentItem
.
reference
]).
toEqual
(
expect
(
state
.
children
[
state
.
parentItem
.
reference
]).
toEqual
(
...
@@ -600,13 +604,8 @@ describe('RelatedItemsTree', () => {
...
@@ -600,13 +604,8 @@ describe('RelatedItemsTree', () => {
state
.
children
[
state
.
parentItem
.
reference
]
=
[
'
foo
'
,
'
bar
'
];
state
.
children
[
state
.
parentItem
.
reference
]
=
[
'
foo
'
,
'
bar
'
];
mutations
[
types
.
MOVE_ITEM
](
state
,
{
mutations
[
types
.
MOVE_ITEM
](
state
,
{
oldParentItem
:
{
...
defaultPayload
,
reference
:
'
&1
'
,
},
newParentItem
,
newParentItem
,
targetItem
:
'
bar
'
,
oldIndex
:
1
,
newIndex
:
0
,
isFirstChild
:
true
,
isFirstChild
:
true
,
});
});
...
@@ -627,13 +626,9 @@ describe('RelatedItemsTree', () => {
...
@@ -627,13 +626,9 @@ describe('RelatedItemsTree', () => {
state
.
childrenFlags
[
state
.
parentItem
.
reference
]
=
{
itemHasChildren
:
true
};
state
.
childrenFlags
[
state
.
parentItem
.
reference
]
=
{
itemHasChildren
:
true
};
mutations
[
types
.
MOVE_ITEM
](
state
,
{
mutations
[
types
.
MOVE_ITEM
](
state
,
{
oldParentItem
:
{
...
defaultPayload
,
reference
:
'
&1
'
,
},
newParentItem
,
newParentItem
,
targetItem
:
'
bar
'
,
oldIndex
:
0
,
oldIndex
:
0
,
newIndex
:
0
,
isFirstChild
:
true
,
isFirstChild
:
true
,
});
});
...
...
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