@using System.Threading.Tasks
@using Volo.Abp.Session
@using Volo.Abp.Ui.Navigation
@model ApplicationMenu
@inject ICurrentUser CurrentUser
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
    <a class="navbar-brand" href="#"><i>Project</i>Name</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarsExampleDefault">
        <ul class="navbar-nav mr-auto">
            @foreach (var menuItem in Model.Items)
            {
                if (menuItem.IsLeaf)
                {
                    <li class="nav-item @(menuItem.IsDisabled ? "disabled" : "")">
                        <!-- active -->
                        <a class="nav-link" href="@(menuItem.Url ?? "#")">@menuItem.DisplayName</a> @*<span class="sr-only">(current)</span>*@
                    </li>
                }
                else
                {
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="Menu_@(menuItem.Name)" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">@menuItem.DisplayName</a>
                        <div class="dropdown-menu" aria-labelledby="Menu_@(menuItem.Name)">
                            @foreach (var childMenuItem in menuItem.Items)
                            {
                                <a class="dropdown-item" href="@(childMenuItem.Url ?? "#")">@childMenuItem.DisplayName</a>
                            }
                        </div>
                    </li>
                }
            }
        </ul>
        
        @if (CurrentUser.IsAuthenticated)
        {
            <div>
                <span style="color: #fff">@CurrentUser.UserName</span> (<a href="/Account/Logout">Logout</a>)
            </div>
        }
        else
        {
            <a href="/Account/Login">Login</a>
        }
    </div>
</nav>
