Skip to content

Commit 4e08d70

Browse files
committed
fix: render tag with link on workflow page
1 parent 3f974b1 commit 4e08d70

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

widgets/base_header.py

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
1+
import typing
12
import gooey_gui as gui
23

3-
from bots.models import Workflow
44
from daras_ai_v2 import icons
5+
from daras_ai_v2.fastapi_tricks import get_app_route_url
6+
from widgets.saved_workflow import render_pill_with_link
57
from widgets.author import render_author_as_breadcrumb
6-
from app_users.models import AppUser
7-
from daras_ai_v2.breadcrumbs import TitleBreadCrumbs
8-
from bots.models import PublishedRun, SavedRun
9-
from workspaces.models import Workspace
8+
from widgets.workflow_search import SearchFilters
109

1110

12-
def render_header_title(tb: TitleBreadCrumbs):
11+
if typing.TYPE_CHECKING:
12+
from app_users.models import AppUser
13+
from bots.models import PublishedRun, SavedRun, Workflow
14+
from daras_ai_v2.breadcrumbs import TitleBreadCrumbs
15+
from workspaces.models import Workspace
16+
17+
18+
def render_header_title(tb: "TitleBreadCrumbs"):
1319
with (
1420
gui.styled("""
1521
& h1 { margin: 0 }
@@ -20,7 +26,7 @@ def render_header_title(tb: TitleBreadCrumbs):
2026
gui.write("# " + tb.title_with_prefix_url())
2127

2228

23-
def render_help_button(workflow: Workflow):
29+
def render_help_button(workflow: "Workflow"):
2430
meta = workflow.get_or_create_metadata()
2531
if not meta.help_url:
2632
return
@@ -39,13 +45,15 @@ def render_help_button(workflow: Workflow):
3945

4046

4147
def render_breadcrumbs_with_author(
42-
breadcrumbs: TitleBreadCrumbs,
48+
breadcrumbs: "TitleBreadCrumbs",
4349
*,
44-
user: AppUser | None = None,
45-
pr: PublishedRun,
46-
sr: SavedRun,
47-
current_workspace: Workspace | None = None,
50+
pr: "PublishedRun",
51+
sr: "SavedRun",
52+
user: typing.Optional["AppUser"] = None,
53+
current_workspace: typing.Optional["Workspace"] = None,
4854
):
55+
from routers.root import explore_page
56+
4957
with gui.div(
5058
className="d-flex flex-wrap align-items-center container-margin-reset"
5159
):
@@ -62,14 +70,16 @@ def render_breadcrumbs_with_author(
6270
with gui.div(className="d-flex align-items-center"):
6371
gui.write("by", className="me-2 d-none d-md-block text-muted")
6472
render_author_as_breadcrumb(
65-
user=user,
66-
pr=pr,
67-
sr=sr,
68-
current_workspace=current_workspace,
73+
user=user, pr=pr, sr=sr, current_workspace=current_workspace
6974
)
7075

7176
if pr.saved_run_id != sr.id:
7277
return
7378

7479
for tag in pr.tags.all():
75-
tag.render(className="ms-2")
80+
query_params = SearchFilters(search=tag.name).get_query_params()
81+
render_pill_with_link(
82+
tag.render(),
83+
link_to=get_app_route_url(explore_page, query_params=query_params),
84+
className="ms-2 border",
85+
)

0 commit comments

Comments
 (0)