Skip to content

Commit 9cabb29

Browse files
committed
fix: remove CSV "Current View" from Export dropdown
The table CSV export uses verbose column names that don't match the import form fields, making round-trip import impossible. Replace the BulkExport action with a YAML-only variant that omits the "Current View" option, keeping only "All Data (YAML)".
1 parent 2035bda commit 9cabb29

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{# SPDX-License-Identifier: Apache-2.0 #}
2+
{# Copyright (C) 2025 Marcin Zieba <marcinpsk@gmail.com> #}
3+
{% load i18n %}
4+
<div class="dropdown">
5+
<button type="button" class="btn btn-purple dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
6+
<i class="mdi mdi-download" aria-hidden="true"></i> {{ label }}
7+
</button>
8+
<ul class="dropdown-menu dropdown-menu-end">
9+
<li><a class="dropdown-item" href="?{% if url_params %}{{ url_params }}&{% endif %}export">{% trans "All Data" %} ({{ data_format }})</a></li>
10+
{% if export_templates %}
11+
<li>
12+
<hr class="dropdown-divider">
13+
</li>
14+
{% for et in export_templates %}
15+
<li>
16+
<a class="dropdown-item" href="?{% if url_params %}{{ url_params }}&{% endif %}export={{ et.name }}"
17+
{% if et.description %} title="{{ et.description }}"{% endif %}
18+
>
19+
{{ et.name }}
20+
</a>
21+
</li>
22+
{% endfor %}
23+
{% endif %}
24+
{% if perms.extras.add_exporttemplate %}
25+
<li>
26+
<hr class="dropdown-divider">
27+
</li>
28+
<li>
29+
<a class="dropdown-item" href="{% url 'extras:exporttemplate_add' %}?object_types={{ object_type.pk }}">{% trans "Add export template" %}...</a>
30+
</li>
31+
{% endif %}
32+
</ul>
33+
</div>

netbox_interface_name_rules/views.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from django.shortcuts import redirect, render
1313
from django.urls import reverse
1414
from django.utils.http import url_has_allowed_host_and_scheme
15+
from netbox.object_actions import AddObject, BulkDelete, BulkEdit, BulkExport, BulkImport, BulkRename
1516
from netbox.views import generic
1617
from netbox.views.generic.base import BaseMultiObjectView
1718
from utilities.views import register_model_view
@@ -45,6 +46,12 @@ class RulePreview:
4546
channel_start: int
4647

4748

49+
class _YAMLOnlyExport(BulkExport):
50+
"""Export action that only offers YAML (no CSV "Current View" option)."""
51+
52+
template_name = "netbox_interface_name_rules/buttons/export_yaml_only.html"
53+
54+
4855
class InterfaceNameRuleListView(generic.ObjectListView):
4956
"""List view for InterfaceNameRule."""
5057

@@ -53,6 +60,7 @@ class InterfaceNameRuleListView(generic.ObjectListView):
5360
filterset = InterfaceNameRuleFilterSet
5461
filterset_form = InterfaceNameRuleFilterForm
5562
template_name = "netbox_interface_name_rules/interfacenamerule_list.html"
63+
actions = (AddObject, BulkImport, _YAMLOnlyExport, BulkEdit, BulkRename, BulkDelete)
5664

5765
def export_yaml(self):
5866
"""Export all rules as a single YAML list (overrides NetBox's per-object concatenation)."""

0 commit comments

Comments
 (0)