mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +00:00
Don't allow dragging into itself (Fixes #583)
This commit is contained in:
parent
d48d396aa2
commit
a5ce4d8f05
@ -937,11 +937,20 @@ function mapDispatchToProps (dispatch) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function _moveDoc (docToMove, parentId, targetId, targetOffset) {
|
async function _moveDoc (docToMove, parentId, targetId, targetOffset) {
|
||||||
|
// Nothing to do. We are in the same spot as we started
|
||||||
if (docToMove._id === targetId) {
|
if (docToMove._id === targetId) {
|
||||||
// Nothing to do. We are in the same spot as we started
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't allow dragging things into itself or children. This will disconnect
|
||||||
|
// the node from the tree and cause the item to no longer show in the UI.
|
||||||
|
const descendents = await db.withDescendants(docToMove);
|
||||||
|
for (const doc of descendents) {
|
||||||
|
if (doc._id === parentId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function __updateDoc (doc, patch) {
|
function __updateDoc (doc, patch) {
|
||||||
models.getModel(docToMove.type).update(doc, patch);
|
models.getModel(docToMove.type).update(doc, patch);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user