Skip to content

Commit 95c89c5

Browse files
committed
Simplify the ProjectResourceTreeTableView
Signed-off-by: tdruez <[email protected]>
1 parent b7b82f9 commit 95c89c5

File tree

5 files changed

+132
-158
lines changed

5 files changed

+132
-158
lines changed

scancodeio/static/main.css

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ body.full-screen #resource-viewer .message-header {
484484
}
485485

486486
#resource-tree-container .resizable-container {
487-
height: calc(100vh - 140px);
487+
min-height: calc(100vh - 140px);
488488
}
489489
#resource-tree-container .chevron {
490490
transition: transform 0.2s ease;
@@ -535,11 +535,6 @@ body.full-screen #resource-viewer .message-header {
535535
transition: opacity 0.2s ease;
536536
height: 100%;
537537
}
538-
#resource-tree-container .right-pane .table-scroll-area {
539-
flex: 1;
540-
overflow-y: auto;
541-
overflow-x: hidden;
542-
}
543538
#resource-tree-container .right-pane.collapsed {
544539
opacity: 0;
545540
pointer-events: none;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<div id="right-pane-header" class="mb-2">
2+
{% include 'scanpipe/tree/resource_path_breadcrumb.html' %}
3+
</div>
4+
<div id="right-pane-content">
5+
{% include 'scanpipe/tree/resource_table.html' %}
6+
</div>

scanpipe/templates/scanpipe/tree/resource_right_pane_table.html

Lines changed: 0 additions & 131 deletions
This file was deleted.
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
{% if resources %}
2+
<table class="table is-bordered is-hoverable is-fullwidth">
3+
<thead class="is-sticky">
4+
<tr>
5+
<th>Name</th>
6+
<th>Status</th>
7+
<th>Language</th>
8+
<th>License</th>
9+
<th>Alert</th>
10+
</tr>
11+
</thead>
12+
<tbody>
13+
{% if parent_path %}
14+
<tr
15+
class="expand-in-tree is-clickable"
16+
data-path="{{ parent_path }}"
17+
hx-get="{% url 'project_resource_tree_table' project.slug %}{% if parent_path %}?path={{ parent_path }}{% endif %}"
18+
hx-target="#right-pane"
19+
hx-push-url="{% url 'project_resource_tree' project.slug %}{% if parent_path %}?path={{ parent_path }}{% endif %}">
20+
<td colspan="5">
21+
<div class="is-flex is-align-items-center">
22+
<span class="icon is-small mr-2">
23+
<i class="fas fa-folder"></i>
24+
</span>
25+
<span class="has-text-weight-semibold">..</span>
26+
</div>
27+
</td>
28+
</tr>
29+
{% endif %}
30+
{% for resource in resources %}
31+
<tr>
32+
<td class="break-all" style="min-width: 100px;">
33+
<div class="is-flex is-align-items-center">
34+
<span class="icon is-small mr-2">
35+
{% if resource.is_dir %}
36+
<i class="fas fa-folder"></i>
37+
{% else %}
38+
<i class="far fa-file"></i>
39+
{% endif %}
40+
</span>
41+
{% if resource.is_dir %}
42+
<a
43+
class="expand-in-tree"
44+
href="{% url 'project_resource_tree' project.slug %}?path={{ resource.path }}"
45+
data-path="{{ resource.path }}"
46+
hx-get="{% url 'project_resource_tree_table' project.slug %}?path={{ resource.path }}"
47+
hx-target="#right-pane"
48+
hx-push-url="{% url 'project_resource_tree' project.slug %}?path={{ resource.path }}">
49+
{{ resource.name }}
50+
</a>
51+
{% else %}
52+
<a
53+
href="{% url 'resource_detail' project.slug resource.path %}"
54+
hx-get="{% url 'resource_detail' project.slug resource.path %}"
55+
hx-target="#right-pane-content"
56+
hx-push-url="{% url 'project_resource_tree' project.slug %}?path={{ resource.path }}">
57+
{{ resource.name }}
58+
</a>
59+
{% endif %}
60+
{% if resource.tag %}
61+
<span class="tag is-rounded ml-2">{{ resource.tag }}</span>
62+
{% endif %}
63+
</div>
64+
</td>
65+
<td>
66+
{{ resource.status }}
67+
</td>
68+
<td class="break-all">
69+
{{ resource.programming_language }}
70+
</td>
71+
<td>
72+
{{ resource.detected_license_expression }}
73+
</td>
74+
<td>
75+
{{ resource.compliance_alert }}
76+
</td>
77+
</tr>
78+
{% endfor %}
79+
</tbody>
80+
</table>
81+
82+
{% if is_paginated %}
83+
<nav class="pagination is-centered mt-4" role="navigation">
84+
{% if page_obj.has_previous %}
85+
<a
86+
class="pagination-previous"
87+
hx-get="{% url 'project_resource_tree_table' project.slug %}?path={{ path }}&page={{ page_obj.previous_page_number }}"
88+
hx-target="#right-pane"
89+
hx-push-url="{% url 'project_resource_tree' project.slug %}?path={{ path }}&page={{ page_obj.previous_page_number }}">
90+
Previous
91+
</a>
92+
{% endif %}
93+
{% if page_obj.has_next %}
94+
<a
95+
class="pagination-next"
96+
hx-get="{% url 'project_resource_tree_table' project.slug %}?path={{ path }}&page={{ page_obj.next_page_number }}"
97+
hx-target="#right-pane"
98+
hx-push-url="{% url 'project_resource_tree' project.slug %}?path={{ path }}&page={{ page_obj.next_page_number }}">
99+
Next page
100+
</a>
101+
{% endif %}
102+
<ul class="pagination-list">
103+
<li>
104+
<span class="pagination-ellipsis">
105+
Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}
106+
</span>
107+
</li>
108+
</ul>
109+
</nav>
110+
{% endif %}
111+
{% else %}
112+
<div class="has-text-centered p-6">
113+
<div class="icon is-large has-text-grey-light mb-3">
114+
<i class="fas fa-folder-open fa-3x"></i>
115+
</div>
116+
<p class="has-text-grey">
117+
{% if path %}
118+
No resources found in this directory.
119+
{% else %}
120+
Select a file or folder from the tree to view its contents.
121+
{% endif %}
122+
</p>
123+
</div>
124+
{% endif %}

scanpipe/views.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2803,30 +2803,12 @@ class ProjectResourceTreeTableView(
28032803
generic.ListView,
28042804
):
28052805
model = CodebaseResource
2806-
template_name = "scanpipe/tree/resource_right_pane_table.html"
2806+
template_name = "scanpipe/tree/resource_right_pane.html"
28072807
paginate_by = settings.SCANCODEIO_PAGINATE_BY.get("resource", 100)
28082808
context_object_name = "resources"
28092809

28102810
def get_queryset(self):
28112811
path = self.request.GET.get("path", "")
2812-
2813-
qs = super().get_queryset().filter(path=path)
2814-
if qs.exists() and not qs.first().is_dir:
2815-
return qs.only(
2816-
"path",
2817-
"status",
2818-
"type",
2819-
"size",
2820-
"name",
2821-
"extension",
2822-
"programming_language",
2823-
"mime_type",
2824-
"tag",
2825-
"detected_license_expression",
2826-
"compliance_alert",
2827-
"package_data",
2828-
).prefetch_related("discovered_packages")
2829-
28302812
return (
28312813
super()
28322814
.get_queryset()
@@ -2835,8 +2817,6 @@ def get_queryset(self):
28352817
.only(
28362818
"path",
28372819
"status",
2838-
"type",
2839-
"name",
28402820
"programming_language",
28412821
"tag",
28422822
"detected_license_expression",

0 commit comments

Comments
 (0)