Skip to content

Commit

Permalink
make it easier to change order of sidebar items w/ the AdminExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
dill0wn authored and brondsem committed Mar 8, 2024
1 parent 9871bd9 commit 1ced114
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Allura/allura/ext/admin/admin_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def sidebar_menu(self):

for ep_name in sorted(g.entry_points['admin'].keys()):
admin_extension = g.entry_points['admin'][ep_name]
admin_extension().update_project_sidebar_menu(links)
links = (admin_extension().update_project_sidebar_menu(links) or links)

return links

Expand Down
8 changes: 6 additions & 2 deletions Allura/allura/lib/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from hashlib import sha256
from base64 import b64encode
from datetime import datetime, timedelta
import typing
import calendar
import six

Expand Down Expand Up @@ -60,6 +61,9 @@
from allura.tasks import activity_tasks
from allura.tasks.index_tasks import solr_del_project_artifacts

if typing.TYPE_CHECKING:
from allura.app import SitemapEntry

log = logging.getLogger(__name__)


Expand Down Expand Up @@ -1800,7 +1804,7 @@ class AdminExtension:

project_admin_controllers = {}

def update_project_sidebar_menu(self, sidebar_links):
def update_project_sidebar_menu(self, sidebar_links: list['SitemapEntry']) -> list['SitemapEntry']:
"""
Implement this function to modify the project sidebar.
Check `c.project` if you want to limit when this displays
Expand All @@ -1811,7 +1815,7 @@ def update_project_sidebar_menu(self, sidebar_links):
:rtype: ``None``
"""
pass
return sidebar_links


class SiteAdminExtension:
Expand Down
1 change: 1 addition & 0 deletions ForgeImporters/forgeimporters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ def update_project_sidebar_menu(self, sidebar_links):
base_url = c.project.url() + 'admin/ext/'
link = SitemapEntry('Import', base_url + 'import/')
sidebar_links.append(link)
return sidebar_links


def bytesio_parser(page):
Expand Down

0 comments on commit 1ced114

Please sign in to comment.