Skip to content

Commit

Permalink
Add status column in relation view table #688
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Druez <tdruez@nexb.com>
  • Loading branch information
tdruez committed Apr 24, 2023
1 parent d64307b commit 73b6984
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
11 changes: 7 additions & 4 deletions scanpipe/templates/scanpipe/relation_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@

<div class="container is-fluid mb-3">
<div class="table-container">
<table class="table is-bordered is-narrow is-hoverable is-fullwidth">
<table class="table is-bordered is-narrow is-hoverable is-fullwidth" style="table-layout: fixed;">
<thead>
<tr>
<th style="width: 45%">To resource</th>
<th>
<th>To resource</th>
<th style="width:100px;">Status</th>
<th style="width:145px;">
<a href="?sort={% if "-" not in filter.data.sort %}-{% endif %}related_from__match_type" class="is-black-link">Match type</a>
{% if "related_from__match_type" in filter.data.sort %}
<i class="fa fa-sort-{% if "-" in filter.data.sort %}down{% else %}up{% endif %}"></i>
Expand All @@ -30,7 +31,7 @@
{% include 'scanpipe/includes/match_type_filter_dropdown.html' %}
</div>
</th>
<th style="width: 45%">From resource</th>
<th>From resource</th>
</tr>
</thead>
<tbody>
Expand All @@ -42,6 +43,7 @@
<a href="{{ resource.get_absolute_url }}#viewer">{{ resource.path }}</a>
</td>
{% endif %}
<td>{{ resource.status }}</td>
<td>
{{ relation.match_type }}
{% if relation.extra_data.path_score %}
Expand All @@ -65,6 +67,7 @@
<td class="break-all">
<a class="has-text-danger" href="{{ resource.get_absolute_url }}#viewer">{{ resource.path }}</a>
</td>
<td>{{ resource.status }}</td>
<td></td>
<td></td>
</tr>
Expand Down
8 changes: 6 additions & 2 deletions scanpipe/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,10 @@ class ProjectErrorListView(
]


RelationRow = namedtuple("RelationRow", "to_resource match_type score from_resource")
RelationRow = namedtuple(
"RelationRow",
field_names=["to_resource", "status", "match_type", "score", "from_resource"],
)


class CodebaseRelationListView(
Expand Down Expand Up @@ -967,11 +970,12 @@ def get_rows(qs):
for resource in qs:
relations = resource.related_from.all()
if not relations:
yield RelationRow(resource.path, "", "", "")
yield RelationRow(resource.path, "", "", "", "")
else:
for relation in resource.related_from.all():
yield RelationRow(
resource.path,
resource.status,
relation.match_type,
relation.extra_data.get("path_score", ""),
relation.from_resource.path,
Expand Down

0 comments on commit 73b6984

Please # to comment.