Skip to content

Commit bcbd3b3

Browse files
committed
Refactor batch component to utilize app state directly, streamline settings button implementation, and enhance toolbar layout by removing redundant settings button.
1 parent ec5a813 commit bcbd3b3

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

dashboard/components/batch.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@
99

1010
from fasthtml.common import *
1111
from monsterui.all import *
12-
from dashboard.state import get_state
12+
from dashboard.app import app
1313

1414
def create_batches_dropdown(batch_name: str) -> DropDownNavContainer:
1515
"""Create the metric batches dropdown menu."""
16-
state = get_state()
1716
return DropDownNavContainer(
1817
NavHeaderLi("metric batches"),
1918
*[
@@ -25,7 +24,7 @@ def create_batches_dropdown(batch_name: str) -> DropDownNavContainer:
2524
hx_target="#main-content",
2625
hx_indicator="#loading",
2726
cls=f"{'uk-active' if name == batch_name else ''}",
28-
)) for name in state.metric_batches
27+
)) for name in app.state.metric_batches
2928
],
3029
uk_dropdown="pos: bottom-right; boundary: window; shift: true; flip: true;")
3130

dashboard/components/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ def create_controls(batch_name: str) -> Card:
3131
cls="w-full",
3232
), ),
3333
cls="mb-4 uk-padding-small py-2 shadow-sm",
34-
)
34+
)

dashboard/components/settings.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,14 @@
1616
def create_settings_button(text: str, batch_name: str, action: str, tooltip: str) -> Li:
1717
"""Create a settings dropdown button."""
1818
return Li(
19-
DivLAligned(
20-
Button(
21-
P(text, cls="text-sm font-medium"),
22-
hx_post=f"/batch/{batch_name}/{action}",
23-
hx_target="#main-content",
24-
cls=ButtonT.ghost,
25-
uk_tooltip=tooltip,
26-
),
27-
cls="flex items-center justify-between w-full py-2",
28-
))
19+
A(
20+
text,
21+
hx_post=f"/batch/{batch_name}/{action}",
22+
hx_target="#main-content",
23+
cls="", # Remove ghost button style to match batch dropdown
24+
uk_tooltip=tooltip,
25+
)
26+
)
2927

3028
def create_settings_dropdown(batch_name: str) -> DropDownNavContainer:
3129
"""Create the settings dropdown menu."""
@@ -72,4 +70,7 @@ def create_settings_dropdown(batch_name: str) -> DropDownNavContainer:
7270
)
7371
])
7472

75-
return DropDownNavContainer(NavHeaderLi("settings"), *menu_items)
73+
return DropDownNavContainer(
74+
NavHeaderLi("settings"),
75+
*menu_items,
76+
)

dashboard/components/toolbar.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ def create_toolbar_buttons(batch_name: str) -> Div:
3030
uk_tooltip="Select metric batch to display",
3131
),
3232
create_batches_dropdown(batch_name),
33+
Button(
34+
DivLAligned(UkIcon("settings")),
35+
cls=ButtonT.secondary,
36+
uk_tooltip="Customize chart display settings",
37+
),
38+
create_settings_dropdown(batch_name),
3339
Button(
3440
DivLAligned(UkIcon("refresh-ccw")),
3541
hx_get=f"/batch/{batch_name}/refresh",
3642
hx_target="#main-content",
3743
cls=ButtonT.secondary,
3844
uk_tooltip="Refresh metrics data from source",
3945
),
40-
Button(
41-
DivLAligned(UkIcon("settings")),
42-
cls=ButtonT.secondary,
43-
uk_tooltip="Customize chart display settings",
44-
),
45-
create_settings_dropdown(batch_name),
4646
Button(
4747
DivLAligned(UkIcon("github")),
4848
cls=ButtonT.secondary,

0 commit comments

Comments
 (0)