Skip to content

Commit fdb9962

Browse files
committed
Display the filename/download_url in the Inventory tab #303
Signed-off-by: tdruez <tdruez@nexb.com>
1 parent 635b293 commit fdb9962

4 files changed

Lines changed: 28 additions & 10 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<div title="{{ package.download_url }}"{% if not package.filename %} class="text-truncate"{% endif %}>
2+
{% if package.download_url %}
3+
<a href="{{ package.download_url }}">
4+
{% if display_icons %}
5+
<i class="fa-solid fa-download me-1"></i>
6+
{% endif %}
7+
{% if package.filename %}
8+
{{ package.filename }}
9+
{% else %}
10+
{{ package.download_url|truncatechars:40 }}
11+
{% endif %}
12+
</a>
13+
{% elif package.filename %}
14+
{% if display_icons %}
15+
<i class="fa-solid fa-file me-1"></i>
16+
{% endif %}
17+
{{ package.filename }}
18+
{% endif %}
19+
</div>

component_catalog/templates/component_catalog/tables/package_list_table.html

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,8 @@
5757
<td>
5858
{{ object.primary_language }}
5959
</td>
60-
<td title="{{ object.download_url }}"{% if not object.filename %} class="text-truncate"{% endif %}>
61-
{% if object.download_url %}
62-
<a href="{{ object.download_url }}">
63-
{% if object.filename %}{{ object.filename }}{% else %}{{ object.download_url }}{% endif %}
64-
</a>
65-
{% endif %}
60+
<td>
61+
{% include 'component_catalog/includes/package_filename_as_link.html' with package=object %}
6662
</td>
6763
<td>
6864
{% with components=object.component_set.all %}

component_catalog/tests/test_views.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,20 +1194,20 @@ def test_package_list_view_download_column(self):
11941194
response = self.client.get(reverse("component_catalog:package_list"))
11951195

11961196
expected = f"""
1197-
<td title="{self.package1.download_url}">
1197+
<div title="{self.package1.download_url}">
11981198
<a href="{self.package1.download_url}">
11991199
{self.package1.filename}
12001200
</a>
1201-
</td>
1201+
</div>
12021202
"""
12031203
self.assertContains(response, expected, html=True)
12041204

12051205
expected = f"""
1206-
<td title="{self.package2.download_url}" class="text-truncate">
1206+
<div title="{self.package2.download_url}" class="text-truncate">
12071207
<a href="{self.package2.download_url}">
12081208
{self.package2.download_url}
12091209
</a>
1210-
</td>
1210+
</div>
12111211
"""
12121212
self.assertContains(response, expected, html=True)
12131213

product_portfolio/templates/product_portfolio/tabs/tab_inventory.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@
115115
<i class="fas fa-user me-2"></i>{{ relation.component.owner.get_absolute_link }}{{ relation.owner }}
116116
</div>
117117
{% endif %}
118+
{% if relation.package %}
119+
{% include 'component_catalog/includes/package_filename_as_link.html' with package=relation.package display_icons=True %}
120+
{% endif %}
118121
</td>
119122
<td>
120123
{% if relation.purpose %}

0 commit comments

Comments
 (0)