Skip to content

Commit 68601a9

Browse files
committed
Add .. navigation option in table to navigate to parent resource
Signed-off-by: Aayush Kumar <[email protected]>
1 parent 473c6fe commit 68601a9

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

scanpipe/templates/scanpipe/panels/resource_table_panel.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,24 @@
3434
</tr>
3535
</thead>
3636
<tbody>
37+
{% if parent_path is not None %}
38+
<tr class="expand-in-tree is-clickable"
39+
data-path="{{ parent_path|default_if_none:'' }}"
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-flex is-align-items-center break-all" 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+
<td></td>
50+
<td></td>
51+
<td></td>
52+
<td></td>
53+
</tr>
54+
{% endif %}
3755
{% for resource in resources %}
3856
<tr>
3957
<td class="is-flex is-align-items-center break-all" style="min-width: 100px;">

scanpipe/views.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2844,4 +2844,11 @@ def get_context_data(self, **kwargs):
28442844
context["path_segments"] = [
28452845
("/".join(segments[: i + 1]), segment) for i, segment in enumerate(segments)
28462846
]
2847+
2848+
if path and "/" in path:
2849+
parent_segments = path.rstrip("/").split("/")[:-1]
2850+
context["parent_path"] = "/".join(parent_segments)
2851+
else:
2852+
context["parent_path"] = None
2853+
28472854
return context

0 commit comments

Comments
 (0)