Skip to content

Commit 3d0e1bd

Browse files
authored
Resources tree view enhancements (#1839)
Signed-off-by: tdruez <tdruez@nexb.com>
1 parent fd78a78 commit 3d0e1bd

14 files changed

+105
-105
lines changed

CHANGELOG.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ v35.4.0 (unreleased)
2020
- Add new ``benchmark_purls`` pipeline.
2121
https://github.com/aboutcode-org/scancode.io/issues/1804
2222

23+
- Add a Resources tree view.
24+
https://github.com/aboutcode-org/scancode.io/issues/1682
25+
2326
v35.3.0 (2025-08-20)
2427
--------------------
2528

scanpipe/templates/scanpipe/includes/project_summary_level.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@
6969
<a href="{{ project_resources_url }}">
7070
{{ project.resource_count|intcomma }}
7171
</a>
72+
{% if project.resource_count > 1 %}
73+
<a href="{% url 'codebase_resource_tree' project.slug %}" class="ml-2">
74+
<span class="icon">
75+
<i class="fa-solid fa-folder-tree is-size-6"></i>
76+
</span>
77+
</a>
78+
{% endif %}
7279
{% if project.resource_compliance_alert_count %}
7380
<a href="{% url 'project_resources' project.slug %}?compliance_alert=error" class="has-text-danger is-size-5 ml-2">
7481
{{ project.resource_compliance_alert_count|intcomma }}

scanpipe/templates/scanpipe/panels/codebase_tree_panel.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<ul>
22
{% for node in children %}
3-
<li class="mb-1">
3+
<li>
44
{% if node.is_dir %}
55
<div class="tree-node is-flex is-align-items-center has-text-weight-semibold px-1" data-folder data-path="{{ node.path }}"{% if node.has_children %} data-target="{{ node.path|slugify }}" data-url="{% url 'codebase_resource_tree' slug=project.slug %}?path={{ node.path }}"{% endif %}>
66
<span class="icon is-small chevron mr-1{% if not node.has_children %} is-invisible{% endif %} is-clickable is-flex is-align-items-center" data-chevron>
77
<i class="fas fa-chevron-right"></i>
88
</span>
99
<span class="is-flex is-align-items-center folder-meta is-clickable" data-folder-click hx-get="{% url 'codebase_resource_table' project.slug %}?path={{ node.path }}" hx-target="#right-pane">
10-
<span class="icon is-small mr-1">
10+
<span class="icon is-small mr-2">
1111
<i class="fas fa-folder"></i>
1212
</span>
1313
<span>{{ node.name }}</span>
@@ -17,8 +17,8 @@
1717
<div id="dir-{{ node.path|slugify }}" class="ml-4 is-hidden" data-loaded="false"></div>
1818
{% endif %}
1919
{% else %}
20-
<div class="is-flex is-align-items-center ml-5 is-clickable is-file" data-file data-path="{{ node.path }}" hx-get="{% url 'codebase_resource_table' project.slug %}?path={{ node.path }}" hx-target="#right-pane">
21-
<span class="icon is-small mr-1">
20+
<div class="tree-node-file is-flex is-align-items-center pl-5 is-clickable is-file" data-file data-path="{{ node.path }}" hx-get="{% url 'codebase_resource_table' project.slug %}?path={{ node.path }}" hx-target="#right-pane">
21+
<span class="icon is-small mr-2">
2222
<i class="far fa-file"></i>
2323
</span>
2424
<span>{{ node.name }}</span>

scanpipe/templates/scanpipe/panels/license_clarity_panel.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<article id="license-clarity-panel" class="panel is-info">
1+
<article id="license-clarity-panel" class="panel is-dark">
22
<div class="panel-heading is-flex is-justify-content-space-between">
33
License clarity
44
{% include "scanpipe/dropdowns/help_dropdown_tooltip.html" with content="License clarity is a set of metrics that indicate how clearly, comprehensively and accurately a software project has defined and communicated the licensing that applies to the software." only %}

scanpipe/templates/scanpipe/panels/license_detections_summary.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{% load humanize %}
22
{% if license_detection_summary %}
33
<div class="column is-half">
4-
<article id="license-detection-summary-panel" class="panel is-info">
4+
<article id="license-detection-summary-panel" class="panel is-dark">
55
<div class="panel-heading is-flex is-justify-content-space-between">
66
Unique license detections
77
{% include "scanpipe/dropdowns/help_dropdown_tooltip.html" with content="All unique license detections in the codebase identified by matched license text and other license match characteristics. Also contains other license clues." only %}
88
</div>
9-
<div class="panel is-info">
10-
<nav class="panel is-info">
9+
<div class="panel is-dark">
10+
<nav class="panel is-dark">
1111
{% for license_expression, count in license_detection_summary.items %}
1212
<a class="panel-block is-align-items-flex-start break-word is-flex is-align-items-center" href="{{ project_licenses_url }}?license_expression={{ license_expression|default:'_EMPTY_' }}" target="_blank">
1313
{{ license_expression|default:'<i>No licenses</i>' }}

scanpipe/templates/scanpipe/panels/project_codebase.html

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
<nav id="codebase-navigation" class="panel is-dark">
2-
<p class="panel-heading is-flex is-justify-content-space-between is-align-items-center">
3-
<span>Codebase</span>
2+
<div class="panel-heading is-flex is-justify-content-space-between is-align-items-center">
3+
<div>
4+
<span>Codebase</span>
5+
{% if current_dir and current_dir != "." %}
6+
<span class="tag ml-2">
7+
{% for dir_name, full_path in codebase_breadcrumbs.items %}
8+
{% if not forloop.last %}
9+
<a href="#" hx-target="#codebase-navigation" hx-swap="outerHTML" hx-get="{{ project_details_url }}codebase/?current_dir={{ full_path }}">
10+
{{ dir_name }}
11+
</a>
12+
<span class="mr-1">/</span>
13+
{% else %}
14+
{{ dir_name }}/
15+
{% endif %}
16+
{% endfor %}
17+
</span>
18+
{% endif %}
19+
</div>
420
<a href="{% url 'codebase_resource_tree' project.slug %}" class="ml-2 has-text-white has-text-decoration-none">
521
<i class="fa-solid fa-folder-tree mr-1"></i>Tree view
622
</a>
7-
{% if current_dir and current_dir != "." %}
8-
<span class="tag ml-2">
9-
{% for dir_name, full_path in codebase_breadcrumbs.items %}
10-
{% if not forloop.last %}
11-
<a href="#" hx-target="#codebase-navigation" hx-swap="outerHTML" hx-get="{{ project_details_url }}codebase/?current_dir={{ full_path }}">
12-
{{ dir_name }}
13-
</a>
14-
<span class="mr-1">/</span>
15-
{% else %}
16-
{{ dir_name }}/
17-
{% endif %}
18-
{% endfor %}
19-
</span>
20-
{% endif %}
21-
</p>
23+
</div>
2224
{% for node in codebase_tree %}
2325
{% if node.is_dir %}
2426
<a class="panel-block" href="#" hx-target="#codebase-navigation" hx-swap="outerHTML" hx-get="{{ project_details_url }}codebase/?current_dir={{ node.location }}">

scanpipe/templates/scanpipe/panels/resource_status_summary.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% load humanize %}
22
{% if resource_status_summary %}
33
<div class="column is-half">
4-
<nav class="panel is-info">
4+
<nav class="panel is-dark">
55
<p class="panel-heading">
66
Resources status
77
</p>

scanpipe/templates/scanpipe/panels/resource_table_panel.html

Lines changed: 23 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,48 @@
11
{% load humanize %}
22

33
{% if resources %}
4-
<table class="table is-bordered is-striped is-narrow is-hoverable is-fullwidth">
4+
<table class="table is-bordered is-striped is-narrow is-fullwidth">
55
<thead class="is-sticky">
66
<tr>
7-
<th>Path</th>
8-
<th>Status</th>
9-
<th>Type</th>
10-
<th>Size</th>
117
<th>Name</th>
12-
<th>Extension</th>
8+
<th>Status</th>
139
<th>Language</th>
14-
<th>MIME Type</th>
15-
<th>Tag</th>
1610
<th>License</th>
1711
<th>Alert</th>
18-
<th>Packages</th>
1912
</tr>
2013
</thead>
2114
<tbody>
2215
{% for resource in resources %}
2316
<tr>
24-
<td class="break-all" style="min-width: 200px;">
25-
{% if resource.is_dir %}
26-
<a href="#" class="expand-in-tree" data-path="{{ resource.path }}" hx-get="{% url 'codebase_resource_table' project.slug %}?path={{ resource.path }}" hx-target="#right-pane">{{ resource.path }}</a>
27-
{% else %}
28-
<a href="{% url 'resource_detail' project.slug resource.path %}">{{ resource.path }}</a>
29-
{% endif %}
17+
<td class="is-flex is-align-items-center break-all" style="min-width: 100px;">
18+
<span class="icon is-small mr-2">
19+
{% if resource.is_dir %}
20+
<i class="fas fa-folder"></i>
21+
{% else %}
22+
<i class="far fa-file"></i>
23+
{% endif %}
24+
</span>
25+
{% if resource.is_dir %}
26+
<a href="#" class="expand-in-tree" data-path="{{ resource.path }}" hx-get="{% url 'codebase_resource_table' project.slug %}?path={{ resource.path }}" hx-target="#right-pane">{{ resource.name }}</a>
27+
{% else %}
28+
<a href="{% url 'resource_detail' project.slug resource.path %}">{{ resource.name }}</a>
29+
{% endif %}
30+
{% if resource.tag %}
31+
<span class="tag is-rounded ml-2">{{ resource.tag }}</span>
32+
{% endif %}
3033
</td>
3134
<td>
3235
{{ resource.status }}
3336
</td>
34-
<td>
35-
{{ resource.type }}
36-
</td>
37-
<td>
38-
{% if resource.is_file %}
39-
{{ resource.size|filesizeformat|default_if_none:"" }}
40-
{% endif %}
41-
</td>
42-
<td class="break-all" style="min-width: 100px;">
43-
{{ resource.name }}
44-
</td>
45-
<td>
46-
{{ resource.extension }}
47-
</td>
4837
<td class="break-all">
4938
{{ resource.programming_language }}
5039
</td>
51-
<td class="break-all">
52-
{{ resource.mime_type }}
53-
</td>
54-
<td>
55-
{{ resource.tag }}
56-
</td>
5740
<td>
5841
{{ resource.detected_license_expression }}
5942
</td>
6043
<td>
6144
{{ resource.compliance_alert }}
6245
</td>
63-
<td>
64-
{% if resource.discovered_packages.all %}
65-
{% for package in resource.discovered_packages.all|slice:":3" %}
66-
<a href="{% url 'project_packages' project.slug %}?purl={{ package.package_url }}">{{ package }}</a>{% if not forloop.last %}, {% endif %}
67-
{% endfor %}
68-
{% if resource.discovered_packages.all|length > 3 %}
69-
+{{ resource.discovered_packages.all|length|add:"-3" }} more
70-
{% endif %}
71-
{% endif %}
72-
</td>
7346
</tr>
7447
{% endfor %}
7548
</tbody>
@@ -84,7 +57,11 @@
8457
<a class="pagination-next" hx-get="{% url 'codebase_resource_table' project.slug %}?path={{ path }}&page={{ page_obj.next_page_number }}" hx-target="#right-pane">Next page</a>
8558
{% endif %}
8659
<ul class="pagination-list">
87-
<li><span class="pagination-ellipsis">Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}</span></li>
60+
<li>
61+
<span class="pagination-ellipsis">
62+
Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}
63+
</span>
64+
</li>
8865
</ul>
8966
</nav>
9067
{% endif %}

scanpipe/templates/scanpipe/panels/scan_summary_panel.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{% load intcomma from humanize %}
2-
<article id="scan-summary-panel" class="panel is-info">
3-
<div class="panel-heading py-2 is-size-6 is-flex is-justify-content-space-between">
2+
<article id="scan-summary-panel" class="panel is-dark">
3+
<div class="panel-heading is-size-6 is-flex is-justify-content-space-between">
44
Scan summary
55
{% include "scanpipe/dropdowns/help_dropdown_tooltip.html" with content="A top-level summary of the collected scanned data such as licenses, holders, and languages." only %}
66
</div>

scanpipe/templates/scanpipe/project_list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
</div>
5151

5252
{% if object_list %}
53-
{% include 'scanpipe/includes/project_list_table.html' with projects=object_list %}
53+
{% include 'scanpipe/tables/project_list_table.html' with projects=object_list %}
5454
{% else %}
5555
<article class="box has-text-centered border-dashed">
5656
{% if filter.is_active %}

0 commit comments

Comments
 (0)