Skip to content

Commit 68db8a6

Browse files
committed
fix: make workflow tag links clickable
1 parent ef33f6d commit 68db8a6

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

bots/models/published_run.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from bots.admin_links import open_in_new_tab
1313
from bots.custom_fields import CustomURLField
1414
from daras_ai_v2.crypto import get_random_doc_id
15+
from daras_ai_v2.fastapi_tricks import get_app_route_url
1516
from gooeysite.custom_create import get_or_create_lazy
1617
from workspaces.models import Workspace
1718

@@ -432,14 +433,30 @@ class Tag(models.Model):
432433
def __str__(self):
433434
return self.name
434435

435-
def render(self) -> str:
436-
return f"{self.icon} {self.name}" if self.icon else self.name
436+
def render(self, **props) -> None:
437+
import gooey_gui as gui
438+
439+
className = (
440+
props.pop("className", "") + " badge rounded-pill border text-bg-light"
441+
)
442+
with gui.div(className=className, **props), gui.link(to=self.get_app_url()):
443+
gui.html(f"{self.icon} {self.name}" if self.icon else self.name)
437444

438445
@classmethod
439446
@cache
440447
def get_options(cls) -> list["Tag"]:
441448
return list(cls.objects.all())
442449

450+
def get_app_url(self, query_params: dict | None = None) -> str:
451+
from routers.root import explore_page
452+
453+
if not query_params:
454+
query_params = {}
455+
return get_app_route_url(
456+
explore_page,
457+
query_params=(query_params | {"search": self.name}),
458+
)
459+
443460
class Meta:
444461
constraints = [
445462
models.UniqueConstraint(

widgets/base_header.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ def render_breadcrumbs_with_author(
7272
return
7373

7474
for tag in pr.tags.all():
75-
gui.pill(tag.render(), className="ms-2", unsafe_allow_html=True)
75+
tag.render(className="ms-2")

widgets/saved_workflow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def render_title_pills(published_run: PublishedRun, workflow_pill: str | None):
123123
gui.html(label)
124124

125125
for tag in published_run.tags.all():
126-
gui.pill(tag.render(), className="ms-2", unsafe_allow_html=True)
126+
tag.render(className="ms-2")
127127

128128

129129
FOOTER_CSS = """

0 commit comments

Comments
 (0)