{% from "components/sidenav_item.html" import SidenavItem %}

<nav class='sidenav workspace-navigation'>
  <ul>
    {{ SidenavItem(
      "Projects",
      href=url_for("workspaces.workspace_projects", workspace_id=workspace.id),
      active=request.url_rule.rule.startswith('/workspaces/<workspace_id>/projects'),
      subnav=None if not user_can(permissions.ADD_APPLICATION_IN_WORKSPACE) else [
        {
          "label": "Add New Project",
          "href": url_for('workspaces.new_project', workspace_id=workspace.id),
          "active": g.matchesPath('\/workspaces\/[A-Za-z0-9-]*\/projects'),
          "icon": "plus"
        }
      ]
    ) }}

    {% if user_can(permissions.VIEW_WORKSPACE_MEMBERS) %}
      {{ SidenavItem(
        "Members",
        href=url_for("workspaces.workspace_members", workspace_id=workspace.id),
        active=request.url_rule.rule.startswith('/workspaces/<workspace_id>/members'),
        subnav=None if not user_can(permissions.ASSIGN_AND_UNASSIGN_ATAT_ROLE) else [
          {
            "label": "Add New Member",
            "href": url_for("workspaces.new_member", workspace_id=workspace.id),
            "active": request.url_rule.rule.startswith('/workspaces/<workspace_id>/members/new'),
            "icon": "plus"
          }
        ]
      ) }}
    {% endif %}

    {% if user_can(permissions.VIEW_USAGE_DOLLARS) %}
      {{ SidenavItem(
        "Budget Report",
        href=url_for("workspaces.workspace_reports", workspace_id=workspace.id),
        active=request.url_rule.rule.startswith('/workspaces/<workspace_id>/reports')
      ) }}
    {% endif %}

    {% if user_can(permissions.EDIT_WORKSPACE_INFORMATION) %}
      {{ SidenavItem(
        "Workspace Settings",
        href=url_for("workspaces.workspace", workspace_id=workspace.id),
        active=request.url_rule.rule.startswith('/workspaces/<workspace_id>/edit'),
        subnav=None
      ) }}
    {% endif %}

  </ul>
</nav>
