24
24
25
25
26
26
class SortOption (typing .NamedTuple ):
27
- key : str
28
27
label : str
29
28
icon : str
30
29
@@ -34,31 +33,28 @@ class SortOption(typing.NamedTuple):
34
33
35
34
class SortOptions (SortOption , GooeyEnum ):
36
35
FEATURED = SortOption (
37
- key = "featured" ,
38
36
label = "Featured" ,
39
37
icon = f'<i class="fa-solid fa-star" style="width: { _icon_width } ;"></i>' ,
40
38
)
41
39
UPDATED_AT = SortOption (
42
- key = "last_updated" ,
43
40
label = "Last Updated" ,
44
41
icon = f'<i class="fa-solid fa-clock" style="width: { _icon_width } ;"></i>' ,
45
42
)
46
43
CREATED_AT = SortOption (
47
- key = "created_at" ,
48
44
label = "Created At" ,
49
45
icon = f'<i class="fa-solid fa-calendar" style="width: { _icon_width } ;"></i>' ,
50
46
)
51
47
MOST_RUNS = SortOption (
52
- key = "most_runs" ,
53
48
label = "Most Runs" ,
54
49
icon = f'<i class="fa-solid fa-chart-line" style="width: { _icon_width } ;"></i>' ,
55
50
)
56
51
57
52
@classmethod
58
- def get (cls , key = None , default = None ):
59
- return next (
60
- (option for option in cls if option .key == key ), default or cls .FEATURED
61
- )
53
+ def get (cls , key = None ):
54
+ return super ().get (key , default = cls .FEATURED )
55
+
56
+ def html_icon_label (self ) -> str :
57
+ return f'{ self .icon } <span class="hide-on-small-screens"> { self .label } </span>'
62
58
63
59
64
60
class SearchFilters (BaseModel ):
@@ -117,12 +113,6 @@ def render_search_filters(
117
113
with gui .div (
118
114
className = f"{ col_class } d-flex gap-2 justify-content-end align-items-center" ,
119
115
):
120
- sort_options : dict [str , str ] = {
121
- (opt .key if opt != SortOptions .get () else "" ): (
122
- f'{ opt .icon } <span class="hide-on-small-screens"> { opt .label } </span>'
123
- )
124
- for opt in SortOptions
125
- }
126
116
with (
127
117
gui .styled (
128
118
"""
@@ -140,6 +130,12 @@ def render_search_filters(
140
130
),
141
131
gui .div (),
142
132
):
133
+ sort_options = {
134
+ opt .name if opt != SortOptions .get () else None : (
135
+ opt .html_icon_label ()
136
+ )
137
+ for opt in SortOptions
138
+ }
143
139
search_filters .sort = (
144
140
gui .selectbox (
145
141
label = "" ,
@@ -379,7 +375,7 @@ def _render_run(pr: PublishedRun):
379
375
show_workspace_author = not bool (search_filters and search_filters .workspace )
380
376
is_member = bool (getattr (pr , "is_member" , False ))
381
377
hide_last_editor = bool (pr .workspace_id and not is_member )
382
- show_run_count = is_member or search_filters .sort == SortOptions .MOST_RUNS .value
378
+ show_run_count = is_member or search_filters .sort == SortOptions .MOST_RUNS .name
383
379
384
380
render_saved_workflow_preview (
385
381
workflow .page_cls ,
0 commit comments