Mark active HTML5 object context action
CI / python (push) Has been cancelled
CI / rust (push) Has been cancelled

This commit is contained in:
2026-05-17 01:12:32 +03:00
parent 2a2786bc60
commit 9ff2cf3676
2 changed files with 18 additions and 2 deletions
+15 -2
View File
@@ -515,7 +515,7 @@ def render_html5_object_context(
<strong>{escape(str(name))}</strong>
<span>{escape(str(getattr(obj, "kind", "object")))}</span>
</article>
{_object_action_links(project_id, str(name), getattr(obj, "lineage_id", ""), modules)}
{_object_action_links(project_id, str(name), getattr(obj, "lineage_id", ""), modules, normalized_mode)}
<dl class="report-grid">
{_metric("Attrs", len(attributes))}
{_metric("Tables", len(sections))}
@@ -1541,7 +1541,13 @@ def _named_node_item(label: str, node: object) -> str:
"""
def _object_action_links(project_id: str, object_name: str, lineage_id: object, modules: Iterable[object]) -> str:
def _object_action_links(
project_id: str,
object_name: str,
lineage_id: object,
modules: Iterable[object],
active_mode: str,
) -> str:
quoted_project = quote(project_id)
quoted_object = quote(object_name, safe="")
lineage = str(lineage_id or "")
@@ -1565,6 +1571,9 @@ def _object_action_links(project_id: str, object_name: str, lineage_id: object,
if lineage
else ""
)
def active_attrs(mode: str) -> str:
return ' aria-current="page" data-html5-object-action-active="true"' if mode == active_mode else ""
return f"""
<nav class="object-actions" data-html5-object-actions>
<a
@@ -1573,6 +1582,7 @@ def _object_action_links(project_id: str, object_name: str, lineage_id: object,
hx-get="/html5/projects/{quoted_project}/objects/context/{quoted_object}"
hx-target="[data-html5-object-context]"
hx-swap="outerHTML"
{active_attrs("overview")}
>Overview</a>
<a
class="button"
@@ -1580,6 +1590,7 @@ def _object_action_links(project_id: str, object_name: str, lineage_id: object,
hx-get="/html5/projects/{quoted_project}/objects/context/{quoted_object}?mode=schema"
hx-target="[data-html5-object-context]"
hx-swap="outerHTML"
{active_attrs("schema")}
>Schema</a>
<a
class="button"
@@ -1587,6 +1598,7 @@ def _object_action_links(project_id: str, object_name: str, lineage_id: object,
hx-get="/html5/projects/{quoted_project}/objects/context/{quoted_object}?mode=impact"
hx-target="[data-html5-object-context]"
hx-swap="outerHTML"
{active_attrs("impact")}
>Impact</a>
<a
class="button"
@@ -1594,6 +1606,7 @@ def _object_action_links(project_id: str, object_name: str, lineage_id: object,
hx-get="/html5/projects/{quoted_project}/objects/context/{quoted_object}?mode=privacy"
hx-target="[data-html5-object-context]"
hx-swap="outerHTML"
{active_attrs("privacy")}
>Privacy</a>
<a
class="button"
+3
View File
@@ -324,6 +324,8 @@ def test_html5_object_context_fragment(tmp_path: Path):
assert "mode=privacy" in context.text
assert 'data-html5-object-mode="overview"' in context.text
assert "Object context · overview" in context.text
assert 'data-html5-object-action-active="true"' in context.text
assert 'aria-current="page"' in context.text
assert 'hx-target="[data-html5-object-context]"' in context.text
assert 'hx-target="[data-html5-flowchart]"' in context.text
assert 'hx-target="[data-html5-source]"' in context.text
@@ -371,6 +373,7 @@ def test_html5_object_context_fragment(tmp_path: Path):
assert schema_context.status_code == 200
assert 'data-html5-object-mode="schema"' in schema_context.text
assert "Object context · schema" in schema_context.text
assert 'data-html5-object-action-active="true"' in schema_context.text
assert "Контрагент" in schema_context.text
impact_context = client.get(