mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
app: Add ability to hide configuration form when app is disabled
- Some apps store their configuration in database. The database server may not be running when app is disabled. Configuration changes may then not be possible for such apps. Provide the ability to disable configuration for apps that don't support configuration changes when disabled. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
717e8cd7f5
commit
524fdf6049
@ -42,6 +42,10 @@ class App:
|
||||
the app. This flag is currently set during backup and restore operations
|
||||
but UI changes are currently not implemented.
|
||||
|
||||
'configure_when_disabled' is a boolean indicating whether the app can
|
||||
configured while it is disabled. Some apps such those whose configuration
|
||||
is stored in a database can't be configured while they are disabled because
|
||||
the database server may not be running when the app is disabled.
|
||||
"""
|
||||
|
||||
app_id: str | None = None
|
||||
@ -51,6 +55,8 @@ class App:
|
||||
locked: bool = False # Whether user interaction with the app is allowed.
|
||||
# XXX: Lockdown the application UI by implementing a middleware
|
||||
|
||||
configure_when_disabled: bool = True
|
||||
|
||||
_all_apps: ClassVar[collections.OrderedDict[
|
||||
str, 'App']] = collections.OrderedDict()
|
||||
|
||||
|
||||
@ -67,6 +67,9 @@ def test_app_instantiation():
|
||||
assert app.app_id == 'test-app'
|
||||
assert app._all_apps['test-app'] == app
|
||||
assert len(app._all_apps) == 1
|
||||
assert app.can_be_disabled
|
||||
assert not app.locked
|
||||
assert app.configure_when_disabled
|
||||
|
||||
|
||||
def test_app_get():
|
||||
|
||||
@ -215,6 +215,11 @@ class AppView(FormView):
|
||||
if not self.form_class:
|
||||
return None
|
||||
|
||||
if not self.app.configure_when_disabled:
|
||||
status = self.get_common_status()
|
||||
if not status['is_enabled']:
|
||||
return None
|
||||
|
||||
return super().get_form(*args, **kwargs)
|
||||
|
||||
def _get_common_status(self):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user