Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable multi root DnD #45428

Merged
merged 4 commits into from
Mar 13, 2018
Merged

enable multi root DnD #45428

merged 4 commits into from
Mar 13, 2018

Conversation

isidorn
Copy link
Contributor

@isidorn isidorn commented Mar 9, 2018

fixes #44554

Not the nicest code but gets the job done for multi select root DnD.
@bpasero please review and let me know if you know how to simplify this. Thanks!

@isidorn isidorn added this to the March 2018 milestone Mar 9, 2018
@bpasero
Copy link
Member

bpasero commented Mar 9, 2018

@isidorn thanks will do

@@ -817,7 +817,7 @@ export class FileDragAndDrop extends SimpleFileResourceDragAndDrop {
return true; // NewStatPlaceholders can not be moved
}

if (source.isRoot && (sources.length > 1 || target instanceof FileStat && !target.isRoot)) {
if (source.isRoot && target instanceof FileStat && !target.isRoot) {
return true; // Root folder can not be moved to a non root file stat. Do not allow root folder move when multi selection drag.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment needs an update too I think

uri: folders[index].uri
});
}
private doHandleRootDrop(roots: FileStat[], target: FileStat | Model): TPromise<void> {
Copy link
Member

@bpasero bpasero Mar 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be much easier here to do something like:

  • fill an array of roots that includes everything except the roots that are being dragged
  • find the index where to drop to (if target is model, the index is the length of the array)
  • add the roots that are being dragged into the array at the correct location
  • call workspace editing service with that array

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. This simplifies a bit. This was tackled via 5564db9

for (let index = 0; index < folders.length; index++) {
const data = {
name: folders[index].name,
uri: folders[index].uri
Copy link
Member

@bpasero bpasero Mar 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@isidorn also careful here, you are introducing a name property that previously might not have been there

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bpasero how can I check if the name was there previously?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@isidorn you don't need to, just leave name empty

@isidorn
Copy link
Contributor Author

isidorn commented Mar 13, 2018

Great, thanks for feedback. I feel like I have addressed all the issues -> merging

@isidorn isidorn merged commit 1e129fd into master Mar 13, 2018
@isidorn isidorn deleted the isidorn/multiRootDnD branch March 13, 2018 11:32
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow to DND multiple root-folders
2 participants