Skip to content

Commit 004ff66

Browse files
committed
control section opening from url
1 parent 2b8307e commit 004ff66

2 files changed

Lines changed: 60 additions & 8 deletions

File tree

dlt/_workspace/helpers/dashboard/dlt_dashboard.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,33 +1346,45 @@ def ui_controls(mo_cli_arg_with_test_identifiers: bool):
13461346
label="<small>Refresh</small>",
13471347
)
13481348

1349+
# read sections from query params to allow navigation via URL
1350+
# use #<cell_name> hash to scroll (e.g. #section_trace) — marimo scrolls to named cells
1351+
_open_sections = (cast(str, mo.query_params().get("sections")) or "").split(",")
1352+
13491353
# page switches
13501354
dlt_section_sync_switch: mo.ui.switch = mo.ui.switch(
13511355
value=True, label="sync" if mo_cli_arg_with_test_identifiers else ""
13521356
)
13531357
dlt_section_info_switch: mo.ui.switch = mo.ui.switch(
1354-
value=False, label="overview" if mo_cli_arg_with_test_identifiers else ""
1358+
value="overview" in _open_sections,
1359+
label="overview" if mo_cli_arg_with_test_identifiers else "",
13551360
)
13561361
dlt_section_schema_switch: mo.ui.switch = mo.ui.switch(
1357-
value=False, label="schema" if mo_cli_arg_with_test_identifiers else ""
1362+
value="schema" in _open_sections,
1363+
label="schema" if mo_cli_arg_with_test_identifiers else "",
13581364
)
13591365
dlt_section_browse_data_switch: mo.ui.switch = mo.ui.switch(
1360-
value=False, label="data" if mo_cli_arg_with_test_identifiers else ""
1366+
value="data" in _open_sections,
1367+
label="data" if mo_cli_arg_with_test_identifiers else "",
13611368
)
13621369
dlt_section_state_switch: mo.ui.switch = mo.ui.switch(
1363-
value=False, label="state" if mo_cli_arg_with_test_identifiers else ""
1370+
value="state" in _open_sections,
1371+
label="state" if mo_cli_arg_with_test_identifiers else "",
13641372
)
13651373
dlt_section_trace_switch: mo.ui.switch = mo.ui.switch(
1366-
value=False, label="trace" if mo_cli_arg_with_test_identifiers else ""
1374+
value="trace" in _open_sections,
1375+
label="trace" if mo_cli_arg_with_test_identifiers else "",
13671376
)
13681377
dlt_section_loads_switch: mo.ui.switch = mo.ui.switch(
1369-
value=False, label="loads" if mo_cli_arg_with_test_identifiers else ""
1378+
value="loads" in _open_sections,
1379+
label="loads" if mo_cli_arg_with_test_identifiers else "",
13701380
)
13711381
dlt_section_ibis_browser_switch: mo.ui.switch = mo.ui.switch(
1372-
value=False, label="ibis" if mo_cli_arg_with_test_identifiers else ""
1382+
value="ibis" in _open_sections,
1383+
label="ibis" if mo_cli_arg_with_test_identifiers else "",
13731384
)
13741385
dlt_section_data_quality_switch: mo.ui.switch = mo.ui.switch(
1375-
value=False, label="data_quality" if mo_cli_arg_with_test_identifiers else ""
1386+
value="data_quality" in _open_sections,
1387+
label="data_quality" if mo_cli_arg_with_test_identifiers else "",
13761388
)
13771389

13781390
# other switches

tests/e2e/helpers/dashboard/test_e2e.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,3 +412,43 @@ def test_broken_trace_pipeline(page: Page, broken_trace_pipeline: Any, pipelines
412412
# should also render the trace section, but there should be an error message
413413
_open_section(page, "trace")
414414
expect(page.get_by_text("Error while building trace section:")).to_be_visible()
415+
416+
417+
def test_sections_query_param(page: Page, fruit_pipeline: Any):
418+
"""Sections specified in ?sections= query param should be pre-opened."""
419+
# navigate with sections=trace,loads in the URL
420+
page.goto("http://localhost:2718/?pipeline=fruit_pipeline&sections=trace,loads")
421+
422+
# wait for the pipeline to load
423+
expect(page.get_by_role("switch", name="trace")).to_be_visible(timeout=20000)
424+
425+
# trace and loads switches should be checked
426+
expect(page.get_by_role("switch", name="trace")).to_be_checked()
427+
expect(page.get_by_role("switch", name="loads")).to_be_checked()
428+
429+
# other sections should NOT be checked
430+
expect(page.get_by_role("switch", name="overview")).not_to_be_checked()
431+
expect(page.get_by_role("switch", name="schema")).not_to_be_checked()
432+
expect(page.get_by_role("switch", name="data")).not_to_be_checked()
433+
expect(page.get_by_role("switch", name="state")).not_to_be_checked()
434+
435+
# verify the trace section content is actually visible
436+
expect(page.get_by_text(app_strings.trace_subtitle)).to_be_visible()
437+
438+
# verify loads section content is visible
439+
expect(page.get_by_role("row", name="fruitshop").nth(0)).to_be_visible()
440+
441+
442+
def test_sections_query_param_all(page: Page, fruit_pipeline: Any):
443+
"""All sections should open when all are specified in ?sections= query param."""
444+
page.goto(
445+
"http://localhost:2718/?pipeline=fruit_pipeline"
446+
"&sections=overview,schema,data,state,trace,loads"
447+
)
448+
449+
# wait for the pipeline to load
450+
expect(page.get_by_role("switch", name="overview")).to_be_visible(timeout=20000)
451+
452+
# all specified switches should be checked
453+
for section in ["overview", "schema", "data", "state", "trace", "loads"]:
454+
expect(page.get_by_role("switch", name=section)).to_be_checked()

0 commit comments

Comments
 (0)