<!-- Main navigation information -->

<!-- main menu -->
<% current_path = request.path%>
<% namespace = controller_path.split("/").first %>
<div id="main-nav-tabs" class="main_nav_tabs">
  <ul class="nav nav-tabs" data-tabs="tabs">

    <!-- Navigation for organisation admin -->
    <% if (user_signed_in? && current_user.can_org_admin? && ( action_name.include? "admin_" ) ) %>
      <% if current_user.can_modify_templates? %>
        <% if namespace == "templates" then %>
          <li class="active">
        <% else %>
          <li>
        <% end %>
            <%= link_to t("org_admin.template_label"), admin_index_template_path(current_user.org_id) %>
          </li>
      <% end %>
      <% if current_user.can_modify_guidance? %>
        <% if namespace == "guidances" then %>
          <li class="active">
        <% else %>
          <li>
        <% end %>
          <%= link_to t("org_admin.guidance_label"), admin_index_guidance_path(current_user.org_id)%>
          </li>
      <% end %>
      <% if current_user.can_modify_org_details? %>
        <% if namespace == "orgs" then %>
          <li class="active">
        <% else %>
          <li>
        <% end %>
            <%= link_to t("org_admin.org_details_label"), admin_show_org_path(current_user.org_id)%>
          </li>
      <% end %>
      <% if current_user.can_grant_permissions? %>
        <% if current_path == "/org/admin/users/admin_index" || current_path == "/org/admin/users/admin_api_update" then %>
          <li class="active">
        <% else %>
          <li>
        <% end %>
          <%= link_to t("org_admin.user_list_label"), "/org/admin/users/admin_index", class: "main_nav_last_li"%>
          </li>
      <% end %>
    <% else %>
      <% if user_signed_in? %>
        <!-- project and plan page -->
        <% if (namespace == "projects" || namespace == "plans") && current_path != "/projects/new" then %>
          <li class="active">
        <% else %>
          <li>
        <% end %>
        <%= link_to t("helpers.view_plans_label"), projects_path %>
          </li>
        <!-- create a plan page -->
        <% if current_path == "/projects/new" then %>
          <li class="active">
        <% else %>
          <li>
        <% end %>
          <%= link_to t("helpers.create_plan_label"), new_project_path %>
          </li>

      <% else %>
        <!-- Home page -->
        <% if current_path == "/" then %>
          <li class="active">
        <% else %>
          <li>
        <% end %>
          <%= link_to t("helpers.home"), root_path %>
          </li>
      <% end %>
      <!-- about_us page -->
      <% if current_path == "/about_us" then %>
        <li class="active">
      <% else %>
        <li>
      <% end %>
          <a href="<%= about_us_path %>"><%= t("helpers.about_us_label") %></a>
        </li>
      <!-- roadmap page -->
      <% if current_path == "/roadmap" then %>
        <li class="active">
      <% else %>
        <li>
      <% end %>
          <a href="<%= roadmap_path %>"><%= t("helpers.roadmap_label") %></a>
        </li>
      <!-- help page -->
      <% if current_path == "/help" then %>
        <li class="active">
      <% else %>
        <li>
      <% end %>
          <a href="<%= help_path %>" class="main_nav"><%= t("helpers.help_label") %></a>
        </li>

      <!-- plans/publicly_available page -->
      <% if current_path == "/plans/public_plans" then %>
        <li class="active">
      <% else %>
        <li>
      <% end %>
          <a href="<%= public_plans_path %>"><%= t("helpers.public_plans_label") %></a>
      </li>

      <!-- language dropdown -->
      <li class="dropdown sign_in">
        <a class="dropdown-toggle main_nav" data-toggle="dropdown" href="#">
          <%= t('helpers.change_language')%>
          <b class="caret caret-orange"></b>
        </a>
        <ul class="dropdown-menu" style="padding: 0;">
          <% Language.all.order('name ASC').each do |language|%>
            <% if I18n.locale == language.abbreviation %>
              <li class="active">
            <% else %>
              <li>
            <% end %>
                <%= link_to language.name, {locale: language.abbreviation}, class: 'main_nav lang-dropdown-link'%>
              </li>
          <% end %>
        </ul>
      </li>
    <% end %>
  </ul>
</div>
