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

Files panel drag and drop support #7386

Closed
1 task done
sudomf opened this issue Feb 5, 2024 · 3 comments
Closed
1 task done

Files panel drag and drop support #7386

sudomf opened this issue Feb 5, 2024 · 3 comments
Labels
enhancement [core label] good first issue Issue suitable for first-time contributors project panel Feedback for files tree view

Comments

@sudomf
Copy link

sudomf commented Feb 5, 2024

Check for existing issues

  • Completed

Describe the feature

Add support to drop a file from Finder to the project's file panel and vice-versa.

If applicable, add mockups / screenshots to help present your vision of the feature

No response

@sudomf sudomf added admin read Pending admin review enhancement [core label] triage Maintainer needs to classify the issue labels Feb 5, 2024
@sudomf sudomf changed the title Files panel drag and drop dupport Files panel drag and drop support Feb 5, 2024
@JosephTLyons JosephTLyons added project panel Feedback for files tree view and removed triage Maintainer needs to classify the issue admin read Pending admin review labels Feb 6, 2024
@SomeoneToIgnore SomeoneToIgnore added the good first issue Issue suitable for first-time contributors label Feb 26, 2024
@SomeoneToIgnore
Copy link
Contributor

SomeoneToIgnore commented Feb 26, 2024

We can enable external file drag and drop with

diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs
index 413d42255..bdeb2780e 100644
--- a/crates/project_panel/src/project_panel.rs
+++ b/crates/project_panel/src/project_panel.rs
@@ -11,10 +11,10 @@ use anyhow::{anyhow, Result};
 use collections::{hash_map, HashMap};
 use gpui::{
     actions, div, overlay, px, uniform_list, Action, AppContext, AssetSource, AsyncWindowContext,
-    ClipboardItem, DismissEvent, Div, EventEmitter, FocusHandle, FocusableView, InteractiveElement,
-    KeyContext, Model, MouseButton, MouseDownEvent, ParentElement, Pixels, Point, PromptLevel,
-    Render, Stateful, Styled, Subscription, Task, UniformListScrollHandle, View, ViewContext,
-    VisualContext as _, WeakView, WindowContext,
+    ClipboardItem, DismissEvent, Div, EventEmitter, ExternalPaths, FocusHandle, FocusableView,
+    InteractiveElement, KeyContext, Model, MouseButton, MouseDownEvent, ParentElement, Pixels,
+    Point, PromptLevel, Render, Stateful, Styled, Subscription, Task, UniformListScrollHandle,
+    View, ViewContext, VisualContext as _, WeakView, WindowContext,
 };
 use menu::{Confirm, SelectNext, SelectPrev};
 use project::{
@@ -1556,6 +1556,15 @@ impl ProjectPanel {
         let depth = details.depth;
         div()
             .id(entry_id.to_proto() as usize)
+            .drag_over(|style, _: &ExternalPaths, cx| {
+                style.bg(cx.theme().colors().drop_target_background)
+            })
+            .on_drop(
+                cx.listener(move |project_panel, external_paths: &ExternalPaths, cx| {
+                    dbg!("Dropped on entry", external_paths, entry_id);
+                    cx.stop_propagation();
+                }),
+            )
             .on_drag(entry_id, move |entry_id, cx| {
                 cx.new_view(|_| DraggedProjectEntryView {
                     details: details.clone(),
@@ -1748,6 +1757,15 @@ impl Render for ProjectPanel {
                         })),
                 )
         }
+        .drag_over(|style, _: &ExternalPaths, cx| {
+            style.bg(cx.theme().colors().drop_target_background)
+        })
+        .on_drop(
+            cx.listener(move |project_panel, external_paths: &ExternalPaths, cx| {
+                dbg!("Empty panel space drop", external_paths);
+            }),
+        )
     }
 }
 

change, note cx.stop_propagation(); on the top level: this way, we catch the even on the item level and do not allow the underlying panel to react on that one too.
Also, style changes inside new drag_over additions seem to need more contrast between each other.

After that, we have to decide what to do with the file or directory: the code should be similar to move_entry except the fact that it does not move but recursively copies.

We might want to open files dropped this way in the editor.

@dwt
Copy link

dwt commented May 21, 2024

This should also enable drag'dropping a file to either the internal or an external terminal to reference the file path there.

bennetbo added a commit that referenced this issue Jun 13, 2024
Partially addresses #7386 



https://github.com/zed-industries/zed/assets/53836821/fc2e9864-40a8-4ada-ac95-a76a31c44437



Release Notes:

- Added support for dropping files from the finder onto the project
panel
ming900518 pushed a commit to ming900518/zed that referenced this issue Jun 14, 2024
@JosephTLyons
Copy link
Contributor

Bennet just landed a PR to address allow for dragging and dropping into the project panel, which feels like the bigger feature here. Let's close this issue out - if there is interest in dragging out of the project panel and into the system, let's open a new issue for users to vote on.

fallenwood pushed a commit to fallenwood/zed that referenced this issue Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement [core label] good first issue Issue suitable for first-time contributors project panel Feedback for files tree view
Projects
None yet
Development

No branches or pull requests

4 participants