Skip to content

Menu link for BaseView is determined by last @expose method (by alphabetical order), not by explicit identity or first @expose #915

@mrpavelgoodman

Description

@mrpavelgoodman

Checklist

  • The bug is reproducible against the latest release or master.
  • There are no similar issues or pull requests to fix it yet.

Describe the bug

Hello!
When using BaseView with multiple methods decorated by @expose, the link that appears in the admin menu is determined by the last method (by alphabetical order) with @expose, regardless of the identity parameter or the order in the class.
Expected behavior:
The menu link should be determined by either:
The first method with @expose (by code order), or
The method with a specific identity (if set), or
Allow explicit control (e.g. via a class attribute or parameter).
Actual behavior:
The menu link always points to the endpoint of the last method (by alphabetical order) with @expose.
Even if I set identity explicitly in the class or in the decorator, it gets overwritten.

class OrdersView(BaseView):
    name = "Orders"
    identity = "ordersview"

    @expose("/orders", identity="ordersview", methods=["GET"])
    async def orders_list(self, request):
        ...

    @expose("/orders/bulk-action", methods=["POST"])
    async def orders_bulk_action(self, request):
        ...

In this case, the menu link points to /orders/bulk-action instead of /orders.
Why this is a problem:
It is not intuitive and makes it impossible to control which endpoint is shown in the menu without hacks (like renaming methods).
Explicit identity is ignored if there are multiple @expose methods.
Suggested solution:
Assign identity only once (for the first @expose method found), or
Allow explicit control via a class attribute or decorator parameter, or
Document the current behavior and recommend best practices.
Thank you for your work on this great project!

Steps to reproduce the bug

No response

Expected behavior

No response

Actual behavior

No response

Debugging material

No response

Environment

  • SQLAdmin version: 0.20.1
  • Python version: 3.11
  • Database: PostgreSQL 15
  • Running inside Docker: yes
  • OS: Ubuntu 22.04 (inside container)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions