Skip to content

Commit e05ca71

Browse files
committed
Flag HTMX navigation as an experimental feature
1 parent c32dff5 commit e05ca71

File tree

4 files changed

+44
-29
lines changed

4 files changed

+44
-29
lines changed

netbox/netbox/preferences.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,25 @@ def get_page_lengths():
2222
('dark', _('Dark')),
2323
),
2424
default='light',
25+
description=_('Preferred default UI theme')
2526
),
2627
'ui.htmx_navigation': UserPreference(
2728
label=_('HTMX Navigation'),
2829
choices=(
2930
('', _('Disabled')),
3031
('true', _('Enabled')),
3132
),
32-
default=False
33+
description=_('Enable dynamic UI navigation'),
34+
default=False,
35+
experimental=True
3336
),
3437
'locale.language': UserPreference(
3538
label=_('Language'),
3639
choices=(
3740
('', _('Auto')),
3841
*settings.LANGUAGES,
39-
)
42+
),
43+
description=_('Forces UI translation to the specified language.')
4044
),
4145
'pagination.per_page': UserPreference(
4246
label=_('Page length'),
@@ -51,8 +55,8 @@ def get_page_lengths():
5155
('top', _('Top')),
5256
('both', _('Both')),
5357
),
54-
description=_('Where the paginator controls will be displayed relative to a table'),
55-
default='bottom'
58+
default='bottom',
59+
description=_('Where the paginator controls will be displayed relative to a table')
5660
),
5761

5862
# Miscellaneous
@@ -62,6 +66,7 @@ def get_page_lengths():
6266
('json', 'JSON'),
6367
('yaml', 'YAML'),
6468
),
69+
description=_('The preferred syntax for displaying generic data within the UI')
6570
),
6671

6772
}

netbox/templates/account/preferences.html

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,30 +39,32 @@ <h5 class="col-9 offset-3">{% trans "Table Configurations" %}</h5>
3939
{% trans "Clear table preferences" %}
4040
</label>
4141
<div class="col-sm-9">
42-
<table class="table table-hover object-list">
43-
<thead>
44-
<tr>
45-
<th>
46-
<input type="checkbox" class="toggle form-check-input" title="{% trans "Toggle All" %}">
47-
</th>
48-
<th>{% trans "Table" %}</th>
49-
<th>{% trans "Ordering" %}</th>
50-
<th>{% trans "Columns" %}</th>
51-
</tr>
52-
</thead>
53-
<tbody>
54-
{% for table, prefs in request.user.config.data.tables.items %}
42+
<div class="card">
43+
<table class="table table-hover object-list">
44+
<thead>
5545
<tr>
56-
<td>
57-
<input type="checkbox" name="pk" value="tables.{{ table }}" class="form-check-input" />
58-
</td>
59-
<td>{{ table }}</td>
60-
<td>{{ prefs.ordering|join:", "|placeholder }}</td>
61-
<td>{{ prefs.columns|join:", "|placeholder }}</td>
46+
<th>
47+
<input type="checkbox" class="toggle form-check-input" title="{% trans "Toggle All" %}">
48+
</th>
49+
<th>{% trans "Table" %}</th>
50+
<th>{% trans "Ordering" %}</th>
51+
<th>{% trans "Columns" %}</th>
6252
</tr>
63-
{% endfor %}
64-
</tbody>
65-
</table>
53+
</thead>
54+
<tbody>
55+
{% for table, prefs in request.user.config.data.tables.items %}
56+
<tr>
57+
<td>
58+
<input type="checkbox" name="pk" value="tables.{{ table }}" class="form-check-input" />
59+
</td>
60+
<td>{{ table }}</td>
61+
<td>{{ prefs.ordering|join:", "|placeholder }}</td>
62+
<td>{{ prefs.columns|join:", "|placeholder }}</td>
63+
</tr>
64+
{% endfor %}
65+
</tbody>
66+
</table>
67+
</div>
6668
</div>
6769
{% else %}
6870
<div class="col-9 offset-3">

netbox/users/forms/model_forms.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from django.contrib.auth import get_user_model
44
from django.contrib.postgres.forms import SimpleArrayField
55
from django.core.exceptions import FieldError
6-
from django.utils.html import mark_safe
6+
from django.utils.safestring import mark_safe
77
from django.utils.translation import gettext_lazy as _
88

99
from core.models import ObjectType
@@ -37,7 +37,14 @@ def __new__(mcs, name, bases, attrs):
3737
preference_fields = {}
3838
for field_name, preference in PREFERENCES.items():
3939
description = f'{preference.description}<br />' if preference.description else ''
40-
help_text = f'{description}<code>{field_name}</code>'
40+
help_text = f'<code>{field_name}</code>'
41+
if preference.description:
42+
help_text = f'{preference.description}<br />{help_text}'
43+
if preference.experimental:
44+
help_text = (
45+
f'<span class="text-danger"><i class="mdi mdi-alert"></i> Experimental feature</span><br />'
46+
f'{help_text}'
47+
)
4148
field_kwargs = {
4249
'label': preference.label,
4350
'choices': preference.choices,

netbox/users/preferences.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ class UserPreference:
22
"""
33
Represents a configurable user preference.
44
"""
5-
def __init__(self, label, choices, default=None, description='', coerce=lambda x: x):
5+
def __init__(self, label, choices, default=None, description='', coerce=lambda x: x, experimental=False):
66
self.label = label
77
self.choices = choices
88
self.default = default if default is not None else choices[0]
99
self.description = description
1010
self.coerce = coerce
11+
self.experimental = experimental

0 commit comments

Comments
 (0)