Introduce component architecture and menu component

- Introduce base class for all apps that will contain components. With
  unittests.

- Introduce base classes for components. With unittests.

- Turn Menu class into an app component.

  - Further cleanup Menu class.

  - Update tests.

  - Maintain a global list of menu items and look them up easily. Generalize
    such that subsubmenus can later be merged into Menu class.

  - Cleanup scope of main menu initialization.

  - Use None instead of empty strings for various values. Ensure that
    printing short_description does not show 'None' in output.

  - Use enable/disable instead of promote/demote.

- Use menu component in all apps.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Sunil Mohan Adapa committed 2019-06-07 11:48:04 -07:00
1 parent 0eee8ddf65
commit b96d901071
61 files changed
+1527 -567

No files matched your search

+20 -5
View File
@@ -21,8 +21,9 @@ FreedomBox app for OpenSSH server.
from django.utils.translation import ugettext_lazy as _
from plinth import actions
from plinth import app as app_module
from plinth import cfg, menu
from plinth import service as service_module
from plinth.menu import main_menu
from plinth.views import ServiceView
from .manifest import backup
@@ -48,15 +49,29 @@ service = None
port_forwarding_info = [('TCP', 22)]
app = None
class SSHApp(app_module.App):
"""FreedomBox app for SSH."""
def __init__(self):
"""Create components for the app."""
super().__init__()
menu_item = menu.Menu('menu-ssh', name, None, 'fa-terminal',
'ssh:index', parent_url_name='system')
self.add(menu_item)
def init():
"""Intialize the ssh module."""
menu = main_menu.get('system')
menu.add_urlname(name, 'fa-terminal', 'ssh:index')
global app
app = SSHApp()
app.set_enabled(True)
global service
service = service_module.Service(
managed_services[0], name, ports=['ssh'], is_external=True)
service = service_module.Service(managed_services[0], name, ports=['ssh'],
is_external=True)
def setup(helper, old_version=None):