mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Flag HTMX navigation as an experimental feature
This commit is contained in:
@ -22,6 +22,7 @@ PREFERENCES = {
|
|||||||
('dark', _('Dark')),
|
('dark', _('Dark')),
|
||||||
),
|
),
|
||||||
default='light',
|
default='light',
|
||||||
|
description=_('Preferred default UI theme')
|
||||||
),
|
),
|
||||||
'ui.htmx_navigation': UserPreference(
|
'ui.htmx_navigation': UserPreference(
|
||||||
label=_('HTMX Navigation'),
|
label=_('HTMX Navigation'),
|
||||||
@ -29,14 +30,17 @@ PREFERENCES = {
|
|||||||
('', _('Disabled')),
|
('', _('Disabled')),
|
||||||
('true', _('Enabled')),
|
('true', _('Enabled')),
|
||||||
),
|
),
|
||||||
default=False
|
description=_('Enable dynamic UI navigation'),
|
||||||
|
default=False,
|
||||||
|
experimental=True
|
||||||
),
|
),
|
||||||
'locale.language': UserPreference(
|
'locale.language': UserPreference(
|
||||||
label=_('Language'),
|
label=_('Language'),
|
||||||
choices=(
|
choices=(
|
||||||
('', _('Auto')),
|
('', _('Auto')),
|
||||||
*settings.LANGUAGES,
|
*settings.LANGUAGES,
|
||||||
)
|
),
|
||||||
|
description=_('Forces UI translation to the specified language.')
|
||||||
),
|
),
|
||||||
'pagination.per_page': UserPreference(
|
'pagination.per_page': UserPreference(
|
||||||
label=_('Page length'),
|
label=_('Page length'),
|
||||||
@ -51,8 +55,8 @@ PREFERENCES = {
|
|||||||
('top', _('Top')),
|
('top', _('Top')),
|
||||||
('both', _('Both')),
|
('both', _('Both')),
|
||||||
),
|
),
|
||||||
description=_('Where the paginator controls will be displayed relative to a table'),
|
default='bottom',
|
||||||
default='bottom'
|
description=_('Where the paginator controls will be displayed relative to a table')
|
||||||
),
|
),
|
||||||
|
|
||||||
# Miscellaneous
|
# Miscellaneous
|
||||||
@ -62,6 +66,7 @@ PREFERENCES = {
|
|||||||
('json', 'JSON'),
|
('json', 'JSON'),
|
||||||
('yaml', 'YAML'),
|
('yaml', 'YAML'),
|
||||||
),
|
),
|
||||||
|
description=_('The preferred syntax for displaying generic data within the UI')
|
||||||
),
|
),
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
{% trans "Clear table preferences" %}
|
{% trans "Clear table preferences" %}
|
||||||
</label>
|
</label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
|
<div class="card">
|
||||||
<table class="table table-hover object-list">
|
<table class="table table-hover object-list">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -64,6 +65,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="col-9 offset-3">
|
<div class="col-9 offset-3">
|
||||||
<p class="text-muted">{% trans "None found" %}</p>
|
<p class="text-muted">{% trans "None found" %}</p>
|
||||||
|
@ -3,7 +3,7 @@ from django.conf import settings
|
|||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from django.contrib.postgres.forms import SimpleArrayField
|
from django.contrib.postgres.forms import SimpleArrayField
|
||||||
from django.core.exceptions import FieldError
|
from django.core.exceptions import FieldError
|
||||||
from django.utils.html import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from core.models import ObjectType
|
from core.models import ObjectType
|
||||||
@ -37,7 +37,14 @@ class UserConfigFormMetaclass(forms.models.ModelFormMetaclass):
|
|||||||
preference_fields = {}
|
preference_fields = {}
|
||||||
for field_name, preference in PREFERENCES.items():
|
for field_name, preference in PREFERENCES.items():
|
||||||
description = f'{preference.description}<br />' if preference.description else ''
|
description = f'{preference.description}<br />' if preference.description else ''
|
||||||
help_text = f'{description}<code>{field_name}</code>'
|
help_text = f'<code>{field_name}</code>'
|
||||||
|
if preference.description:
|
||||||
|
help_text = f'{preference.description}<br />{help_text}'
|
||||||
|
if preference.experimental:
|
||||||
|
help_text = (
|
||||||
|
f'<span class="text-danger"><i class="mdi mdi-alert"></i> Experimental feature</span><br />'
|
||||||
|
f'{help_text}'
|
||||||
|
)
|
||||||
field_kwargs = {
|
field_kwargs = {
|
||||||
'label': preference.label,
|
'label': preference.label,
|
||||||
'choices': preference.choices,
|
'choices': preference.choices,
|
||||||
|
@ -2,9 +2,10 @@ class UserPreference:
|
|||||||
"""
|
"""
|
||||||
Represents a configurable user preference.
|
Represents a configurable user preference.
|
||||||
"""
|
"""
|
||||||
def __init__(self, label, choices, default=None, description='', coerce=lambda x: x):
|
def __init__(self, label, choices, default=None, description='', coerce=lambda x: x, experimental=False):
|
||||||
self.label = label
|
self.label = label
|
||||||
self.choices = choices
|
self.choices = choices
|
||||||
self.default = default if default is not None else choices[0]
|
self.default = default if default is not None else choices[0]
|
||||||
self.description = description
|
self.description = description
|
||||||
self.coerce = coerce
|
self.coerce = coerce
|
||||||
|
self.experimental = experimental
|
||||||
|
Reference in New Issue
Block a user