Skip to content

Commit ad34af4

Browse files
committed
Proper rendering of resource detail in the right panel
Signed-off-by: tdruez <[email protected]>
1 parent a91483b commit ad34af4

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

scanpipe/templates/scanpipe/resource_detail.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<div class="mx-5">
1717
{% block partial-content %}
1818
{% if request.htmx %}
19-
{% include 'scanpipe/tree/resource_path_breadcrumb.html' %}
19+
{% include 'scanpipe/tree/resource_path_breadcrumb.html' with path=object.path %}
2020
{% endif %}
2121
{% include 'scanpipe/tabset/tabset.html' %}
2222
{% endblock %}

scanpipe/templates/scanpipe/resource_tree.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@
2929
<div id="right-pane" class="right-pane px-3">
3030
{% if path %}
3131
<div
32-
hx-get="{% url 'project_resource_tree_table' project.slug %}?path={{ path }}"
32+
{% if resource.is_file %}
33+
hx-get="{% url 'resource_detail' project.slug resource.path %}"
34+
{% else %}
35+
hx-get="{% url 'project_resource_tree_table' project.slug %}?path={{ path }}"
36+
{% endif %}
3337
hx-trigger="load"
3438
hx-target="this">
3539
</div>

scanpipe/templates/scanpipe/tree/resource_path_breadcrumb.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% if path_segments %}
2-
<nav class="breadcrumb is-flex is-align-items-center" aria-label="breadcrumbs">
2+
<nav class="breadcrumb is-flex is-align-items-center mb-2" aria-label="breadcrumbs">
33
<button
44
id="expand-left-pane"
55
class="button is-light px-2 mr-2 has-tooltip is-hidden"

scanpipe/views.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from django.conf import settings
3232
from django.contrib import messages
3333
from django.contrib.auth.mixins import LoginRequiredMixin
34+
from django.core.exceptions import ObjectDoesNotExist
3435
from django.core.exceptions import SuspiciousFileOperation
3536
from django.core.exceptions import ValidationError
3637
from django.core.files.storage.filesystem import FileSystemStorage
@@ -2749,16 +2750,23 @@ def get(self, request, *args, **kwargs):
27492750
.order_by("type", "path")
27502751
)
27512752

2753+
try:
2754+
resource = project.codebaseresources.get(path=path)
2755+
except ObjectDoesNotExist:
2756+
resource = None
2757+
27522758
context = {
27532759
"project": project,
27542760
"path": path,
27552761
"children": children,
2762+
"resource": resource,
27562763
}
27572764

27582765
if request.GET.get("tree_panel") == "true":
27592766
return render(
27602767
request, "scanpipe/tree/resource_left_pane_tree.html", context
27612768
)
2769+
27622770
return render(request, self.template_name, context)
27632771

27642772

0 commit comments

Comments
 (0)