app: Add tags to menu and frontpage components

- Add typing information for init methods Info, Shortcut, and Menu to easily
  identify problems.

- Update docstrings for these components.

- Updates test cases to deal with tags instead of short description.

- Update custom shortcuts code to read tags and ignore short description.

- Update API to send tags instead of custom shortcuts.

- OpenVPN special treatment of info.description in Shortcut

Tests:

- All unit tests pass and type checking succeeds.

- All apps show icons with tags in apps and system section.

- In help section cards don't show tags.

- In front page, enabled apps show shortcuts with tags.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
This commit is contained in:
Sunil Mohan Adapa authored and Joseph Nuthalapati committed 2025-01-09 21:08:10 +05:30
1 parent 196a2deb6f
commit 89bce7a344
75 files changed
+278 -318

No files matched your search

-1
View File
@@ -1,6 +1,5 @@
{"shortcuts": [{
"name": "NextCloud",
"short_description": "File Hosting Service",
"description": [ "Nextcloud is a suite of client-server software for creating and using file hosting services." ],
"icon_url": "/plinth/custom/static/themes/default/icons/nextcloud.png",
"clients": [{
@@ -1,6 +1,5 @@
{"shortcuts": [{
"name": "NextCloud2",
"short_description": "File Hosting Service",
"description": [ "Nextcloud is a suite of client-server software for creating and using file hosting services." ],
"icon_url": "/plinth/custom/static/themes/default/icons/nextcloud.png",
"clients": [{
@@ -9,5 +8,6 @@
"type": "web",
"url": "/nextcloud"
}]
}]
}],
"tags": ["Groupware", "File sync"]
}]}
+2 -2
View File
@@ -1,6 +1,5 @@
{"shortcuts": [{
"name": "NextCloud",
"short_description": "File Hosting Service",
"description": [ "Nextcloud is a suite of client-server software for creating and using file hosting services." ],
"icon_url": "/plinth/custom/static/themes/default/icons/nextcloud.png",
"clients": [{
@@ -9,5 +8,6 @@
"type": "web",
"url": "/nextcloud"
}]
}]
}],
"tags": ["Groupware", "File sync"]
}]}
+4 -4
View File
@@ -438,10 +438,10 @@ def test_info_initialization_without_args():
assert info.name is None
assert info.icon is None
assert info.icon_filename is None
assert info.short_description is None
assert info.description is None
assert info.manual_page is None
assert info.clients is None
assert info.tags == []
def test_info_initialization_with_args():
@@ -455,17 +455,17 @@ def test_info_initialization_with_args():
}]
info = Info('test-app', 3, is_essential=True, depends=['test-app-2'],
name='Test App', icon='fa-test', icon_filename='test-icon',
short_description='For Test', description='Test description',
manual_page='Test', clients=clients)
description='Test description', manual_page='Test',
clients=clients, tags=['tag1', 'tag2'])
assert info.is_essential
assert info.depends == ['test-app-2']
assert info.name == 'Test App'
assert info.icon == 'fa-test'
assert info.icon_filename == 'test-icon'
assert info.short_description == 'For Test'
assert info.description == 'Test description'
assert info.manual_page == 'Test'
assert info.clients == clients
assert info.tags == ['tag1', 'tag2']
def test_info_clients_validation():
+7 -10
View File
@@ -26,13 +26,13 @@ def test_shortcut_init_with_arguments():
shortcut = Shortcut('test-component', 'test-name')
assert shortcut.component_id == 'test-component'
assert shortcut.name == 'test-name'
assert shortcut.short_description is None
assert shortcut.url == '?selected=test-component'
assert shortcut.icon is None
assert shortcut.description is None
assert shortcut.manual_page is None
assert shortcut.configure_url is None
assert shortcut.clients is None
assert shortcut.tags is None
assert not shortcut.login_required
assert shortcut.allowed_groups is None
assert Shortcut._all_shortcuts['test-component'] == shortcut
@@ -42,19 +42,19 @@ def test_shortcut_init():
"""Test initializing shortcut component."""
clients = ['client1', 'client2']
allowed_groups = ['group1', 'group2']
shortcut = Shortcut('test-component', name='test-name',
short_description='test-short-description',
url='test-url', icon='test-icon',
description='test-description', manual_page='TestPage',
shortcut = Shortcut('test-component', name='test-name', url='test-url',
icon='test-icon', description='test-description',
manual_page='TestPage',
configure_url='test-configure-url', clients=clients,
login_required=True, allowed_groups=allowed_groups)
assert shortcut.short_description == 'test-short-description'
tags=['tag1', 'tag2'], login_required=True,
allowed_groups=allowed_groups)
assert shortcut.url == 'test-url'
assert shortcut.icon == 'test-icon'
assert shortcut.description == 'test-description'
assert shortcut.manual_page == 'TestPage'
assert shortcut.configure_url == 'test-configure-url'
assert shortcut.clients == clients
assert shortcut.tags == ['tag1', 'tag2']
assert shortcut.login_required
assert shortcut.allowed_groups == set(allowed_groups)
@@ -91,9 +91,6 @@ def test_shortcut_list_sorting(common_shortcuts):
return_list = Shortcut.list(sort_by='name')
assert return_list == [cuts[0], cuts[1], cuts[2], cuts[3]]
return_list = Shortcut.list(sort_by='short_description')
assert return_list == [cuts[3], cuts[2], cuts[1], cuts[0]]
def test_shortcut_list_web_apps_only(common_shortcuts):
"""Test listing only web app shortcuts."""
+7 -7
View File
@@ -27,8 +27,8 @@ def build_menu(size=5):
kwargs = {
'component_id': f'menu-test-{index}',
'name': f'Name{index}',
'short_description': f'ShortDescription{index}',
'icon': f'Icon{index}',
'tags': ['tag1', 'tag2'],
'url_name': f'test{index}',
'url_kwargs': {
'a': index,
@@ -73,8 +73,8 @@ def test_menu_creation_without_arguments():
menu = Menu('menu-index', url_name='index')
assert menu.component_id == 'menu-index'
assert menu.name is None
assert menu.short_description is None
assert menu.icon is None
assert menu.tags is None
assert menu.url == '/'
assert menu.order == 50
assert not menu.advanced
@@ -84,23 +84,23 @@ def test_menu_creation_without_arguments():
def test_menu_creation_with_arguments():
"""Verify the Menu state with initialization parameters."""
expected_name = 'Name'
expected_short_description = 'ShortDescription'
expected_icon = 'Icon'
expected_tags = ['tag1', 'tag2']
url_name = 'test'
url_kwargs = {'a': 1, 'b': 2, 'c': 3}
expected_url = reverse(url_name, kwargs=url_kwargs)
expected_order = 42
parent_menu = Menu('menu-index', url_name='index')
menu = Menu('menu-test', expected_name, expected_short_description,
expected_icon, url_name, url_kwargs=url_kwargs,
parent_url_name='index', order=expected_order, advanced=True)
menu = Menu('menu-test', expected_name, expected_icon, expected_tags,
url_name, url_kwargs=url_kwargs, parent_url_name='index',
order=expected_order, advanced=True)
assert menu.parent_url_name == 'index'
assert len(parent_menu.items) == 1
assert parent_menu.items[0] == menu
assert expected_name == menu.name
assert expected_short_description == menu.short_description
assert expected_icon == menu.icon
assert expected_tags == menu.tags
assert expected_url == menu.url
assert expected_order == menu.order
assert menu.advanced