Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: add_to_menu=False in CustomView results in the view to be in the menu #206

Closed
dfioravanti opened this issue Jun 6, 2023 · 0 comments · Fixed by #217
Closed

Bug: add_to_menu=False in CustomView results in the view to be in the menu #206

dfioravanti opened this issue Jun 6, 2023 · 0 comments · Fixed by #217
Labels
bug Something isn't working

Comments

@dfioravanti
Copy link

Describe the bug
If I set add_to_menu=False in a CustomView the view is added to the menu.

To Reproduce

The minimum working version that shows the bug is

from fastapi import FastAPI
from starlette.requests import Request
from starlette.responses import Response
from starlette.templating import Jinja2Templates
from starlette_admin import CustomView

from sqlalchemy import create_engine
from starlette_admin.contrib.sqla import Admin


engine = create_engine("sqlite:///test.db", connect_args={"check_same_thread": False})

app = FastAPI()

admin = Admin(engine)


class HomeView(CustomView):
    async def render(self, request: Request, templates: Jinja2Templates) -> Response:
        return templates.TemplateResponse(
            "home.html",
        )


admin.add_view(
    HomeView(
        label="This should not be visible",
        icon="fa fa-home",
        path="/home",
        add_to_menu=False,
    ),
)

admin.mount_to(app)

Then if I run the app and go on <host>/admin I see

Screenshot 2023-06-06 at 14 44 28

Environment (please complete the following information):

  • Starlette-Admin version: 0.9
  • ORM/ODMs: SQLAlchemy

Additional context

This happens even if the view is added to a DropDown. Not sure if it helps but maybe

@dfioravanti dfioravanti added the bug Something isn't working label Jun 6, 2023
jowilf added a commit that referenced this issue Jun 6, 2023
@jowilf jowilf closed this as completed in 019dc95 Jun 6, 2023
@jowilf jowilf mentioned this issue Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant