From 93da15c0eef0cf2d598a823d88a3c0c5dda3230c Mon Sep 17 00:00:00 2001 From: Hao Liu <44379968+TheRealHaoLiu@users.noreply.github.com> Date: Tue, 19 Mar 2024 15:08:41 -0400 Subject: [PATCH] Setting modification to address requests from UI_NEXT devs (#14996) Modification to settings - Add hidden to indicate to UI_NEXT to hide the field - Add warning_text to indicate to UI_NEXT to display the warning when specific setting is modified - Address some non required field being marked as required --- awx/api/conf.py | 1 + awx/api/metadata.py | 2 ++ awx/conf/conf.py | 1 + awx/conf/registry.py | 4 ++++ awx/main/conf.py | 6 ++++++ awx/ui/conf.py | 2 ++ 6 files changed, 16 insertions(+) diff --git a/awx/api/conf.py b/awx/api/conf.py index 0697f40c56..72aaf3eec3 100644 --- a/awx/api/conf.py +++ b/awx/api/conf.py @@ -93,6 +93,7 @@ register( default='', label=_('Login redirect override URL'), help_text=_('URL to which unauthorized users will be redirected to log in. If blank, users will be sent to the login page.'), + warning_text=_('Changing the redirect URL could impact the ability to login if local authentication is also disabled.'), category=_('Authentication'), category_slug='authentication', ) diff --git a/awx/api/metadata.py b/awx/api/metadata.py index 4218946890..5adb7d8f12 100644 --- a/awx/api/metadata.py +++ b/awx/api/metadata.py @@ -36,11 +36,13 @@ class Metadata(metadata.SimpleMetadata): field_info = OrderedDict() field_info['type'] = self.label_lookup[field] field_info['required'] = getattr(field, 'required', False) + field_info['hidden'] = getattr(field, 'hidden', False) text_attrs = [ 'read_only', 'label', 'help_text', + 'warning_text', 'min_length', 'max_length', 'min_value', diff --git a/awx/conf/conf.py b/awx/conf/conf.py index 019bd1d068..69aa5d3515 100644 --- a/awx/conf/conf.py +++ b/awx/conf/conf.py @@ -55,6 +55,7 @@ register( # Optional; category_slug will be slugified version of category if not # explicitly provided. category_slug='cows', + hidden=True, ) diff --git a/awx/conf/registry.py b/awx/conf/registry.py index da056e99db..fdce19b305 100644 --- a/awx/conf/registry.py +++ b/awx/conf/registry.py @@ -127,6 +127,8 @@ class SettingsRegistry(object): encrypted = bool(field_kwargs.pop('encrypted', False)) defined_in_file = bool(field_kwargs.pop('defined_in_file', False)) unit = field_kwargs.pop('unit', None) + hidden = field_kwargs.pop('hidden', False) + warning_text = field_kwargs.pop('warning_text', None) if getattr(field_kwargs.get('child', None), 'source', None) is not None: field_kwargs['child'].source = None field_instance = field_class(**field_kwargs) @@ -134,12 +136,14 @@ class SettingsRegistry(object): field_instance.category = category field_instance.depends_on = depends_on field_instance.unit = unit + field_instance.hidden = hidden if placeholder is not empty: field_instance.placeholder = placeholder field_instance.defined_in_file = defined_in_file if field_instance.defined_in_file: field_instance.help_text = str(_('This value has been set manually in a settings file.')) + '\n\n' + str(field_instance.help_text) field_instance.encrypted = encrypted + field_instance.warning_text = warning_text original_field_instance = field_instance if field_class != original_field_class: original_field_instance = original_field_class(**field_kwargs) diff --git a/awx/main/conf.py b/awx/main/conf.py index e50aac8caf..b05c4e70c9 100644 --- a/awx/main/conf.py +++ b/awx/main/conf.py @@ -92,6 +92,7 @@ register( ), category=_('System'), category_slug='system', + required=False, ) register( @@ -774,6 +775,7 @@ register( allow_null=True, category=_('System'), category_slug='system', + required=False, ) register( 'AUTOMATION_ANALYTICS_LAST_ENTRIES', @@ -815,6 +817,7 @@ register( help_text=_('Max jobs to allow bulk jobs to launch'), category=_('Bulk Actions'), category_slug='bulk', + hidden=True, ) register( @@ -825,6 +828,7 @@ register( help_text=_('Max number of hosts to allow to be created in a single bulk action'), category=_('Bulk Actions'), category_slug='bulk', + hidden=True, ) register( @@ -835,6 +839,7 @@ register( help_text=_('Max number of hosts to allow to be deleted in a single bulk action'), category=_('Bulk Actions'), category_slug='bulk', + hidden=True, ) register( @@ -845,6 +850,7 @@ register( help_text=_('Enable preview of new user interface.'), category=_('System'), category_slug='system', + hidden=True, ) register( diff --git a/awx/ui/conf.py b/awx/ui/conf.py index 3e87620add..fa8a2ead52 100644 --- a/awx/ui/conf.py +++ b/awx/ui/conf.py @@ -59,6 +59,7 @@ register( help_text=_('Maximum number of job events for the UI to retrieve within a single request.'), category=_('UI'), category_slug='ui', + hidden=True, ) register( @@ -68,4 +69,5 @@ register( help_text=_('If disabled, the page will not refresh when events are received. Reloading the page will be required to get the latest details.'), category=_('UI'), category_slug='ui', + hidden=True, )