Mark active HTML5 object context action
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user