Check against current url_rule instead of matching a path with a regex

This commit is contained in:
Patrick Smith 2018-08-21 14:54:56 -04:00
parent 0631b69503
commit 92e1036e8a
2 changed files with 7 additions and 7 deletions

View File

@ -4,8 +4,8 @@
<ul> <ul>
{{ SidenavItem( {{ SidenavItem(
"Projects", "Projects",
href=url_for("workspaces.workspace_projects", workspace_id=123456), href=url_for("workspaces.workspace_projects", workspace_id=workspace.id),
active=g.matchesPath('\/workspaces\/[A-Za-z0-9]*\/projects'), active=request.url_rule.rule.startswith('/workspaces/<workspace_id>/projects'),
subnav=[ subnav=[
{ {
"label": "Add New Project", "label": "Add New Project",
@ -18,8 +18,8 @@
{{ SidenavItem( {{ SidenavItem(
"Members", "Members",
href=url_for("workspaces.workspace_members", workspace_id=123456), href=url_for("workspaces.workspace_members", workspace_id=workspace.id),
active=g.matchesPath('\/workspaces\/[A-Za-z0-9]*\/members'), active=request.url_rule.rule.startswith('/workspaces/<workspace_id>/members'),
subnav=[ subnav=[
{ {
"label": "Add New Member", "label": "Add New Member",
@ -32,8 +32,8 @@
{{ SidenavItem( {{ SidenavItem(
"Funding & Reports", "Funding & Reports",
href='/workspaces/123456/reports', href=url_for("workspaces.workspace_reports", workspace_id=workspace.id),
active=g.matchesPath('\/workspaces\/[A-Za-z0-9]*\/reports') active=request.url_rule.rule.startswith('/workspaces/<workspace_id>/reports')
) }} ) }}
</ul> </ul>
</nav> </nav>

View File

@ -8,7 +8,7 @@
<div class='block-list project-list-item'> <div class='block-list project-list-item'>
<header class='block-list__header'> <header class='block-list__header'>
<h2 class='block-list__title'>{{ project['name'] }} ({{ project['environments']|length }} environments)</h2> <h2 class='block-list__title'>{{ project['name'] }} ({{ project['environments']|length }} environments)</h2>
<a class='icon-link' href='/workspaces/123456/projects/789/edit'> <a class='icon-link' href=''>
{{ Icon('edit') }} {{ Icon('edit') }}
<span>edit</span> <span>edit</span>
</a> </a>