-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Big refactor to tree rendering structure
DnD tree now converts the nested tree to a flat one and only consists of _1_ droppable area with a flat array of draggables that can be combined. Using the existing logic in the reducer combined with translating the flat structure changes to a format the nested reducer can understand looks like a really promising avenue. There still seems to be a bug with a longer list where items do not interact properly.
- Loading branch information
1 parent
d9ef80a
commit 3ccc16d
Showing
4 changed files
with
148 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
.../application/components/pipeline_processors_editor/components/drag_and_drop_tree/utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { DraggableLocation, ProcessorSelector } from '../../types'; | ||
|
||
export const mapDestinationIndexToTreeLocation = ( | ||
items: ProcessorSelector[], | ||
isRootLevelSource: boolean, | ||
destinationIndex: number | ||
): DraggableLocation => { | ||
// TODO: This needs to be vastly improved. | ||
const destinationSelector = items[destinationIndex]; | ||
const destinationProcessorsSelector = destinationSelector.slice(0, -1); | ||
|
||
if (destinationIndex === 0) { | ||
return { selector: [], index: 0 }; | ||
} | ||
|
||
if (destinationIndex === items.length - 1 && isRootLevelSource) { | ||
return { selector: [], index: items.length - 1 }; | ||
} | ||
|
||
return { | ||
selector: destinationProcessorsSelector, | ||
index: parseInt(destinationSelector[destinationSelector.length - 1], 10), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters