diff --git a/netbox/netbox/ui/panels.py b/netbox/netbox/ui/panels.py index 8409bf6ed..67290014f 100644 --- a/netbox/netbox/ui/panels.py +++ b/netbox/netbox/ui/panels.py @@ -106,9 +106,15 @@ class ObjectPanel(Panel): def get_context(self, context): obj = resolve_attr_path(context, self.accessor) + if self.title is not None: + title_ = self.title + elif obj is not None: + title_ = title(obj._meta.verbose_name) + else: + title_ = None return { **super().get_context(context), - 'title': self.title or title(obj._meta.verbose_name), + 'title': title_, 'object': obj, } diff --git a/netbox/templates/ui/panels/_base.html b/netbox/templates/ui/panels/_base.html index 5128e6428..670d9fda8 100644 --- a/netbox/templates/ui/panels/_base.html +++ b/netbox/templates/ui/panels/_base.html @@ -1,15 +1,17 @@
-

- {{ title }} - {% if actions %} -
- {% for action in actions %} - {% render action %} - {% endfor %} -
- {% endif %} -

+ {% if title or actions %} +

+ {{ title|default:"" }} + {% if actions %} +
+ {% for action in actions %} + {% render action %} + {% endfor %} +
+ {% endif %} +

+ {% endif %} {% block panel_content %}{% endblock %}