Skip to content

Commit 37aef0f

Browse files
committed
add breadcrumbs and copy-to-clipboard button in resource_table_view
Signed-off-by: Aayush Kumar <[email protected]>
1 parent 3d8700a commit 37aef0f

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

scanpipe/templates/scanpipe/panels/resource_table_panel.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
11
{% load humanize %}
2+
<div class="mb-4">
3+
<div class="has-text-weight-semibold is-flex is-align-items-center is-family-monospace">
4+
{% if path_segments %}
5+
<span id="resource-path" class="has-text-weight-medium">
6+
{% for subpath, segment in path_segments %}
7+
{% if not forloop.first %}<span class="mx-1">/</span>{% endif %}
8+
{% if not forloop.last %}
9+
<a href="#" class="expand-in-tree has-text-link" data-path="{{ subpath }}" hx-get="{% url 'codebase_resource_table' project.slug %}?path={{ subpath }}" hx-target="#right-pane">{{ segment }}</a>
10+
{% else %}
11+
<span>{{ segment }}</span>
12+
{% endif %}
13+
{% endfor %}
14+
</span>
15+
<button class="copy-to-clipboard ml-2 is-size-6 is-shadowless is-white" aria-label="Copy path" data-copy="{{ path }}" data-copy-feedback="Path copied!">
16+
<i class="fa-regular fa-copy"></i>
17+
</button>
18+
{% endif %}
19+
</div>
20+
</div>
221

322
{% if resources %}
423
<table class="table is-bordered is-striped is-narrow is-fullwidth">

scanpipe/templates/scanpipe/resource_tree.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@
105105

106106
{% block scripts %}
107107
<script>
108+
document.body.addEventListener('htmx:afterSwap', function(evt) {
109+
if (evt.target && evt.target.id === 'right-pane') {
110+
if (typeof enableCopyToClipboard === 'function') {
111+
enableCopyToClipboard('.copy-to-clipboard');
112+
}
113+
}
114+
});
115+
108116
// Tree functionality
109117
document.addEventListener("click", async function (e) {
110118
const chevron = e.target.closest("[data-chevron]");

scanpipe/views.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2837,5 +2837,8 @@ def get_queryset(self):
28372837

28382838
def get_context_data(self, **kwargs):
28392839
context = super().get_context_data(**kwargs)
2840-
context["path"] = self.request.GET.get("path", "")
2840+
path = self.request.GET.get("path", "")
2841+
context["path"] = path
2842+
segments = path.strip("/").split("/")
2843+
context["path_segments"] = [ ("/".join(segments[:i+1]), segment) for i, segment in enumerate(segments) ]
28412844
return context

0 commit comments

Comments
 (0)