Skip to content

Commit 62a8f1e

Browse files
authored
Add .. navigation option in table to navigate to parent resource (#1869)
Signed-off-by: Aayush Kumar <[email protected]>
1 parent 0ed2d03 commit 62a8f1e

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

scanpipe/templates/scanpipe/panels/resource_table_panel.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,20 @@
3434
</tr>
3535
</thead>
3636
<tbody>
37+
{% if parent_path %}
38+
<tr class="expand-in-tree is-clickable"
39+
data-path="{{ parent_path }}"
40+
hx-get="{% url 'codebase_resource_table' project.slug %}{% if parent_path %}?path={{ parent_path }}{% endif %}"
41+
hx-target="#right-pane"
42+
hx-push-url="{% url 'codebase_resource_tree' project.slug %}{% if parent_path %}?path={{ parent_path }}{% endif %}">
43+
<td class="is-align-items-center break-all" colspan="5" style="min-width: 100px;">
44+
<span class="icon is-small mr-2">
45+
<i class="fas fa-folder"></i>
46+
</span>
47+
<span class="has-text-weight-medium">..</span>
48+
</td>
49+
</tr>
50+
{% endif %}
3751
{% for resource in resources %}
3852
<tr>
3953
<td class="is-flex is-align-items-center break-all" style="min-width: 100px;">

scanpipe/views.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2848,4 +2848,9 @@ def get_context_data(self, **kwargs):
28482848
context["path_segments"] = [
28492849
("/".join(segments[: i + 1]), segment) for i, segment in enumerate(segments)
28502850
]
2851+
2852+
if path and "/" in path:
2853+
parent_segments = path.rstrip("/").split("/")[:-1]
2854+
context["parent_path"] = "/".join(parent_segments)
2855+
28512856
return context

0 commit comments

Comments
 (0)