Skip to content

Commit d56b5eb

Browse files
Fix license detections page error and improve UI (#1751)
Reference: #1750 Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
1 parent 58318b0 commit d56b5eb

File tree

8 files changed

+58
-28
lines changed

8 files changed

+58
-28
lines changed

scanpipe/filters.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,8 @@ class LicenseFilterSet(FilterSetUtilsMixin, django_filters.FilterSet):
840840
"compliance_alert",
841841
"license_expression",
842842
"license_expression_spdx",
843+
"is_license_clue",
844+
"needs_review",
843845
]
844846

845847
search = DiscoveredLicenseSearchFilter(
@@ -853,6 +855,8 @@ class LicenseFilterSet(FilterSetUtilsMixin, django_filters.FilterSet):
853855
"license_expression",
854856
"license_expression_spdx",
855857
"compliance_alert",
858+
"is_license_clue",
859+
"needs_review",
856860
],
857861
)
858862
license_expression = django_filters.AllValuesFilter()

scanpipe/models.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2544,7 +2544,6 @@ class Meta:
25442544
"""
25452545

25462546
license_expression_field = None
2547-
license_expression_spdx_field = None
25482547

25492548
class Compliance(models.TextChoices):
25502549
OK = "ok"

scanpipe/templates/scanpipe/license_detection_list.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
<a href="{% url 'license_detail' project.slug license_detection.identifier %}">{{ license_detection.identifier }}</a>
2727
{% if license_detection.needs_review %}
2828
<a href="{% url 'license_detail' project.slug license_detection.identifier %}#detection">
29-
<i class="fa-solid fa-magnifying-glass fa-sm has-text-danger" title="License Detection Issues"></i>
29+
<i class="fa-solid fa-magnifying-glass fa-sm has-text-danger" title="License detection issue: needs review"></i>
3030
</a>
3131
{% endif %}
3232
{% if license_detection.has_compliance_alert %}
3333
<a href="{% url 'license_detail' project.slug license_detection.identifier %}#detection">
34-
<i class="fa-solid fa-scale-balanced fa-sm has-text-danger" title="License Compliance Alerts"></i>
34+
<i class="fa-solid fa-scale-balanced fa-sm has-text-danger" title="License Compliance Alert"></i>
3535
</a>
3636
{% endif %}
3737
</td>
@@ -50,13 +50,13 @@
5050
<td>
5151
{{ license_detection.needs_review }}
5252
</td>
53-
{% if display_compliance_alert %}
54-
<td>
55-
<a href="?compliance_alert={{ license_detection.compliance_alert }}" class="is-black-link">
56-
{{ license_detection.compliance_alert }}
57-
</a>
58-
</td>
53+
<td>
54+
{% if display_compliance_alert %}
55+
<a href="?compliance_alert={{ license_detection.compliance_alert }}" class="is-black-link">
56+
{{ license_detection.compliance_alert }}
57+
</a>
5958
{% endif %}
59+
</td>
6060
</tr>
6161
{% empty %}
6262
<tr>

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-dark">
1+
<article id="license-clarity-panel" class="panel is-info">
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 %}
Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
11
{% load humanize %}
22
{% if license_detection_summary %}
3-
<div class="column is-half">
3+
<div class="column is-half">
4+
<article id="license-detection-summary-panel" class="panel is-info">
5+
<div class="panel-heading is-flex is-justify-content-space-between">
6+
Unique license detections
7+
{% 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 %}
8+
</div>
9+
<div class="panel is-info">
410
<nav class="panel is-info">
5-
<p class="panel-heading py-2 is-size-6">
6-
Unique license detections
7-
</p>
811
{% for license_expression, count in license_detection_summary.items %}
9-
<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">
12+
<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">
1013
{{ license_expression|default:'<i>No licenses</i>' }}
1114
<span class="tag is-rounded ml-1">{{ count|intcomma }}</span>
15+
{% if license_expression in issue_count_by_expression %}
16+
<span class="has-text-danger is-size-6 ml-2 is-flex is-flex-direction-row" title="License detection issue: needs review">
17+
<span class="ml-1"><i class="fa-solid fa-magnifying-glass"></i></span>
18+
{% for expression, count in issue_count_by_expression.items %}
19+
{% if license_expression is expression %}
20+
<span class="ml-1">{{ count|intcomma }}</span>
21+
{% endif %}
22+
{% endfor %}
23+
</span>
24+
{% endif %}
1225
{% if license_expression in expressions_with_compliance_alert %}
13-
&nbsp; <span class="fa-solid fa-scale-balanced has-text-danger" title="License Compliance Alerts"></span>
26+
<span class="has-text-danger is-size-6 is-flex is-flex-direction-row" title="License Compliance Alert">
27+
<span class="ml-1"><i class="fa-solid fa-scale-balanced"></i></span>
28+
<span class="ml-1">{{ count|intcomma }}</span>
29+
</span>
1430
{% endif %}
1531
</a>
1632
{% endfor %}
@@ -19,13 +35,13 @@
1935
See all license detections
2036
<span class="tag is-rounded ml-1">{{ total_counts.all|intcomma }}</span>
2137
{% if total_counts.needs_review %}
22-
<span class="has-text-danger is-size-6 ml-2">
38+
<span class="has-text-danger is-size-6 ml-2" title="License detection issue: needs review">
2339
<i class="fa-solid fa-magnifying-glass"></i>
2440
{{ total_counts.needs_review|intcomma }}
2541
</span>
2642
{% endif %}
2743
{% if total_counts.with_compliance_error %}
28-
<span class="has-text-danger is-size-6 ml-2">
44+
<span class="has-text-danger is-size-6 ml-2" title="License Compliance Alert">
2945
<i class="fa-solid fa-scale-balanced fa-sm"></i>
3046
{{ total_counts.with_compliance_error|intcomma }}
3147
</span>
@@ -37,13 +53,13 @@
3753
See all license clues
3854
<span class="tag is-rounded ml-1">{{ clue_counts.all|intcomma }}</span>
3955
{% if clue_counts.needs_review %}
40-
<span class="has-text-danger is-size-6 ml-2">
56+
<span class="has-text-danger is-size-6 ml-2" title="License detection issue: needs review">
4157
<i class="fa-solid fa-magnifying-glass"></i>
4258
{{ clue_counts.needs_review|intcomma }}
4359
</span>
4460
{% endif %}
4561
{% if clue_counts.with_compliance_error %}
46-
<span class="has-text-danger is-size-6 ml-2">
62+
<span class="has-text-danger is-size-6 ml-2" title="License Compliance Alert">
4763
<i class="fa-solid fa-scale-balanced fa-sm"></i>
4864
{{ clue_counts.with_compliance_error|intcomma }}
4965
</span>
@@ -52,4 +68,6 @@
5268
{% endif %}
5369
</nav>
5470
</div>
71+
</article>
72+
</div>
5573
{% endif %}

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-dark">
4+
<nav class="panel is-info">
55
<p class="panel-heading">
66
Resources status
77
</p>

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-dark">
3-
<div class="panel-heading is-flex is-justify-content-space-between">
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">
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/views.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,14 +1129,19 @@ def get_license_detection_summary(project, limit=10):
11291129

11301130
# Also get count for detections with
11311131
expressions_with_compliance_alert = []
1132+
issue_count_by_expression = {}
11321133
for license_expression in top_licenses.keys():
1134+
detections_for_expression = proper_license_detections.filter(
1135+
license_expression=license_expression
1136+
)
11331137
has_compliance_alert = (
1134-
proper_license_detections.filter(license_expression=license_expression)
1135-
.has_compliance_alert()
1136-
.exists()
1138+
detections_for_expression.has_compliance_alert().exists()
11371139
)
1140+
issue_count = detections_for_expression.needs_review().count()
11381141
if has_compliance_alert:
11391142
expressions_with_compliance_alert.append(license_expression)
1143+
if issue_count > 0:
1144+
issue_count_by_expression[license_expression] = issue_count
11401145

11411146
total_counts = {
11421147
"with_compliance_error": (
@@ -1160,18 +1165,20 @@ def get_license_detection_summary(project, limit=10):
11601165
return (
11611166
top_licenses,
11621167
expressions_with_compliance_alert,
1168+
issue_count_by_expression,
11631169
total_counts,
11641170
license_clues,
11651171
clue_counts,
11661172
)
11671173

11681174
def get_context_data(self, **kwargs):
11691175
context = super().get_context_data(**kwargs)
1170-
summary, expressions, counts, clues, clue_counts = (
1176+
summary, expressions, issues, counts, clues, clue_counts = (
11711177
self.get_license_detection_summary(project=self.object)
11721178
)
11731179
context["license_detection_summary"] = summary
11741180
context["expressions_with_compliance_alert"] = expressions
1181+
context["issue_count_by_expression"] = issues
11751182
context["total_counts"] = counts
11761183
context["license_clues"] = clues
11771184
context["clue_counts"] = clue_counts
@@ -1901,7 +1908,9 @@ def get_queryset(self):
19011908

19021909
def get_context_data(self, **kwargs):
19031910
context = super().get_context_data(**kwargs)
1904-
context["display_compliance_alert"] = self.get_project().policies_enabled
1911+
context["display_compliance_alert"] = (
1912+
self.get_project().license_policies_enabled
1913+
)
19051914
return context
19061915

19071916

0 commit comments

Comments
 (0)