-
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
Open
aayushkdev
wants to merge
12
commits into
aboutcode-org:main
Choose a base branch
from
aayushkdev:1682-left-pane-file-tree
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+232
−2
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
1047b49
add left-pane file tree view and related templates
aayushkdev 173d5c7
temporarily include parent_path field from previous pr for tests
aayushkdev 92c7f65
Some formatting changes
aayushkdev 84ad1bf
bump migration up to resolve failing tests
aayushkdev 3119e50
remove conflicting migration
aayushkdev f049d5a
implement suggested changes
aayushkdev 76ee26e
fix code format
aayushkdev 5eb1648
use instead of None to follow code format
aayushkdev 7414e60
update save function so tests pass
aayushkdev aca7d49
add suggested improvements
aayushkdev fd21c80
refactor tests
aayushkdev 154d1a6
fix code format
aayushkdev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
scanpipe/migrations/0075_codebaseresource_parent_path_and_more.py
This file contains hidden or 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,24 @@ | ||
# Generated by Django 5.1.9 on 2025-06-19 21:19 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('scanpipe', '0074_discovered_license_models'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='codebaseresource', | ||
name='parent_path', | ||
field=models.CharField(blank=True, help_text="The path of the resource's parent directory. Set to None for top-level (root) resources. Used to efficiently retrieve a directory's contents.", max_length=2000, null=True), | ||
), | ||
migrations.AddIndex( | ||
model_name='codebaseresource', | ||
index=models.Index(fields=['project', 'parent_path'], name='scanpipe_co_project_008448_idx'), | ||
), | ||
] | ||
|
||
|
This file contains hidden or 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
29 changes: 29 additions & 0 deletions
29
scanpipe/templates/scanpipe/panels/codebase_tree_panel.html
This file contains hidden or 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,29 @@ | ||
<ul class="pl-2"> | ||
{% for node in children %} | ||
<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 'codebase_resource_tree' slug=project.slug %}?path={{ node.path }}"{% endif %}> | ||
<span class="icon is-small chevron mr-1{% if not node.has_children %} is-invisible{% endif %}" data-chevron> | ||
<i class="fas fa-chevron-right"></i> | ||
</span> | ||
<span class="is-flex is-align-items-center folder-meta"> | ||
<span class="icon is-small mr-1"> | ||
<i class="fas fa-folder"></i> | ||
</span> | ||
<span>{{ node.name }}</span> | ||
</span> | ||
</div> | ||
{% if node.has_children %} | ||
<div id="dir-{{ node.path|slugify }}" class="ml-4 is-hidden" data-loaded="false"></div> | ||
{% endif %} | ||
{% else %} | ||
<div class="is-flex is-align-items-center ml-5 is-clickable"> | ||
<span class="icon is-small mr-1"> | ||
<i class="far fa-file"></i> | ||
</span> | ||
<span>{{ node.name }}</span> | ||
</div> | ||
{% endif %} | ||
</li> | ||
{% endfor %} | ||
</ul> |
This file contains hidden or 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,67 @@ | ||
{% extends "scanpipe/base.html" %} | ||
{% load static humanize %} | ||
{% block title %}ScanCode.io: {{ project.name }} - Resource Tree{% endblock %} | ||
|
||
{% block extrahead %} | ||
<style> | ||
.chevron { | ||
transition: transform 0.2s ease; | ||
display: inline-block; | ||
} | ||
.chevron.rotated { | ||
transform: rotate(90deg); | ||
} | ||
</style> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div id="content-header" class="container is-max-widescreen mb-3"> | ||
{% include 'scanpipe/includes/navbar_header.html' %} | ||
<section class="mx-5"> | ||
<div class="is-flex is-justify-content-space-between"> | ||
{% include 'scanpipe/includes/breadcrumb.html' with linked_project=True current="Resource Tree" %} | ||
</div> | ||
</section> | ||
</div> | ||
|
||
<div class="columns is-gapless is-mobile" style="height: 80vh; margin: 0;"> | ||
<div class="column is-one-third p-4" style="border-right: 1px solid #ccc; overflow-y: auto;"> | ||
<div id="resource-tree"> | ||
{% include "scanpipe/panels/codebase_tree_panel.html" with children=children path=path %} | ||
</div> | ||
</div> | ||
<div class="column p-4" style="overflow-y: auto;"> | ||
<div id="right-pane"> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} | ||
|
||
{% block scripts %} | ||
<script> | ||
document.addEventListener("click", async function (e) { | ||
const chevron = e.target.closest("[data-chevron]"); | ||
if (chevron) { | ||
const folderNode = chevron.closest("[data-folder]"); | ||
const targetId = folderNode.dataset.target; | ||
const url = folderNode.dataset.url; | ||
const icon = chevron.querySelector("i"); | ||
const target = document.getElementById("dir-" + targetId); | ||
|
||
if (target.dataset.loaded === "true") { | ||
target.classList.toggle("is-hidden"); | ||
} else { | ||
target.classList.remove("is-hidden"); | ||
const response = await fetch(url + "&tree_panel=true"); | ||
target.innerHTML = await response.text(); | ||
target.dataset.loaded = "true"; | ||
htmx.process(target); | ||
} | ||
|
||
chevron.classList.toggle("rotated"); | ||
e.stopPropagation(); | ||
return; | ||
} | ||
}); | ||
</script> | ||
{% endblock %} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.