S
Solara2mo ago
Rahon

hiding details page in navbar with AppLayout

Trying to implement a "details" page for one of my entities (Runs).

import solara
from webcrawler.models import Run

@solara.component
def Page(id: str = None):
run: Run = Run.objects.get(id=id)
if run is None:
with solara.Column() as main:
return solara.Markdown("Run not found")
return main
else:
with solara.Column() as main:
solara.Markdown(f"Run {run.id}")
solara.Markdown(f"Status: {run.status}")
solara.Markdown(f"Start: {run.start_time}")
solara.Markdown(f"End: {run.end_time}")
return main

import solara
from webcrawler.models import Run

@solara.component
def Page(id: str = None):
run: Run = Run.objects.get(id=id)
if run is None:
with solara.Column() as main:
return solara.Markdown("Run not found")
return main
else:
with solara.Column() as main:
solara.Markdown(f"Run {run.id}")
solara.Markdown(f"Status: {run.status}")
solara.Markdown(f"Start: {run.start_time}")
solara.Markdown(f"End: {run.end_time}")
return main
Everything works fine, the problem is, that i would like to not have this page shown in the navbar, while at the same time making use of the default AppLayout. I tried to specify the routes by hand:
routes = [
solara.Route(path="/", component=Page),
solara.Route(path="products", component=products.Page),
solara.Route(path="runs", component=runs.Page),
solara.Route(path="__run_details", component=run_details.Page),
]
routes = [
solara.Route(path="/", component=Page),
solara.Route(path="products", component=products.Page),
solara.Route(path="runs", component=runs.Page),
solara.Route(path="__run_details", component=run_details.Page),
]
But couldn't find a parameter which allows me to hide __run_details in the navbar (see attached image). I tried adding the __run_details path as a children of runs which doesn't work, since I cant have a wildcard path (along the lines of: solara.Route(path=":id", component=run_details.Page)) and would have to add every runs detail path during runtime in a loop, which to me doesn't seem sustainable. Another attempt was to have some logic inside runs Page function to return the details page, if ?id=1234234 was part of the query.
(runs Page)
@solara.component
def Page():
router = solara.use_router()

if router.search is not None:
parsed_values = urllib.parse.parse_qs(
router.search, keep_blank_values=True)
return Details(id=parsed_values['id'][0])
(runs Page)
@solara.component
def Page():
router = solara.use_router()

if router.search is not None:
parsed_values = urllib.parse.parse_qs(
router.search, keep_blank_values=True)
return Details(id=parsed_values['id'][0])

This approach led to a RuntimeError (after working once), claiming that too many hooks are being instantiated. Any ideas?
No description
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server