-
Notifications
You must be signed in to change notification settings - Fork 111
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
base: main
Are you sure you want to change the base?
Add left-pane file tree view and related templates #1704
Conversation
0ffbe25
to
6172941
Compare
Hey @AyanSinhaMahapatra @tdruez can I have a review of this pr |
03842ca
to
7b8ba33
Compare
There was a problem hiding this 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.
b1f8a7f
to
3d1c4b7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comments for refinements.
Once done with those, you can continue the implementation of
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)
scanpipe/tests/test_views.py
Outdated
url = reverse("codebase_resource_tree", kwargs={"slug": self.project1.slug}) | ||
response = self.client.get(url) | ||
children = response.context["children"] | ||
print(response.context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leftover.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aayushkdev The current code is fine, you can implement the missing parts before the next review round.
scanpipe/tests/test_models.py
Outdated
CodebaseResource.objects.create( | ||
project=project1, | ||
type=CodebaseResource.Type.DIRECTORY, | ||
path="parent", | ||
) | ||
CodebaseResource.objects.create( | ||
project=project1, | ||
type=CodebaseResource.Type.FILE, | ||
path="parent/child.txt", | ||
) | ||
CodebaseResource.objects.create( | ||
project=project1, | ||
type=CodebaseResource.Type.DIRECTORY, | ||
path="empty", | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use make_resource
, make_resource_file
, make_resource_directory
intead.
scanpipe/tests/test_models.py
Outdated
qs = CodebaseResource.objects.filter(project=project1).with_has_children() | ||
results = {r.path: r.has_children for r in qs} | ||
self.assertTrue(results["parent"]) | ||
self.assertFalse(results["parent/child.txt"]) | ||
self.assertFalse(results["empty"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You want to simplify this. Store the resource in variuable and test directly on the instance.
Better readability:
self.assertTrue(resource1.has_children())
Signed-off-by: Aayush Kumar <[email protected]>
Signed-off-by: Aayush Kumar <[email protected]>
Signed-off-by: Aayush Kumar <[email protected]>
Signed-off-by: Aayush Kumar <[email protected]>
Signed-off-by: Aayush Kumar <[email protected]>
Signed-off-by: Aayush Kumar <[email protected]>
Signed-off-by: Aayush Kumar <[email protected]>
Signed-off-by: Aayush Kumar <[email protected]>
Signed-off-by: Aayush Kumar <[email protected]>
Signed-off-by: Aayush Kumar <[email protected]>
Signed-off-by: Aayush Kumar <[email protected]>
Signed-off-by: Aayush Kumar <[email protected]>
e20208a
to
154d1a6
Compare
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).
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.