Add option to hide plugin setting from auto-generated plugin setting page (#4767)

* Add option to hide plugin setting from auto-generated plugin setting page

* Change hide to hidden

* Added small note to docs about hidden settings

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>

---------

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
Lukas 2023-05-05 17:14:39 +02:00 committed by GitHub
parent 35d04c0357
commit d416e57ee3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -9,8 +9,10 @@
<table class='table table-striped table-condensed'>
<tbody>
{% for setting in plugin_settings %}
{% include "InvenTree/settings/setting.html" with key=setting plugin=plugin %}
{% for setting, value in plugin_settings.items %}
{% if not value.hidden %}
{% include "InvenTree/settings/setting.html" with key=setting plugin=plugin %}
{% endif %}
{% endfor %}
</tbody>
</table>

View File

@ -52,9 +52,17 @@ class PluginWithSettings(SettingsMixin, InvenTreePlugin):
MaxValueValidator(25)
]
},
'HIDDEN_SETTING': {
'name': _('Hidden Setting'),
'description': _('This setting is hidden from the automatically generated plugin settings page'),
'hidden': True,
}
}
```
!!! tip "Hidden Settings"
Plugin settings can be hidden from the settings page by marking them as 'hidden'
This mixin defines the helper functions `plugin.get_setting` and `plugin.set_setting` to access all plugin specific settings:
```python