Skip to content

add left-pane file tree view and related templates #1704

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

aayushkdev
Copy link
Collaborator

@aayushkdev aayushkdev commented Jun 27, 2025

fix #1682

tree.webm

Summary/Goals of this change
The goal of this PR is to introduce a collapsible file tree panel in the left pane of the project resource view. This view allows users to explore the project's CodebaseResource in a more user friendly way.

  • Clicking the chevron next to a folder toggles a dropdown view of its immediate children in the tree (left pane).

    • If the children have already been fetched, they are simply shown or hidden without making another request.
    • Directories without any children are shown without a chevron and cannot be expanded.
    • This action only affects the left pane and does not update the right pane.
  • Clicking the folder name is intended to display the list of that folder’s children in the right pane. (Not yet implemented)

  • Clicking on a file is intended to show that individual file’s details or metadata in the right pane. (Not yet implemented)

Note: This pr depends on the parent_path field introduced in #1687. To ensure tests pass and the functionality works, I’ve temporarily duplicated the necessary parts of that change here. These changes will be removed once that pr is merged.

@aayushkdev aayushkdev force-pushed the 1682-left-pane-file-tree branch from 0ffbe25 to 6172941 Compare June 27, 2025 14:08
@aayushkdev aayushkdev requested review from tdruez, Copilot and AyanSinhaMahapatra and removed request for Copilot June 27, 2025 14:32
Copilot

This comment was marked as spam.

@aayushkdev
Copy link
Collaborator Author

Hey @AyanSinhaMahapatra @tdruez can I have a review of this pr

@aayushkdev aayushkdev force-pushed the 1682-left-pane-file-tree branch from 03842ca to 7b8ba33 Compare July 4, 2025 04:45
Copy link
Contributor

@tdruez tdruez left a comment

Choose a reason for hiding this comment

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

@aayushkdev Off to a good start, see my various comments for improvements.

The naming convention needs consistency:
resource_tree, file_tree, file_tree_panel, file-tree, CodebaseResourceTree, codebase_tree, Resource Tree
Let's use CodebaseResourceTree and resource_tree everywhere rather than "file...".

You can start the implementation of the left and right panels rendering.

scanpipe/urls.py Outdated
Comment on lines 244 to 248
path(
"project/<slug:slug>/codebase_tree/",
views.CodebaseResourceTreeView.as_view(),
name="file_tree",
),
Copy link
Contributor

Choose a reason for hiding this comment

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

Move this just after the project/<slug:slug>/codebase/", entry.

Copy link
Contributor

Choose a reason for hiding this comment

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

name="file_tree", is not consistent with codebase_tree and CodebaseResourceTreeView

Comment on lines 2588 to 2593
subdirs = CodebaseResource.objects.filter(
project=project,
parent_path=OuterRef("path"),
)

children = base_qs.annotate(has_children=Exists(subdirs))
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be refactored as a method of the QuerySet.

{% else %}
<div class="is-flex is-align-items-center ml-5 is-clickable">
<span class="icon is-small mr-1">
<i class="fas fa-file"></i>
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use far to enforce the visual distinction between files and directories.

<li class="mb-1">
{% if node.is_dir %}
<div class="tree-node is-flex is-align-items-center has-text-weight-semibold is-clickable px-1" data-folder{% if node.has_children %} data-target="{{ node.path|slugify }}" data-url="{% url 'file_tree' slug=project.slug %}?path={{ node.path }}"{% endif %}>
<span class="icon is-small chevron mr-1" data-chevron{% if not node.has_children %} style="visibility: hidden;"{% endif %}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Use is-invisible CSS class.

Comment on lines 7 to 9
.hidden {
display: none;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove and use is-hidden class instead.

Signed-off-by: Aayush Kumar <aayush214.kumar@gmail.com>
Signed-off-by: Aayush Kumar <aayush214.kumar@gmail.com>
Signed-off-by: Aayush Kumar <aayush214.kumar@gmail.com>
Signed-off-by: Aayush Kumar <aayush214.kumar@gmail.com>
Signed-off-by: Aayush Kumar <aayush214.kumar@gmail.com>
Signed-off-by: Aayush Kumar <aayush214.kumar@gmail.com>
@aayushkdev aayushkdev force-pushed the 1682-left-pane-file-tree branch from b1f8a7f to 3d1c4b7 Compare July 7, 2025 19:16
Signed-off-by: Aayush Kumar <aayush214.kumar@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a new View to return the immediate children of a path
2 participants