Skip to content

Commit d76117b

Browse files
authored
Add "Package Compliance Alert" chart in the Policies section (#1699)
Signed-off-by: tdruez <tdruez@nexb.com>
1 parent 2b587ae commit d76117b

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ v34.12.0 (unreleased)
3333
- Add "(No value detected)" for Copyright and Holder charts.
3434
https://github.com/aboutcode-org/scancode.io/issues/1697
3535

36+
- Add "Package Compliance Alert" chart in the Policies section.
37+
3638
v34.11.0 (2025-05-02)
3739
---------------------
3840

scanpipe/templates/scanpipe/project_charts.html

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,26 @@ <h3 id="resource-charts" class="title is-4 has-text-centered mb-3">
5858
{% include "scanpipe/includes/resource_chart_column.html" with field_name="detected_license_expression" url=resources_url %}
5959
<div class="column"></div>
6060
</div>
61-
{% if file_compliance_alert %}
62-
<hr>
63-
<h3 class="title is-4 has-text-centered mb-3">
64-
Policies
65-
</h3>
66-
<div class="columns is-gapless">
61+
{% endif %}
62+
63+
{% if file_compliance_alert or package_compliance_alert %}
64+
<hr>
65+
<h3 class="title is-4 has-text-centered mb-3">
66+
Policies
67+
</h3>
68+
<div class="columns is-gapless">
69+
{% if file_compliance_alert %}
6770
{% include "scanpipe/includes/resource_chart_column.html" with field_name="compliance_alert" url=resources_url %}
71+
{% endif %}
72+
{% if package_compliance_alert %}
73+
<div class="column">
74+
<div id="package_compliance_alert_chart" data-url="{{ packages_url }}" data-lookup_field="compliance_alert"></div>
75+
</div>
76+
{% endif %}
77+
{% if not file_compliance_alert or not package_compliance_alert %}
6878
<div class="column"></div>
69-
</div>
70-
{% endif %}
79+
{% endif %}
80+
</div>
7181
{% endif %}
7282

7383
{% block scripts %}
@@ -79,6 +89,7 @@ <h3 class="title is-4 has-text-centered mb-3">
7989
{{ file_compliance_alert|json_script:"file_compliance_alert" }}
8090
{{ package_declared_license_expression|json_script:"package_declared_license_expression" }}
8191
{{ package_type|json_script:"package_type" }}
92+
{{ package_compliance_alert|json_script:"package_compliance_alert" }}
8293
{{ dependency_type|json_script:"dependency_type" }}
8394
{{ dependency_is_runtime|json_script:"dependency_is_runtime" }}
8495
{{ dependency_is_optional|json_script:"dependency_is_optional" }}
@@ -154,6 +165,7 @@ <h3 class="title is-4 has-text-centered mb-3">
154165
{% if project.package_count %}
155166
makeChart("package_type", "#package_type_chart", "Package\nType");
156167
makeChart("package_declared_license_expression", "#package_license_chart", "Package\nLicense\nExpression");
168+
makeChart("package_compliance_alert", "#package_compliance_alert_chart", "Package\nCompliance\nAlert");
157169
{% endif %}
158170
{% if project.dependency_count %}
159171
makeChart("dependency_type", "#dependency_type_chart", "Package\nType");
@@ -167,7 +179,7 @@ <h3 class="title is-4 has-text-centered mb-3">
167179
makeChart("file_holders", "#holders_chart", "Holder");
168180
makeChart("file_copyrights", "#copyrights_chart", "Copyright");
169181
makeChart("file_detected_license_expression", "#detected_license_expression_chart", "Detected\nLicense\nExpression");
170-
makeChart("file_compliance_alert", "#compliance_alert_chart", "Compliance\nAlert");
182+
makeChart("file_compliance_alert", "#compliance_alert_chart", "Resource\nCompliance\nAlert");
171183
{% endif %}
172184
</script>
173185
{% endblock %}

scanpipe/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ def get_context_data(self, **kwargs):
10131013
},
10141014
"package": {
10151015
"queryset": project.discoveredpackages,
1016-
"fields": ["type", "declared_license_expression"],
1016+
"fields": ["type", "declared_license_expression", "compliance_alert"],
10171017
},
10181018
"dependency": {
10191019
"queryset": project.discovereddependencies,

0 commit comments

Comments
 (0)