mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
apps: Separate enabled and disabled apps
- Add 'secondary' flag to menu items. - Mark apps as 'secondary' when disabled. - Extend TemplateView for apps index. - Add card-container for disabled apps. Closes #1309 Signed-off-by: James Valleroy <jvalleroy@mailbox.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
1 parent
fe16bf4d26
commit
893bd2b4d6
27 files changed
+295
-103
No files matched your search
+32
-2
@@ -23,7 +23,8 @@ from plinth.utils import format_lazy
|
||||
class Menu(object):
|
||||
"""One menu item."""
|
||||
|
||||
def __init__(self, name="",short_description="", label="", icon="", url="#", order=50):
|
||||
def __init__(self, name="", short_description="", label="", icon="",
|
||||
url="#", order=50):
|
||||
"""label is the text that is displayed on the menu.
|
||||
|
||||
icon is the icon to be displayed next to the label.
|
||||
@@ -47,6 +48,7 @@ class Menu(object):
|
||||
self.icon = icon
|
||||
self.url = url
|
||||
self.order = order
|
||||
self.secondary = True
|
||||
# TODO: With an ordered dictionary for self.items we could access the
|
||||
# items by their URL directly instead of searching for them each time,
|
||||
# which we do currently with the 'get' method
|
||||
@@ -84,8 +86,10 @@ class Menu(object):
|
||||
return it.
|
||||
|
||||
"""
|
||||
item = Menu(name=name, short_description=short_description, label=label, icon=icon, url=url, order=order)
|
||||
item = Menu(name=name, short_description=short_description,
|
||||
label=label, icon=icon, url=url, order=order)
|
||||
self.items.append(item)
|
||||
|
||||
return item
|
||||
|
||||
def active_item(self, request):
|
||||
@@ -94,6 +98,32 @@ class Menu(object):
|
||||
if request.path.startswith(str(item.url)):
|
||||
return item
|
||||
|
||||
def promote_item(self, urlname, url_args=None, url_kwargs=None):
|
||||
"""Promote a secondary item to an item."""
|
||||
found_item = None
|
||||
url = reverse(urlname, args=url_args, kwargs=url_kwargs)
|
||||
for item in self.items:
|
||||
if str(item.url) == url:
|
||||
found_item = item
|
||||
|
||||
if found_item:
|
||||
found_item.secondary = False
|
||||
else:
|
||||
raise KeyError('Menu item not found')
|
||||
|
||||
def demote_item(self, urlname, url_args=None, url_kwargs=None):
|
||||
"""Demote an item to a secondary item."""
|
||||
found_item = None
|
||||
url = reverse(urlname, args=url_args, kwargs=url_kwargs)
|
||||
for item in self.items:
|
||||
if str(item.url) == url:
|
||||
found_item = item
|
||||
|
||||
if found_item:
|
||||
found_item.secondary = True
|
||||
else:
|
||||
raise KeyError('Menu item not found')
|
||||
|
||||
|
||||
main_menu = Menu()
|
||||
|
||||
|
||||
Reference in new issue
Block a user